(bug 19408) user_properties.up_property: 32 bytes is not enough.
authorChad Horohoe <demon@users.mediawiki.org>
Tue, 3 May 2011 21:08:44 +0000 (21:08 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Tue, 3 May 2011 21:08:44 +0000 (21:08 +0000)
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()

RELEASE-NOTES
includes/installer/DatabaseUpdater.php
includes/installer/MysqlUpdater.php
includes/installer/SqliteUpdater.php
maintenance/archives/patch-up_property.sql [new file with mode: 0644]
maintenance/tables.sql

index 8c182e6..47319df 100644 (file)
@@ -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.
index c0cfcc2..1ac60ff 100644 (file)
@@ -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" );
                }
        }
index 3ab4b92..3078718 100644 (file)
@@ -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' ),
                );
        }
 
index d1a6c20..e2e0124 100644 (file)
@@ -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 (file)
index 0000000..742841e
--- /dev/null
@@ -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);
index 81f7424..5ccc61e 100644 (file)
@@ -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