From 546ece815472fbdaa5d124f0dbb3b4d8c81d2786 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 23 Dec 2015 01:41:24 +0000 Subject: [PATCH] In `WP::handle_404()`, make sure `$wp_query->post` is a `WP_Post` object before cloning it. Merges [35994] to the 4.4 branch. Props igmoweb, swissspidy. Fixes #35013. git-svn-id: https://develop.svn.wordpress.org/branches/4.4@36064 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/class-wp.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/wp-includes/class-wp.php b/src/wp-includes/class-wp.php index bcb8606336..3685305a26 100644 --- a/src/wp-includes/class-wp.php +++ b/src/wp-includes/class-wp.php @@ -609,7 +609,12 @@ class WP { $success = true; if ( is_singular() ) { - $p = clone $wp_query->post; + $p = false; + + if ( $wp_query->post instanceof WP_Post ) { + $p = clone $wp_query->post; + } + // Only set X-Pingback for single posts that allow pings. if ( $p && pings_open( $p ) ) { @header( 'X-Pingback: ' . get_bloginfo( 'pingback_url' ) );