r87357 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r87356‎ | r87357 | r87358 >
Date:21:08, 3 May 2011
Author:demon
Status:resolved (Comments)
Tags:schema 
Comment:
(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()
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/SqliteUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/archives/patch-up_property.sql (added) (history)
  • /trunk/phase3/maintenance/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/archives/patch-up_property.sql
@@ -0,0 +1,4 @@
 2+-- Increase the length of up_property from 32 -> 255 bytes. Bug 19408
 3+
 4+ALTER TABLE /*_*/user_properties
 5+ MODIFY up_property varbinary(255);
Property changes on: trunk/phase3/maintenance/archives/patch-up_property.sql
___________________________________________________________________
Added: svn:eol-style
16 + native
Index: trunk/phase3/maintenance/tables.sql
@@ -199,7 +199,7 @@
200200 up_user int NOT NULL,
201201
202202 -- Name of the option being saved. This is indexed for bulk lookup.
203 - up_property varbinary(32) NOT NULL,
 203+ up_property varbinary(255) NOT NULL,
204204
205205 -- Property value as a string.
206206 up_value blob
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -247,6 +247,7 @@
248248 * Helper function: check if the given key is present in the updatelog table.
249249 * Obviously, only use this for updates that occur after the updatelog table was
250250 * created!
 251+ * @param $key String Name of the key to check for
251252 */
252253 public function updateRowExists( $key ) {
253254 $row = $this->db->selectRow(
@@ -259,6 +260,21 @@
260261 }
261262
262263 /**
 264+ * Helper function: Add a key to the updatelog table
 265+ * Obviously, only use this for updates that occur after the updatelog table was
 266+ * created!
 267+ * @param $key String Name of key to insert
 268+ * @param $val String [optional] value to insert along with the key
 269+ */
 270+ public function insertUpdateRow( $key, $val = null ) {
 271+ $values = array( 'ul_key' => $key );
 272+ if( $val && $this->canUseNewUpdatelog() ) {
 273+ $values['ul_value'] = $val;
 274+ }
 275+ $this->db->insert( 'updatelog', $values, __METHOD__, 'IGNORE' );
 276+ }
 277+
 278+ /**
263279 * Updatelog was changed in 1.17 to have a ul_value column so we can record
264280 * more information about what kind of updates we've done (that's what this
265281 * class does). Pre-1.17 wikis won't have this column, and really old wikis
@@ -439,13 +455,17 @@
440456 * @param $fullpath Boolean: whether to treat $patch path as a relative or not
441457 */
442458 public function modifyField( $table, $field, $patch, $fullpath = false ) {
 459+ $updateKey = "$table-$field-$patch";
443460 if ( !$this->db->tableExists( $table ) ) {
444461 $this->output( "...$table table does not exist, skipping modify field patch\n" );
445462 } elseif ( !$this->db->fieldExists( $table, $field ) ) {
446463 $this->output( "...$field field does not exist in $table table, skipping modify field patch\n" );
 464+ } elseif( $this->updateRowExists( $updateKey ) ) {
 465+ $this->output( "...$field in table $table already modified by patch $patch\n" );
447466 } else {
448467 $this->output( "Modifying $field field of table $table..." );
449468 $this->applyPatch( $patch, $fullpath );
 469+ $this->insertUpdateRow( $updateKey );
450470 $this->output( "ok\n" );
451471 }
452472 }
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -179,6 +179,7 @@
180180 // 1.18
181181 array( 'doUserNewTalkTimestampNotNull' ),
182182 array( 'addIndex', 'user', 'user_email', 'patch-user_email_index.sql' ),
 183+ array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
183184 );
184185 }
185186
Index: trunk/phase3/includes/installer/SqliteUpdater.php
@@ -52,6 +52,9 @@
5353 array( 'doCollationUpdate' ),
5454 array( 'addTable', 'msg_resource', 'patch-msg_resource.sql' ),
5555 array( 'addTable', 'module_deps', 'patch-module_deps.sql' ),
 56+
 57+ // 1.18
 58+ array( 'modifyField', 'user_properties', 'up_property', 'patch-up_property.sql' ),
5659 );
5760 }
5861
Index: trunk/phase3/RELEASE-NOTES
@@ -255,6 +255,7 @@
256256 * (bug 28752) XCache doesn't work in CLI mode.
257257 * (bug 28076) Thumbnail height limited to 360 pixels on Special:Listfiles
258258 * (bug 22227) Special:Listfiles no longer throws an error on bogus file entries
 259+* (bug 19408) user_properties.up_property: 32 bytes is not enough.
259260
260261 === API changes in 1.18 ===
261262 * (bug 26339) Throw warning when truncating an overlarge API result.

Sign-offs

UserFlagDate
Reedytested21:12, 3 May 2011

Follow-up revisions

RevisionCommit summaryAuthorDate
r87706Revert SQLite-related part of r87357: sauses SLQ errors, not neededmaxsem11:03, 9 May 2011
r89521Revert SQLite-related part of r87357: sauses SLQ errors, not needed...hashar19:06, 5 June 2011

Comments

#Comment by Bryan (talk | contribs)   13:48, 7 May 2011

Sqlite does not support ALTER TABLE MODIFY, but it doesn't need it in this case, because varchars are converted to TEXT columns, which don't have a maximum length.

#Comment by MaxSem (talk | contribs)   11:04, 9 May 2011

Reverted in r87706.

Status & tagging log