From ab8cff782774ddb45aad9fe7cdf49b877ca88f26 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Thu, 17 Dec 2015 18:12:50 +0000 Subject: [PATCH] In `WP::handle_404()`, make sure `$wp_query->post` is a `WP_Post` object before cloning it. Props igmoweb for initial patch. See #35013. git-svn-id: https://develop.svn.wordpress.org/trunk@35994 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 06c59bd7b7..9f6172deac 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' ) );