Make WordPress Core

Opened 15 years ago

Closed 15 years ago

#16977 closed defect (bug) (fixed)

PHP notice for undefined variable in wp_list_post_revisions()

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

Description

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 http://core.trac.wordpress.org/browser/trunk/wp-includes/post-template.php#L1365 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 15 years ago.

Download all attachments as: .zip

Change History (3)

@boonebgorges
15 years ago

#1 @nacin
15 years ago

  • Milestone Awaiting Review3.2

Looks good.

#2 @nacin
15 years ago

  • Resolutionfixed
  • Status newclosed

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

Note: See TracTickets for help on using tickets.