[wp-trac] [WordPress Trac] #54159: comments_open() & pings_open() trigger PHP Notice when called on a page without a $post

WordPress Trac noreply at wordpress.org
Wed Nov 17 14:46:03 UTC 2021


#54159: comments_open() & pings_open() trigger PHP Notice when called on a page
without a $post
--------------------------+-----------------------------
 Reporter:  dd32          |       Owner:  hellofromTonya
     Type:  defect (bug)  |      Status:  accepted
 Priority:  normal        |   Milestone:  5.9
Component:  Comments      |     Version:
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+-----------------------------

Comment (by costdev):

 == Test Report
 === Env
 * WordPress 5.9-alpha-20211117.140912
 * Chrome 95.0.4638.69
 * Windows 10
 * Theme: Twenty Twenty Two
 * Gutenberg Editor
 * Plugin: None activated
 === Steps to test
 1. Add `comments_open( 999999 );` to your theme's `functions.php` file.
 2. Load any page. You should see a PHP notice.
 3. Apply the patch.
 4. Reload the page. You should not see a PHP notice.
 === Results
 **Without the patch:** A PHP notice displays for `Warning: Attempt to read
 property "comment_status" on null`.
 **With the patch:** The PHP notice no longer displays.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/54159#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list