From: Reedy Date: Wed, 26 Apr 2017 16:08:51 +0000 (+0100) Subject: Making numerous fields unsigned to match their target referenced column X-Git-Tag: 1.31.0-rc.0~2197^2 X-Git-Url: http://git.cyclocoop.org/%27.parametre_url%28%20%20%20generer_action_auteur%28%27charger_plugin%27%2C%20%27update_flux%27%29%2C%27update_flux%27%2C%20%27oui%27%29.%27?a=commitdiff_plain;h=f4022fe876525b49d557194d084b35bd59e0f336;p=lhc%2Fweb%2Fwiklou.git Making numerous fields unsigned to match their target referenced column Bug: T157227 Change-Id: Ic11822d6c893103adcc99a3e188a592f13c968b8 --- diff --git a/RELEASE-NOTES-1.30 b/RELEASE-NOTES-1.30 index b478f51fcf..0b2faecea9 100644 --- a/RELEASE-NOTES-1.30 +++ b/RELEASE-NOTES-1.30 @@ -209,6 +209,9 @@ changes to languages because of Phabricator reports. (formerly it was needed by PostgreSQL and Oracle), and is now deprecated. * (T146591) The lc_lang_key index on the l10n_cache table has been changed into a PRIMARY KEY. +* (T157227) bot_password.bp_user, change_tag.ct_log_id, change_tag.ct_rev_id, + page_restrictions.pr_user, tag_summary.ts_log_id, tag_summary.ts_rev_id and + user_properties.up_user have all been made unsigned on MySQL. == Compatibility == MediaWiki 1.30 requires PHP 5.5.9 or later. There is experimental support for diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index aeecbb0e3d..2abc6b61db 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -266,7 +266,6 @@ class MysqlUpdater extends DatabaseUpdater { 'patch-fa_major_mime-chemical.sql' ], // 1.25 - [ 'doUserNewTalkUseridUnsigned' ], // note this patch covers other _comment and _description fields too [ 'modifyField', 'recentchanges', 'rc_comment', 'patch-editsummary-length.sql' ], @@ -329,6 +328,7 @@ class MysqlUpdater extends DatabaseUpdater { [ 'migrateComments' ], [ 'renameIndex', 'l10n_cache', 'lc_lang_key', 'PRIMARY', false, 'patch-l10n_cache-primary-key.sql' ], + [ 'doUnsignedSyncronisation' ], ]; } @@ -1123,26 +1123,42 @@ class MysqlUpdater extends DatabaseUpdater { ); } - protected function doUserNewTalkUseridUnsigned() { - if ( !$this->doTable( 'user_newtalk' ) ) { - return true; - } + protected function doUnsignedSyncronisation() { + $sync = [ + [ 'table' => 'bot_passwords', 'field' => 'bp_user' ], + [ 'table' => 'change_tag', 'field' => 'ct_log_id' ], + [ 'table' => 'change_tag', 'field' => 'ct_rev_id' ], + [ 'table' => 'page_restrictions', 'field' => 'pr_user' ], + [ 'table' => 'tag_summary', 'field' => 'ts_log_id' ], + [ 'table' => 'tag_summary', 'field' => 'ts_rev_id' ], + [ 'table' => 'user_newtalk', 'field' => 'user_id' ], + [ 'table' => 'user_properties', 'field' => 'up_user' ], + ]; - $info = $this->db->fieldInfo( 'user_newtalk', 'user_id' ); - if ( $info === false ) { - return true; - } - if ( $info->isUnsigned() ) { - $this->output( "...user_id is already unsigned int.\n" ); + foreach ( $sync as $s ) { + if ( !$this->doTable( $s['table'] ) ) { + continue; + } - return true; + $info = $this->db->fieldInfo( $s['table'], $s['field'] ); + if ( $info === false ) { + continue; + } + $fullName = "{$s['table']}.{$s['field']}"; + if ( $info->isUnsigned() ) { + $this->output( "...$fullName is already unsigned int.\n" ); + + continue; + } + + $this->applyPatch( + "patch-{$s['table']}-{$s['field']}-unsigned.sql", + false, + "Making $fullName into an unsigned int" + ); } - return $this->applyPatch( - 'patch-user-newtalk-userid-unsigned.sql', - false, - 'Making user_id unsigned int' - ); + return true; } protected function doRevisionPageRevIndexNonUnique() { diff --git a/maintenance/archives/patch-bot_passwords-bp_user-unsigned.sql b/maintenance/archives/patch-bot_passwords-bp_user-unsigned.sql new file mode 100644 index 0000000000..163609abe5 --- /dev/null +++ b/maintenance/archives/patch-bot_passwords-bp_user-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/bot_passwords MODIFY bp_user int unsigned NOT NULL; \ No newline at end of file diff --git a/maintenance/archives/patch-change_tag-ct_log_id-unsigned.sql b/maintenance/archives/patch-change_tag-ct_log_id-unsigned.sql new file mode 100644 index 0000000000..1371c474f3 --- /dev/null +++ b/maintenance/archives/patch-change_tag-ct_log_id-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/change_tag MODIFY ct_log_id int unsigned NULL; \ No newline at end of file diff --git a/maintenance/archives/patch-change_tag-ct_rev_id-unsigned.sql b/maintenance/archives/patch-change_tag-ct_rev_id-unsigned.sql new file mode 100644 index 0000000000..b7e1f02e21 --- /dev/null +++ b/maintenance/archives/patch-change_tag-ct_rev_id-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/change_tag MODIFY ct_rev_id int unsigned NULL; \ No newline at end of file diff --git a/maintenance/archives/patch-page_restrictions-pr_user-unsigned.sql b/maintenance/archives/patch-page_restrictions-pr_user-unsigned.sql new file mode 100644 index 0000000000..2337ff0ce5 --- /dev/null +++ b/maintenance/archives/patch-page_restrictions-pr_user-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/page_restrictions MODIFY pr_user int unsigned NULL; diff --git a/maintenance/archives/patch-tag_summary-ts_log_id-unsigned.sql b/maintenance/archives/patch-tag_summary-ts_log_id-unsigned.sql new file mode 100644 index 0000000000..617073dbf2 --- /dev/null +++ b/maintenance/archives/patch-tag_summary-ts_log_id-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/tag_summary MODIFY ts_log_id int unsigned NULL; \ No newline at end of file diff --git a/maintenance/archives/patch-tag_summary-ts_rev_id-unsigned.sql b/maintenance/archives/patch-tag_summary-ts_rev_id-unsigned.sql new file mode 100644 index 0000000000..e6a5bcde01 --- /dev/null +++ b/maintenance/archives/patch-tag_summary-ts_rev_id-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/tag_summary MODIFY ts_rev_id int unsigned NULL; \ No newline at end of file diff --git a/maintenance/archives/patch-user-newtalk-userid-unsigned.sql b/maintenance/archives/patch-user-newtalk-userid-unsigned.sql deleted file mode 100644 index a83e03b9d2..0000000000 --- a/maintenance/archives/patch-user-newtalk-userid-unsigned.sql +++ /dev/null @@ -1 +0,0 @@ -ALTER TABLE /*_*/user_newtalk MODIFY user_id int unsigned NOT NULL default 0; diff --git a/maintenance/archives/patch-user_newtalk-user_id-unsigned.sql b/maintenance/archives/patch-user_newtalk-user_id-unsigned.sql new file mode 100644 index 0000000000..a83e03b9d2 --- /dev/null +++ b/maintenance/archives/patch-user_newtalk-user_id-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/user_newtalk MODIFY user_id int unsigned NOT NULL default 0; diff --git a/maintenance/archives/patch-user_properties-up_user-unsigned.sql b/maintenance/archives/patch-user_properties-up_user-unsigned.sql new file mode 100644 index 0000000000..f4f563f8bf --- /dev/null +++ b/maintenance/archives/patch-user_properties-up_user-unsigned.sql @@ -0,0 +1 @@ +ALTER TABLE /*_*/user_properties MODIFY up_user int unsigned NOT NULL; \ No newline at end of file diff --git a/maintenance/tables.sql b/maintenance/tables.sql index bed80db37c..1813f6cdf0 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -213,7 +213,7 @@ CREATE INDEX /*i*/un_user_ip ON /*_*/user_newtalk (user_ip); -- CREATE TABLE /*_*/user_properties ( -- Foreign key to user.user_id - up_user int NOT NULL, + up_user int unsigned NOT NULL, -- Name of the option being saved. This is indexed for bulk lookup. up_property varbinary(255) NOT NULL, @@ -231,7 +231,7 @@ CREATE INDEX /*i*/user_properties_property ON /*_*/user_properties (up_property) -- CREATE TABLE /*_*/bot_passwords ( -- User ID obtained from CentralIdLookup. - bp_user int NOT NULL, + bp_user int unsigned NOT NULL, -- Application identifier bp_app_id varbinary(32) NOT NULL, @@ -1640,7 +1640,7 @@ CREATE TABLE /*_*/page_restrictions ( -- Whether or not to cascade the protection down to pages transcluded. pr_cascade tinyint NOT NULL, -- Field for future support of per-user restriction. - pr_user int NULL, + pr_user int unsigned NULL, -- Field for time-limited protection. pr_expiry varbinary(14) NULL ) /*$wgDBTableOptions*/; @@ -1692,9 +1692,9 @@ CREATE TABLE /*_*/change_tag ( -- RCID for the change ct_rc_id int NULL, -- LOGID for the change - ct_log_id int NULL, + ct_log_id int unsigned NULL, -- REVID for the change - ct_rev_id int NULL, + ct_rev_id int unsigned NULL, -- Tag applied ct_tag varchar(255) NOT NULL, -- Parameters for the tag, presently unused @@ -1715,9 +1715,9 @@ CREATE TABLE /*_*/tag_summary ( -- RCID for the change ts_rc_id int NULL, -- LOGID for the change - ts_log_id int NULL, + ts_log_id int unsigned NULL, -- REVID for the change - ts_rev_id int NULL, + ts_rev_id int unsigned NULL, -- Comma-separated list of tags ts_tags blob NOT NULL ) /*$wgDBTableOptions*/;