Make WordPress Core

Opened 12 years ago

Closed 12 years ago

#23201 closed defect (bug) (duplicate)

post-template.php calls in_array() without checking args

Reported by: gcrumb's profile gcrumb Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Template Keywords: reporter-feedback
Focuses: Cc:

Description

Line 1039 of wp-includes/post-template looks like:

if ( in_array( $page->ID, $_current_page->ancestors ) )

... but in some circumstances, $_current_page->ancestors is null, which results in an error being thrown. I suggest testing the variable before passing it:

if ( gettype($_current_page->ancestors) === 'array' && in_array( $page->ID, $_current_page->ancestors ) )

Change History (4)

#1 @kovshenin
12 years ago

  • Cc kovshenin added
  • Keywords reporter-feedback added; has-patch removed

Hey there!

in some circumstances, $_current_page->ancestors is null

Can you elaborate on that? Under what circumstances will ancestors be null? Also, you can use is_array rather than gettype. Thanks!

#3 @johnbillion
12 years ago

I believe this was fixed in r23213.

#4 @SergeyBiryukov
12 years ago

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

Duplicate of #22882.

Note: See TracTickets for help on using tickets.