[wp-trac] [WordPress Trac] #21272: reporting typo in dbDelta

WordPress Trac wp-trac at lists.automattic.com
Sat Jul 14 14:45:26 UTC 2012


#21272: reporting typo in dbDelta
--------------------------+-----------------------------
 Reporter:  apimlott      |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Database      |    Version:
 Severity:  minor         |   Keywords:
--------------------------+-----------------------------
 In dbDelta, there is the section:


 {{{
                 // For every remaining index specified for the table
                 foreach ( (array) $indices as $index ) {
                         // Push a query line into $cqueries that adds the
 index to that table
                         $cqueries[] = "ALTER TABLE {$table} ADD $index";
                         $for_update[$table.'.'.$fieldname] = 'Added index
 '.$table.' '.$index;
                 }
 }}}

 Note that $for_update is updated with the wrong array index.  This causes
 some updates not to be returned in $for_update.  Better would be:

 {{{
                         $for_update[$table.'.'.$index] = 'Added index
 '.$table.' '.$index;
 }}}

 Even this is not really right, since indexes and columns may have the same
 names.  Given that the users of dbDelta don't even seem to care about the
 keys, it might be simpler just to change all the $for_update lines to

 {{{
                         $for_update[] = ...
 }}}

 except for the first one that must be keyed on table name.

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


More information about the wp-trac mailing list