Opened 14 years ago
Closed 14 years ago
#17921 closed defect (bug) (duplicate)
$curpage->post_parent and $curpage->post_name checks
Reported by: | adamnbowen | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.1.3 |
Component: | General | Keywords: | has-patch |
Focuses: | Cc: |
Description
So I'm not entirely sure the "root cause" of the problem, but I've encountered an issue with wp-includes/post.php. It seems to stem from the fact that there are not proper isset() checks being performed on properties of $curpage before they are accessed.
Below is the backtrace (note that this was on v 3.1.3, which has different line numbers from my patch, which was on the svn trunk):
Backtrace from warning 'Trying to get property of non-object' at /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/post.php 3163:
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 1600 calling get_page_by_path()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 1889 calling parse_query()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 2895 calling get_posts()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/class-wp.php 454 calling query()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/class-wp.php 501 calling query_posts()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/functions.php 1527 calling main()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-blog-header.php 14 calling wp()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/index.php 17 calling require()
Backtrace from warning 'Trying to get property of non-object' at /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/post.php 3158:
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 1600 calling get_page_by_path()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 1889 calling parse_query()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/query.php 2895 calling get_posts()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/class-wp.php 454 calling query()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/class-wp.php 501 calling query_posts()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-includes/functions.php 1527 calling main()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/wp-blog-header.php 14 calling wp()
. /var/www/vhosts/wisdomadhesives.com/subdomains/dev/httpdocs/index.php 17 calling require()
Again, I'm not sure, but this may come from some of our own experimentation with taxonomies.
Anyhow, I'm attaching the change I was able to make that solved the problem for me
Patch looks good. Please use tabs rather than spaces though (core coding standards) and
empty()
might be be better for the while clause.