WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

#19007 closed defect (bug) (duplicate)

Unnecessray database query and loop in dbDelta

Reported by: inxilpro Owned by:
Milestone: Priority: normal
Severity: normal Version: 3.2.1
Component: Upgrade/Install Keywords: has-patch needs-testing
Focuses: Cc:

Description

The dbDelta function currently queries the database for all tables using SHOW TABLES, loops through that data, and then queries the database again to DESCRIBE the tables it is upgrading. This causes some issues with advanced database setups where sharding is in place (not all tables are on the same database), but more importantly, it's completely unnecessary. The function is already hitting the database for each table that it's comparing, so the loop can be removed, and the table's existence can be checked after the DESCRIBE query is run. I threw together a quick patch, but I haven't tested it yet. When I get a chance, I'll post any additional comments.

Attachments (1)

upgrade.patch (12.6 KB) - added by inxilpro 2 years ago.
Patch

Download all attachments as: .zip

Change History (3)

inxilpro2 years ago

Patch

comment:2 nacin2 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Going to close this as a duplicate of #17998 as there's already work there in place.

If you can format your patch as an svn diff, rather than diff -u, and upload it there, we'd appreciate it. It may look similar to the patch I just uploaded there (plus the formatting changes).

Note: See TracTickets for help on using tickets.