[wp-trac] [WordPress Trac] #16977: PHP notice for undefined variable in wp_list_post_revisions()

WordPress Trac wp-trac at lists.automattic.com
Sun Mar 27 02:28:07 UTC 2011


#16977: PHP notice for undefined variable in wp_list_post_revisions()
--------------------------+-----------------------------
 Reporter:  boonebgorges  |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Revisions     |    Version:  3.1
 Severity:  trivial       |   Keywords:  has-patch
--------------------------+-----------------------------
 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.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16977>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list