Make WordPress Core

Opened 9 years ago

Closed 4 months ago

#40418 closed defect (bug) (fixed)

ID columns in multisite database tables should be unsigned

Reported by: johnjamesjacoby's profile johnjamesjacoby Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 6.9 Priority: normal
Severity: normal Version: 3.0
Component: Upgrade/Install Keywords: has-patch needs-refresh commit
Focuses: multisite Cc:

Description

See #8751 for ye'olde single-site effort to normalize the respective object ID columns.

All multisite ID columns are bigint(20), but none of them are unsigned which has 2 unintended consequences:

  • Negative numbers can be stored as values instead of being set to 0
  • Maximum int of 9223372036854775807 instead of intended 18446744073709551615

Changes are necessary to every multisite database table, as they all touch site or network IDs.

Patch imminent

Attachments (2)

40418.patch (4.2 KB) - added by johnjamesjacoby 9 years ago.
40418.2.patch (4.0 KB) - added by johnjamesjacoby 4 months ago.
Refreshed for 6.9, includes new wp_blogmeta table

Download all attachments as: .zip

Change History (17)

#1 @johnjamesjacoby
9 years ago

  • Component changed from General to Database
  • Focuses multisite added
  • Keywords 2nd-opinion has-patch needs-testing added
  • Severity changed from normal to major
  • Version set to 3.0

#2 @johnjamesjacoby
9 years ago

40418.patch

  • Bumps the database version (will likely need a patch refresh by the time it's time)
  • Updates $ms_global_tables in wp_get_db_schema() with the unsigned data types
  • Adds ALTERS to pre_schema_upgrade() for existing installations

Related to work from #38203.

This ticket was mentioned in Slack in #core-multisite by jjj. View the logs.


9 years ago

#4 @johnjamesjacoby
9 years ago

  • Summary changed from ID columns in multisite database tables are all unsigned to ID columns in multisite database tables should be unsigned

#5 @johnjamesjacoby
9 years ago

A few questions came up in Slack about this patch, so I'll answer them as best I can here:

  • These ALTERs will take some time, because indices need to be rebuilt
  • MySQL will invisibly perform table locks & copies for signature changes
  • MySQL will perform string to integer conversions on really large numbers, so places where values would be higher than PHP_INT_MAX could be turned into strings in PHP, and MySQL will save them correctly
  • My research on signed vs unsigned leads me to believe there is no performance benefit for WordPress with this change, as the range of available index values has not changed (it's only shifted out of negative numbers and into higher ones)

#6 @johnjamesjacoby
9 years ago

If you're curious about how I even discovered this in the first place, wonder over here but maybe come back quickly. :)

#7 @spacedmonkey
7 years ago

  • Keywords needs-refresh added
  • Owner set to flixos90
  • Status changed from new to assigned

This ticket needs to merged before 5.0.0 now that blogmeta (#37923) is in core.

The patch needs to refreshed a little before merge. I have assigned to @flixos90 to own, as he merged blog meta. Will to review and support on this.

This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.


7 years ago

This ticket was mentioned in Slack in #core-multisite by spacedmonkey. View the logs.


7 years ago

@johnjamesjacoby
4 months ago

Refreshed for 6.9, includes new wp_blogmeta table

#12 @johnjamesjacoby
4 months ago

  • Component changed from Database to Upgrade/Install
  • Keywords commit added; 2nd-opinion needs-testing removed
  • Milestone changed from Awaiting Review to 6.9
  • Owner changed from flixos90 to johnjamesjacoby
  • Severity changed from major to normal

Refreshed patch for 6.9, now including the wp_blogmeta table per @spacedmonkey's comment.

Moving this to the 6.9 milestone and adding the commit keyword.

#13 @spacedmonkey
4 months ago

This looks good to commit 👍

#15 @johnjamesjacoby
4 months ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 60497:

Multisite: Enforce consistent types on ID columns in multisite database tables, to better allow for foreign keys to more reliably be defined between them.

This change adjusts the install & upgrade routines so all of ID-based database columns in the multisite database tables are unsigned, bringing them up-to-speed with ID-based columns in single-site tables.

Additionally, the $wp_db_version number is bumped, and the pre_schema_upgrade() upgrade function is modified to accommodate & use that new version.

Follow-up to [10852].

Props spacedmonkey, johnjamesjacoby.

Fixes #40418.

Note: See TracTickets for help on using tickets.