[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 Sep 22 07:24:13 UTC 2021


#54159: comments_open() & pings_open() trigger PHP Notice when called on a page
without a $post
--------------------------+-----------------------------
 Reporter:  dd32          |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Comments      |    Version:
 Severity:  normal        |   Keywords:  has-patch
  Focuses:                |
--------------------------+-----------------------------
 Both `comments_open()` and `pings_open()` contain some slightly odd logic,
 that accounts for the `$post` not existing on one line, and assuming it
 does exist on the next. Causing a PHP Notice under some specific
 circumstances.

 Calling `comments_open( $post_id_that_does_not_exist )` would also trigger
 it.

 See attached.

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


More information about the wp-trac mailing list