Opened 11 months ago
Last modified 5 months ago
#21272 new defect (bug)
reporting typo in dbDelta
| Reported by: |
|
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)
Change History (5)
comment:1
coffee2code
— 11 months ago
- Keywords needs-patch added
- Version set to 3.4.1
wonderboymusic
— 10 months ago
comment:2
wonderboymusic
— 10 months ago
- Keywords has-patch added; needs-patch removed
wonderboymusic
— 5 months ago
comment:3
wonderboymusic
— 5 months ago
- Milestone changed from Awaiting Review to 3.6
Updated patch applies cleanly against trunk
Note: See
TracTickets for help on using
tickets.
Now arbitrarily adds items to array, rather than clobbering the key in the loop. Patch added.