Make WordPress Core

Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#31301 closed defect (bug) (duplicate)

Page ID of 0 passes is_page( 'ANYSLUG' ) check

Reported by: r-a-y's profile r-a-y Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.1
Component: Query Keywords: has-patch
Focuses: Cc:


For plugins using virtual pages like BuddyPress and bbPress, to avoid notices we override $wp_query to set the page ID to 0.

If we land on a page with our resetted page ID of 0, if a theme dev is using is_page( 'ANYSLUG' ) on this page, the check will always return true.

The problem is due to $wp_query->is_page() using in_array( $page_obj->ID, $page ):

in_array( 0, array( 'ANYSLUG' ) always returns true.

My suggested fix would have been to use in_array()'s strict check - in_array( $page_obj->ID, $page, true ) - but that fails this test:

So, I've opted to check the page ID before doing the in_array() check.

Attached is a unit test demonstrating the problem with the fix suggested above.

Attachments (1)

31301.01.patch (1.4 KB) - added by r-a-y 9 years ago.

Download all attachments as: .zip

Change History (4)

9 years ago

#1 @r-a-y
9 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
9 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Duplicate of #24674.

#3 @r-a-y
9 years ago

Ugh! Apologies for the duplicate and thanks for pointing me to that ticket, SergeyBiryukov!

Note: See TracTickets for help on using tickets.