From: Reedy Date: Sun, 17 Sep 2017 22:56:51 +0000 (+0100) Subject: Don't unconditionally run patch-editsummary-length.sql X-Git-Tag: 1.31.0-rc.0~2070^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=e6a77bb2d45ce24eb1832957eae73dfd882afc69 Don't unconditionally run patch-editsummary-length.sql Bug: T176041 Change-Id: I165ee4fa1c0cfadf5f8f400a0ea9db220ed7dbbb --- diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 2abc6b61db..e2ff9604a2 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -267,7 +267,7 @@ class MysqlUpdater extends DatabaseUpdater { // 1.25 // note this patch covers other _comment and _description fields too - [ 'modifyField', 'recentchanges', 'rc_comment', 'patch-editsummary-length.sql' ], + [ 'doExtendCommentLengths' ], // 1.26 [ 'dropTable', 'hitcounter' ], @@ -1181,6 +1181,22 @@ class MysqlUpdater extends DatabaseUpdater { ); } + protected function doExtendCommentLengths() { + $table = $this->db->tableName( 'revision' ); + $res = $this->db->query( "SHOW COLUMNS FROM $table LIKE 'rev_comment'" ); + $row = $this->db->fetchObject( $res ); + + if ( $row && ( $row->Type !== "varbinary(767)" || $row->Default !== "" ) ) { + $this->applyPatch( + 'patch-editsummary-length.sql', + false, + 'Extending edit summary lengths (and setting defaults)' + ); + } else { + $this->output( '...comment fields are up to date' ); + } + } + public function getSchemaVars() { global $wgDBTableOptions; diff --git a/maintenance/archives/patch-editsummary-length.sql b/maintenance/archives/patch-editsummary-length.sql index c8ac1adfb9..996d562d95 100644 --- a/maintenance/archives/patch-editsummary-length.sql +++ b/maintenance/archives/patch-editsummary-length.sql @@ -1,11 +1,11 @@ -ALTER TABLE /*_*/revision MODIFY rev_comment varbinary(767) NOT NULL; -ALTER TABLE /*_*/archive MODIFY ar_comment varbinary(767) NOT NULL; -ALTER TABLE /*_*/image MODIFY img_description varbinary(767) NOT NULL; -ALTER TABLE /*_*/oldimage MODIFY oi_description varbinary(767) NOT NULL; -ALTER TABLE /*_*/filearchive MODIFY fa_description varbinary(767); +ALTER TABLE /*_*/revision MODIFY rev_comment varbinary(767) NOT NULL default ''; +ALTER TABLE /*_*/archive MODIFY ar_comment varbinary(767) NOT NULL default ''; +ALTER TABLE /*_*/image MODIFY img_description varbinary(767) NOT NULL default ''; +ALTER TABLE /*_*/oldimage MODIFY oi_description varbinary(767) NOT NULL default ''; +ALTER TABLE /*_*/filearchive MODIFY fa_description varbinary(767) default ''; ALTER TABLE /*_*/filearchive MODIFY fa_deleted_reason varbinary(767) default ''; ALTER TABLE /*_*/recentchanges MODIFY rc_comment varbinary(767) NOT NULL default ''; ALTER TABLE /*_*/logging MODIFY log_comment varbinary(767) NOT NULL default ''; -ALTER TABLE /*_*/ipblocks MODIFY ipb_reason varbinary(767) NOT NULL; -ALTER TABLE /*_*/protected_titles MODIFY pt_reason varbinary(767); +ALTER TABLE /*_*/ipblocks MODIFY ipb_reason varbinary(767) NOT NULL default ''; +ALTER TABLE /*_*/protected_titles MODIFY pt_reason varbinary(767) default '';