[wp-trac] [WordPress Trac] #35013: WP4.4 function handle_404 yelds a fatal error on line 613 when trying to clone $wp_query->post if it's not an object
WordPress Trac
noreply at wordpress.org
Fri Dec 11 14:36:28 UTC 2015
#35013: WP4.4 function handle_404 yelds a fatal error on line 613 when trying to
clone $wp_query->post if it's not an object
----------------------------+------------------------------
Reporter: jdmweb | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Bootstrap/Load | Version: 4.4
Severity: normal | Resolution:
Keywords: | Focuses:
----------------------------+------------------------------
Description changed by SergeyBiryukov:
Old description:
> Hello.
>
> Here's the problem:
> Fatal error: __clone method called on non-object in
> /var/www/html/lesmenuires/wp-includes/class-wp.php on line 612
>
> So I went on having a look at what this function does, and this
> particular line, here's what I have:
> $p = clone $wp_query->post;
>
> I've just updated a multi site install to WordPress 4.4, and that is a
> core WordPress file so you should have the same code than me when looking
> at this file on the WP4.4 branch.
>
> I must be in the context where $wp_query->post hasn't been defined yet,
> which therefore triggers the error.
>
> I've tried a little fix like so:
> $p = is_object($wp_query->post) ? clone $wp_query->post : null;
> And that fixed my issue. But as this is a WordPress core file, I can't
> leave it like this that's why I'm reporting this to you today.
>
> To give you a bit more context if that helps:
>
> I've been running this multi site install for several years now, I've
> followed nearly every version upgrade and never had any issue before
> this upgrade.
>
> An element that might be important: I'm the context of a file in my theme
> with no active plugins (it's a special API). This file is called with an
> absolute path, and includes wp-blog-header.php to activate WordPress.
>
> Here's the complete stack trace with comments:
> Fatal error: __clone method called on non-object in
> /var/www/html/lesmenuires/wp-includes/class-wp.php on line 612
> Call Stack
> # Time Memory Function Location
> 1 0.0030 797888 {main}( ) ../noe-api.php:0 //This is the
> inclusion of my special file
> 2 0.0045 805128 require_once( '/var/www/html/lesmenuires/wp-blog-
> header.php' ) ../noe-api.php:16 //Before this line, nothing special
> happens, then I include wp-blog-header.php
> 3 0.8151 56045320 wp( ) ../wp-blog-header.php:14
> 4 0.8151 56045448 WP->main( ) ../functions.php:947
> 5 0.8173 56095592 WP->handle_404( ) ../class-
> wp.php:677 //Fatal
>
> Thanking you very much.
>
> Regards.
>
> PS: I have echoed a var_dump of $wp_query just before this line to give
> you a little more context if that's of any help:
>
> object(WP_Query)[165]
> public 'query_vars' =>
> array
> 'page' => int 0
> 'name' => string 'api' (length=3)
> 'error' => string '' (length=0)
> 'm' => string '' (length=0)
> 'p' => int 0
> 'post_parent' => string '' (length=0)
> 'subpost' => string '' (length=0)
> 'subpost_id' => string '' (length=0)
> 'attachment' => string '' (length=0)
> 'attachment_id' => int 0
> 'static' => string '' (length=0)
> 'pagename' => string '' (length=0)
> 'page_id' => int 0
> 'second' => string '' (length=0)
> 'minute' => string '' (length=0)
> 'hour' => string '' (length=0)
> 'day' => int 0
> 'monthnum' => int 0
> 'year' => int 0
> 'w' => int 0
> 'category_name' => string '' (length=0)
> 'tag' => string '' (length=0)
> 'cat' => string '' (length=0)
> 'tag_id' => string '' (length=0)
> 'author' => string '' (length=0)
> 'author_name' => string '' (length=0)
> 'feed' => string '' (length=0)
> 'tb' => string '' (length=0)
> 'paged' => int 0
> 'comments_popup' => string '' (length=0)
> 'meta_key' => string '' (length=0)
> 'meta_value' => string '' (length=0)
> 'preview' => string '' (length=0)
> 's' => string '' (length=0)
> 'sentence' => string '' (length=0)
> 'title' => string '' (length=0)
> 'fields' => string '' (length=0)
> 'menu_order' => string '' (length=0)
> 'category__in' =>
> array
> empty
> 'category__not_in' =>
> array
> empty
> 'category__and' =>
> array
> empty
> 'post__in' =>
> array
> empty
> 'post__not_in' =>
> array
> empty
> 'post_name__in' =>
> array
> empty
> 'tag__in' =>
> array
> empty
> 'tag__not_in' =>
> array
> empty
> 'tag__and' =>
> array
> empty
> 'tag_slug__in' =>
> array
> empty
> 'tag_slug__and' =>
> array
> empty
> 'post_parent__in' =>
> array
> empty
> 'post_parent__not_in' =>
> array
> empty
> 'author__in' =>
> array
> empty
> 'author__not_in' =>
> array
> empty
> 'ignore_sticky_posts' => boolean false
> 'suppress_filters' => boolean false
> 'cache_results' => boolean true
> 'update_post_term_cache' => boolean true
> 'update_post_meta_cache' => boolean true
> 'post_type' => string '' (length=0)
> 'posts_per_page' => int 10
> 'nopaging' => boolean false
> 'comments_per_page' => string '50' (length=2)
> 'no_found_rows' => boolean false
> 'order' => string 'DESC' (length=4)
> public 'tax_query' => null
> public 'meta_query' =>
> object(WP_Meta_Query)[4624]
> public 'queries' =>
> array
> empty
> public 'relation' => null
> public 'meta_table' => null
> public 'meta_id_column' => null
> public 'primary_table' => null
> public 'primary_id_column' => null
> protected 'table_aliases' =>
> array
> empty
> protected 'clauses' =>
> array
> empty
> protected 'has_or_relation' => boolean false
> public 'date_query' => boolean false
> public 'post_count' => int 0
> public 'current_post' => int -1
> public 'in_the_loop' => boolean false
> public 'comment_count' => int 0
> public 'current_comment' => int -1
> public 'found_posts' => int 0
> public 'max_num_pages' => int 0
> public 'max_num_comment_pages' => int 0
> public 'is_single' => boolean true
> public 'is_preview' => boolean false
> public 'is_page' => boolean false
> public 'is_archive' => boolean false
> public 'is_date' => boolean false
> public 'is_year' => boolean false
> public 'is_month' => boolean false
> public 'is_day' => boolean false
> public 'is_time' => boolean false
> public 'is_author' => boolean false
> public 'is_category' => boolean false
> public 'is_tag' => boolean false
> public 'is_tax' => boolean false
> public 'is_search' => boolean false
> public 'is_feed' => boolean false
> public 'is_comment_feed' => boolean false
> public 'is_trackback' => boolean false
> public 'is_home' => boolean false
> public 'is_404' => boolean false
> public 'is_embed' => boolean false
> public 'is_comments_popup' => boolean false
> public 'is_paged' => boolean false
> public 'is_admin' => boolean true
> public 'is_attachment' => boolean false
> public 'is_singular' => boolean true
> public 'is_robots' => boolean false
> public 'is_posts_page' => boolean false
> public 'is_post_type_archive' => boolean false
> private 'query_vars_hash' => string '49a108f3c6538dd0a5cc33d9f5f8e501'
> (length=32)
> private 'query_vars_changed' => boolean false
> public 'thumbnails_cached' => boolean false
> public 'updated_term_meta_cache' => boolean false
> public 'updated_comment_meta_cache' => boolean false
> private 'stopwords' => null
> private 'compat_fields' =>
> array
> 0 => string 'query_vars_hash' (length=15)
> 1 => string 'query_vars_changed' (length=18)
> private 'compat_methods' =>
> array
> 0 => string 'init_query_flags' (length=16)
> 1 => string 'parse_tax_query' (length=15)
> public 'query' =>
> array
> 'page' => string '' (length=0)
> 'name' => string 'api' (length=3)
> public 'request' => string 'SELECT lm_posts.* FROM lm_posts WHERE
> 1=1 AND lm_posts.post_name = 'api' AND lm_posts.post_type = 'post'
> ORDER BY lm_posts.post_date DESC ' (length=143)
> public 'posts' =>
> array
> empty
New description:
Hello.
Here's the problem:
`Fatal error: __clone method called on non-object in
/var/www/html/lesmenuires/wp-includes/class-wp.php on line 612`
So I went on having a look at what this function does, and this particular
line, here's what I have:
`$p = clone $wp_query->post;`
I've just updated a multi site install to WordPress 4.4, and that is a
core WordPress file so you should have the same code than me when looking
at this file on the WP4.4 branch.
I must be in the context where $wp_query->post hasn't been defined yet,
which therefore triggers the error.
I've tried a little fix like so:
`$p = is_object($wp_query->post) ? clone $wp_query->post : null;`
And that fixed my issue. But as this is a WordPress core file, I can't
leave it like this that's why I'm reporting this to you today.
To give you a bit more context if that helps:
I've been running this multi site install for several years now, I've
followed nearly every version upgrade and never had any issue before this
upgrade.
An element that might be important: I'm the context of a file in my theme
with no active plugins (it's a special API). This file is called with an
absolute path, and includes wp-blog-header.php to activate WordPress.
Here's the complete stack trace with comments:
{{{
Fatal error: __clone method called on non-object in
/var/www/html/lesmenuires/wp-includes/class-wp.php on line 612
Call Stack
# Time Memory Function Location
1 0.0030 797888 {main}( ) ../noe-api.php:0 //This is the
inclusion of my special file
2 0.0045 805128 require_once( '/var/www/html/lesmenuires/wp-blog-
header.php' ) ../noe-api.php:16 //Before this line, nothing special
happens, then I include wp-blog-header.php
3 0.8151 56045320 wp( ) ../wp-blog-header.php:14
4 0.8151 56045448 WP->main( ) ../functions.php:947
5 0.8173 56095592 WP->handle_404( ) ../class-
wp.php:677 //Fatal
}}}
Thanking you very much.
Regards.
PS: I have echoed a var_dump of $wp_query just before this line to give
you a little more context if that's of any help:
{{{
object(WP_Query)[165]
public 'query_vars' =>
array
'page' => int 0
'name' => string 'api' (length=3)
'error' => string '' (length=0)
'm' => string '' (length=0)
'p' => int 0
'post_parent' => string '' (length=0)
'subpost' => string '' (length=0)
'subpost_id' => string '' (length=0)
'attachment' => string '' (length=0)
'attachment_id' => int 0
'static' => string '' (length=0)
'pagename' => string '' (length=0)
'page_id' => int 0
'second' => string '' (length=0)
'minute' => string '' (length=0)
'hour' => string '' (length=0)
'day' => int 0
'monthnum' => int 0
'year' => int 0
'w' => int 0
'category_name' => string '' (length=0)
'tag' => string '' (length=0)
'cat' => string '' (length=0)
'tag_id' => string '' (length=0)
'author' => string '' (length=0)
'author_name' => string '' (length=0)
'feed' => string '' (length=0)
'tb' => string '' (length=0)
'paged' => int 0
'comments_popup' => string '' (length=0)
'meta_key' => string '' (length=0)
'meta_value' => string '' (length=0)
'preview' => string '' (length=0)
's' => string '' (length=0)
'sentence' => string '' (length=0)
'title' => string '' (length=0)
'fields' => string '' (length=0)
'menu_order' => string '' (length=0)
'category__in' =>
array
empty
'category__not_in' =>
array
empty
'category__and' =>
array
empty
'post__in' =>
array
empty
'post__not_in' =>
array
empty
'post_name__in' =>
array
empty
'tag__in' =>
array
empty
'tag__not_in' =>
array
empty
'tag__and' =>
array
empty
'tag_slug__in' =>
array
empty
'tag_slug__and' =>
array
empty
'post_parent__in' =>
array
empty
'post_parent__not_in' =>
array
empty
'author__in' =>
array
empty
'author__not_in' =>
array
empty
'ignore_sticky_posts' => boolean false
'suppress_filters' => boolean false
'cache_results' => boolean true
'update_post_term_cache' => boolean true
'update_post_meta_cache' => boolean true
'post_type' => string '' (length=0)
'posts_per_page' => int 10
'nopaging' => boolean false
'comments_per_page' => string '50' (length=2)
'no_found_rows' => boolean false
'order' => string 'DESC' (length=4)
public 'tax_query' => null
public 'meta_query' =>
object(WP_Meta_Query)[4624]
public 'queries' =>
array
empty
public 'relation' => null
public 'meta_table' => null
public 'meta_id_column' => null
public 'primary_table' => null
public 'primary_id_column' => null
protected 'table_aliases' =>
array
empty
protected 'clauses' =>
array
empty
protected 'has_or_relation' => boolean false
public 'date_query' => boolean false
public 'post_count' => int 0
public 'current_post' => int -1
public 'in_the_loop' => boolean false
public 'comment_count' => int 0
public 'current_comment' => int -1
public 'found_posts' => int 0
public 'max_num_pages' => int 0
public 'max_num_comment_pages' => int 0
public 'is_single' => boolean true
public 'is_preview' => boolean false
public 'is_page' => boolean false
public 'is_archive' => boolean false
public 'is_date' => boolean false
public 'is_year' => boolean false
public 'is_month' => boolean false
public 'is_day' => boolean false
public 'is_time' => boolean false
public 'is_author' => boolean false
public 'is_category' => boolean false
public 'is_tag' => boolean false
public 'is_tax' => boolean false
public 'is_search' => boolean false
public 'is_feed' => boolean false
public 'is_comment_feed' => boolean false
public 'is_trackback' => boolean false
public 'is_home' => boolean false
public 'is_404' => boolean false
public 'is_embed' => boolean false
public 'is_comments_popup' => boolean false
public 'is_paged' => boolean false
public 'is_admin' => boolean true
public 'is_attachment' => boolean false
public 'is_singular' => boolean true
public 'is_robots' => boolean false
public 'is_posts_page' => boolean false
public 'is_post_type_archive' => boolean false
private 'query_vars_hash' => string '49a108f3c6538dd0a5cc33d9f5f8e501'
(length=32)
private 'query_vars_changed' => boolean false
public 'thumbnails_cached' => boolean false
public 'updated_term_meta_cache' => boolean false
public 'updated_comment_meta_cache' => boolean false
private 'stopwords' => null
private 'compat_fields' =>
array
0 => string 'query_vars_hash' (length=15)
1 => string 'query_vars_changed' (length=18)
private 'compat_methods' =>
array
0 => string 'init_query_flags' (length=16)
1 => string 'parse_tax_query' (length=15)
public 'query' =>
array
'page' => string '' (length=0)
'name' => string 'api' (length=3)
public 'request' => string 'SELECT lm_posts.* FROM lm_posts WHERE 1=1
AND lm_posts.post_name = 'api' AND lm_posts.post_type = 'post' ORDER BY
lm_posts.post_date DESC ' (length=143)
public 'posts' =>
array
empty
}}}
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35013#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list