Make WordPress Core

Opened 13 years ago

Closed 13 years ago

#16977 closed defect (bug) (fixed)

PHP notice for undefined variable in wp_list_post_revisions()

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: 3.2 Priority: normal
Severity: trivial Version: 3.1
Component: Revisions Keywords: has-patch
Focuses: Cc:


I'm using wp_list_post_revisions() in a function, and noticed a bug related to $left_checked and $right_checked. Initial scenario/steps to reproduce:

1) Call wp_list_post_revisions(), within the loop, with the following arguments:

wp_list_post_revisions( get_the_ID(), array( 'format' => 'form-table' ) );

2) Load the page. Notice: Undefined variable: right_checked in /sites/yolanda/wp-includes/post-template.php on line 1369

The problem has to do with the fallback design of the form-table format. The logic at is: if an explicit 'right' parameter is passed (the New revision), but no 'left' argument (the Old revision), the next oldest revision should be checked as tho Old revision. That's done by checking to see whether $right_checked was set on the previous iteration of the foreach loop. The problem is that, on the first iteration of the foreach loop, $right_checked hasn't been cast at all.

I'm marking the bug as trivial since it doesn't arise at all in WP core (where $left and $right arguments are always passed to the function). It's only an issue for edge-case plugins.

Patch attached.

Attachments (1)

16977.patch (426 bytes) - added by boonebgorges 13 years ago.

Download all attachments as: .zip

Change History (3)

13 years ago

#1 @nacin
13 years ago

  • Milestone changed from Awaiting Review to 3.2

Looks good.

#2 @nacin
13 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [17564]) Initialize a variable. props boonebgorges, fixes #16977.

Note: See TracTickets for help on using tickets.