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

WordPress Trac noreply at wordpress.org
Sat Feb 14 02:07:36 UTC 2015


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

Comment (by boonebgorges):

 > We should be able to specifically tell the difference between a numeric
 string and a non-numeric string pretty easily.

 Casting the queried object ID to a string before testing against it has
 this effect. Basically, if you pass either 123 or '123' to `is_page()`,
 the following checks happen:

 1. Is the ID of the current page 123? If so, return true.
 2. Is the post_title of the current page 123? If so, return true.
 3. Is the post_name of the current page 123? If so, return true.

 The string-casting trick ensures that there's no funny business in check
 (1).

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


More information about the wp-trac mailing list