Make WordPress Core

Opened 4 years ago

Closed 4 years ago

Last modified 2 years ago

#52510 closed defect (bug) (duplicate)

In PHP 8.0, non-posts/pages shows an warning error "Attempt to read property on null"

Reported by: erwinbantilan's profile erwinbantilan Owned by:
Milestone: Priority: normal
Severity: minor Version: 5.6.1
Component: Query Keywords: has-patch
Focuses: Cc:

Description

In PHP 8.0, when accessing the non-posts/pages like /data/feed and /data/rss, it shows an PHP Warning error saying "Attempt to read property "post_title" on null".

This fix added an isset check for the variable and immediately return false value.

I have a pull request on your mirror github page, which shows the possible fixes for this error:
https://github.com/WordPress/WordPress/pull/532

Best Regards,

  • Erwin

Change History (4)

#1 @erwinbantilan
4 years ago

By the way here are the example errors:

2021/02/12 12:49:21 [error] 101518#101518: *74 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179" while reading response header from upstream, client: 49.145.229.24, server: gamingph.com, request: "GET /data/feed/ HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock:", host: "gamingph.com"
2021/02/12 10:56:58 [error] 84487#84487: *9570 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031" while reading response header from upstream, client: 212.83.184.228, server: gamingph.com, request: "GET /data/rss HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock:", host: "gamingph.com"

This ticket was mentioned in PR #995 on WordPress/wordpress-develop by bantilan.


4 years ago
#2

  • Keywords has-patch added

In PHP 8.0, when accessing the non-posts/pages like /data/feed and /data/rss, it shows an PHP Warning error saying "Attempt to read property "post_title" on null".

here are the example errors:

2021/02/12 12:49:21 [error] 101518#101518: *74 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179PHP message: PHP Warning: Attempt to read property "post_type" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4179" while reading response header from upstream, client: 49.145.229.24, server: gamingph.com, request: "GET /data/feed/ HTTP/2.0", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock:", host: "gamingph.com"

2021/02/12 10:56:58 [error] 84487#84487: *9570 FastCGI sent in stderr: "PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031PHP message: PHP Warning: Attempt to read property "ID" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4027PHP message: PHP Warning: Attempt to read property "post_title" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4029PHP message: PHP Warning: Attempt to read property "post_name" on null in /var/www/gamingph.com/wp-includes/class-wp-query.php on line 4031" while reading response header from upstream, client: 212.83.184.228, server: gamingph.com, request: "GET /data/rss HTTP/1.1", upstream: "fastcgi://unix:/var/run/php/php8.0-fpm.sock:", host: "gamingph.com"

This fix added an isset check for all variable that has null value when accessing non-posts/pages, it immediately return false value.

Trac ticket: https://core.trac.wordpress.org/ticket/52510

#3 @SergeyBiryukov
4 years ago

  • Component changed from General to Query
  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi there, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #29660.

#4 @etswak1
2 years ago

I have the same problem i don't know how i can fix it .
can someone of wordpress expert explain to us how we can solve it ?
i have php v8.0
wordpress v6

Note: See TracTickets for help on using tickets.