PHP notice for undefined variable in wp_list_post_revisions()
|Reported by:||boonebgorges||Owned by:|
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.