WordPress.org

Make WordPress Core

Opened 11 months ago

Last modified 5 months ago

#21272 new defect (bug)

reporting typo in dbDelta

Reported by: apimlott Owned by:
Priority: normal Milestone: 3.6
Component: Database Version: 3.4.1
Severity: minor Keywords: has-patch
Cc:

Description

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.

Attachments (2)

for-update-keys.diff (597 bytes) - added by wonderboymusic 10 months ago.
21272.diff (603 bytes) - added by wonderboymusic 5 months ago.

Download all attachments as: .zip

Change History (5)

comment:1 coffee2code11 months ago

  • Keywords needs-patch added
  • Version set to 3.4.1

comment:2 wonderboymusic10 months ago

  • Keywords has-patch added; needs-patch removed

Now arbitrarily adds items to array, rather than clobbering the key in the loop. Patch added.

wonderboymusic5 months ago

comment:3 wonderboymusic5 months ago

  • Milestone changed from Awaiting Review to 3.6

Updated patch applies cleanly against trunk

Note: See TracTickets for help on using tickets.