[wp-trac] [WordPress Trac] #37645: Changes made to certain is_*() functions generates PHP Notices when arrays or objects are present

WordPress Trac noreply at wordpress.org
Wed Feb 8 03:00:31 UTC 2017


#37645: Changes made to certain is_*() functions generates PHP Notices when arrays
or objects are present
--------------------------+------------------------------
 Reporter:  Enchiridion   |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  4.5
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by boonebgorges):

 Hi @Enchiridion - Thanks for the ticket, and many apologies for the
 silence. I missed the ticket when it originally came through.

 Looking closely at your issue: It seems to me that the problem is not
 #35902 [36625], but was only surfaced by that change. The real problem is
 that `WP_Post` objects are not a valid input for `is_attachment()`. The
 `is_*()` functions are meant to test whether the current *query* is for an
 attachment, NOT the current *post*; the optional `$attachment` parameter
 is an ID, slug, or array of IDs or slugs. `get_body_class()` is, as far as
 I can see, the only place where WP passes a post object into an `is_*()`
 function.

 It looks like the introduction of the clause `is_attachment( $post )` to
 `get_body_class()` in [27622] was probably by mistake. It should probably
 just be `is_attachment()`. @wonderboymusic - Can you cast your mind back
 to 2014 to verify?

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


More information about the wp-trac mailing list