[wp-trac] [WordPress Trac] #24674: WP_Query::is_page() should use stricter comparison

WordPress Trac noreply at wordpress.org
Sat Feb 14 02:08:49 UTC 2015


#24674: WP_Query::is_page() should use stricter comparison
--------------------------+---------------------------
 Reporter:  clifgriffin   |       Owner:  boonebgorges
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  4.2
Component:  Query         |     Version:  2.5
 Severity:  minor         |  Resolution:  fixed
 Keywords:  has-patch     |     Focuses:
--------------------------+---------------------------
Changes (by boonebgorges):

 * owner:   => boonebgorges
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"31458"]:
 {{{
 #!CommitTicketReference repository="" revision="31458"
 More careful type conversion in `WP_Query` `is_*()` methods.

 `is_array( 1, '1-foo' )` returns true, which means that `is_page( 1 )`
 was returning true when on a page with the slug '1-foo'. We avoid this odd
 behavior by casting the queried object ID to a string before testing
 against
 the value passed to the conditional function.

 This also helps to avoid a problem where an arbitrary value for `$page`
 would
 cause `is_page( $page )` to return true if the query had been manipulated
 by
 a plugin to show that the current page's ID is 0.

 Props boonebgorges, r-a-y, nunomorgadinho, wonderboymusic, clifgriffin.
 Fixes #24674.
 }}}

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


More information about the wp-trac mailing list