From: Chad Horohoe Date: Tue, 3 May 2011 21:08:44 +0000 (+0000) Subject: (bug 19408) user_properties.up_property: 32 bytes is not enough. X-Git-Tag: 1.31.0-rc.0~30428 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/gestion/rappel_supprimer.php?a=commitdiff_plain;h=32fde7f35b6dde889f22eb1e4f10392acd0efde6;p=lhc%2Fweb%2Fwiklou.git (bug 19408) user_properties.up_property: 32 bytes is not enough. Increased it to 255 bytes to be like page titles Some minor tweaks to modifyField() in the installer to make it more useful and added insertUpdateRow() --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 8c182e6eec..47319df428 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -255,6 +255,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN * (bug 28752) XCache doesn't work in CLI mode. * (bug 28076) Thumbnail height limited to 360 pixels on Special:Listfiles * (bug 22227) Special:Listfiles no longer throws an error on bogus file entries +* (bug 19408) user_properties.up_property: 32 bytes is not enough. === API changes in 1.18 === * (bug 26339) Throw warning when truncating an overlarge API result. diff --git a/includes/installer/DatabaseUpdater.php b/includes/installer/DatabaseUpdater.php index c0cfcc2dcf..1ac60ff3e2 100644 --- a/includes/installer/DatabaseUpdater.php +++ b/includes/installer/DatabaseUpdater.php @@ -247,6 +247,7 @@ abstract class DatabaseUpdater { * Helper function: check if the given key is present in the updatelog table. * Obviously, only use this for updates that occur after the updatelog table was * created! + * @param $key String Name of the key to check for */ public function updateRowExists( $key ) { $row = $this->db->selectRow( @@ -258,6 +259,21 @@ abstract class DatabaseUpdater { return (bool)$row; } + /** + * Helper function: Add a key to the updatelog table + * Obviously, only use this for updates that occur after the updatelog table was + * created! + * @param $key String Name of key to insert + * @param $val String [optional] value to insert along with the key + */ + public function insertUpdateRow( $key, $val = null ) { + $values = array( 'ul_key' => $key ); + if( $val && $this->canUseNewUpdatelog() ) { + $values['ul_value'] = $val; + } + $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' ); + } + /** * Updatelog was changed in 1.17 to have a ul_value column so we can record * more information about what kind of updates we've done (that's what this @@ -439,13 +455,17 @@ abstract class DatabaseUpdater { * @param $fullpath Boolean: whether to treat $patch path as a relative or not */ public function modifyField( $table, $field, $patch, $fullpath = false ) { + $updateKey = "$table-$field-$patch"; if ( !$this->db->tableExists( $table ) ) { $this->output( "...$table table does not exist, skipping modify field patch\n" ); } elseif ( !$this->db->fieldExists( $table, $field ) ) { $this->output( "...$field field does not exist in $table table, skipping modify field patch\n" ); + } elseif( $this->updateRowExists( $updateKey ) ) { + $this->output( "...$field in table $table already modified by patch $patch\n" ); } else { $this->output( "Modifying $field field of table $table..." ); $this->applyPatch( $patch, $fullpath ); + $this->insertUpdateRow( $updateKey ); $this->output( "ok\n" ); } } diff --git a/includes/installer/MysqlUpdater.php b/includes/installer/MysqlUpdater.php index 3ab4b92b5f..3078718404 100644 --- a/includes/installer/MysqlUpdater.php +++ b/includes/installer/MysqlUpdater.php @@ -179,6 +179,7 @@ class MysqlUpdater extends DatabaseUpdater { // 1.18 array( 'doUserNewTalkTimestampNotNull' ), array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ), + array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), ); } diff --git a/includes/installer/SqliteUpdater.php b/includes/installer/SqliteUpdater.php index d1a6c20bb5..e2e01240b8 100644 --- a/includes/installer/SqliteUpdater.php +++ b/includes/installer/SqliteUpdater.php @@ -52,6 +52,9 @@ class SqliteUpdater extends DatabaseUpdater { array( 'doCollationUpdate' ), array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ), array( 'addTable', 'module_deps', 'patch-module_deps.sql' ), + + // 1.18 + array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ), ); } diff --git a/maintenance/archives/patch-up_property.sql b/maintenance/archives/patch-up_property.sql new file mode 100644 index 0000000000..742841e412 --- /dev/null +++ b/maintenance/archives/patch-up_property.sql @@ -0,0 +1,4 @@ +-- Increase the length of up_property from 32 -> 255 bytes. Bug 19408 + +ALTER TABLE /*_*/user_properties + MODIFY up_property varbinary(255); diff --git a/maintenance/tables.sql b/maintenance/tables.sql index 81f7424394..5ccc61e2aa 100644 --- a/maintenance/tables.sql +++ b/maintenance/tables.sql @@ -199,7 +199,7 @@ CREATE TABLE /*_*/user_properties ( up_user int NOT NULL, -- Name of the option being saved. This is indexed for bulk lookup. - up_property varbinary(32) NOT NULL, + up_property varbinary(255) NOT NULL, -- Property value as a string. up_value blob