r71431 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71430‎ | r71431 | r71432 >
Date:11:57, 22 August 2010
Author:ialex
Status:ok
Tags:
Comment:
Removed some specific methods from updaters.inc that can use generic ones
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)
  • /trunk/phase3/includes/installer/MysqlUpdater.php (modified) (history)
  • /trunk/phase3/maintenance/updaters.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/updaters.inc
@@ -165,50 +165,6 @@
166166 }
167167 }
168168
169 -function do_logging_timestamp_index() {
170 - global $wgDatabase;
171 - if ( $wgDatabase->indexExists( 'logging', 'times' ) ) {
172 - wfOut( "...timestamp key on logging already exists.\n" );
173 - } else {
174 - wfOut( "Adding timestamp key on logging table... " );
175 - $wgDatabase->sourceFile( archive( "patch-logging-times-index.sql" ) );
176 - wfOut( "ok\n" );
177 - }
178 -}
179 -
180 -function do_archive_user_index() {
181 - global $wgDatabase;
182 - if ( $wgDatabase->indexExists( 'archive', 'usertext_timestamp' ) ) {
183 - wfOut( "...usertext,timestamp key on archive already exists.\n" );
184 - } else {
185 - wfOut( "Adding usertext,timestamp key on archive table... " );
186 - $wgDatabase->sourceFile( archive( "patch-archive-user-index.sql" ) );
187 - wfOut( "ok\n" );
188 - }
189 -}
190 -
191 -function do_image_user_index() {
192 - global $wgDatabase;
193 - if ( $wgDatabase->indexExists( 'image', 'img_usertext_timestamp' ) ) {
194 - wfOut( "...usertext,timestamp key on image already exists.\n" );
195 - } else {
196 - wfOut( "Adding usertext,timestamp key on image table... " );
197 - $wgDatabase->sourceFile( archive( "patch-image-user-index.sql" ) );
198 - wfOut( "ok\n" );
199 - }
200 -}
201 -
202 -function do_oldimage_user_index() {
203 - global $wgDatabase;
204 - if ( $wgDatabase->indexExists( 'oldimage', 'oi_usertext_timestamp' ) ) {
205 - wfOut( "...usertext,timestamp key on oldimage already exists.\n" );
206 - } else {
207 - wfOut( "Adding usertext,timestamp key on oldimage table... " );
208 - $wgDatabase->sourceFile( archive( "patch-oldimage-user-index.sql" ) );
209 - wfOut( "ok\n" );
210 - }
211 -}
212 -
213169 function do_watchlist_update() {
214170 global $wgDatabase;
215171 $fname = 'do_watchlist_update';
@@ -277,17 +233,6 @@
278234 wfOut( "Done.\n" );
279235 }
280236
281 -function do_user_update() {
282 - global $wgDatabase;
283 - if ( $wgDatabase->fieldExists( 'user', 'user_emailauthenticationtimestamp' ) ) {
284 - wfOut( "User table contains old email authentication field. Dropping... " );
285 - $wgDatabase->sourceFile( archive( 'patch-email-authentication.sql' ) );
286 - wfOut( "ok\n" );
287 - } else {
288 - wfOut( "...user table does not contain old email authentication field.\n" );
289 - }
290 -}
291 -
292237 /**
293238 * 1.4 betas were missing the 'binary' marker from logging.log_title,
294239 * which causes a collation mismatch error on joins in MySQL 4.1.
@@ -475,28 +420,6 @@
476421 }
477422 }
478423
479 -function do_inverse_timestamp() {
480 - global $wgDatabase;
481 - if ( $wgDatabase->fieldExists( 'revision', 'inverse_timestamp' ) ) {
482 - wfOut( "Removing revision.inverse_timestamp and fixing indexes... " );
483 - $wgDatabase->sourceFile( archive( 'patch-inverse_timestamp.sql' ) );
484 - wfOut( "ok\n" );
485 - } else {
486 - wfOut( "...revision timestamp indexes already up to 2005-03-13\n" );
487 - }
488 -}
489 -
490 -function do_text_id() {
491 - global $wgDatabase;
492 - if ( $wgDatabase->fieldExists( 'revision', 'rev_text_id' ) ) {
493 - wfOut( "...rev_text_id already in place.\n" );
494 - } else {
495 - wfOut( "Adding rev_text_id field... " );
496 - $wgDatabase->sourceFile( archive( 'patch-rev_text_id.sql' ) );
497 - wfOut( "ok\n" );
498 - }
499 -}
500 -
501424 function do_pagelinks_update() {
502425 global $wgDatabase;
503426 if ( $wgDatabase->tableExists( 'pagelinks' ) ) {
@@ -537,18 +460,6 @@
538461 wfOut( "ok\n" );
539462 }
540463
541 -function do_drop_img_type() {
542 - global $wgDatabase;
543 -
544 - if ( $wgDatabase->fieldExists( 'image', 'img_type' ) ) {
545 - wfOut( "Dropping unused img_type field in image table... " );
546 - $wgDatabase->sourceFile( archive( 'patch-drop_img_type.sql' ) );
547 - wfOut( "ok\n" );
548 - } else {
549 - wfOut( "...no img_type field in image table; Good.\n" );
550 - }
551 -}
552 -
553464 function do_old_links_update() {
554465 if( !defined( 'MW_NO_SETUP' ) ) {
555466 define( 'MW_NO_SETUP', true );
Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -220,6 +220,24 @@
221221 wfOut( "ok\n" );
222222 }
223223 }
 224+
 225+ /**
 226+ * Drop a field from an existing table
 227+ *
 228+ * @param $table String Name of the table to modify
 229+ * @param $field String Name of the old field
 230+ * @param $patch String Path to the patch file
 231+ * @param $fullpath Boolean Whether to treat $patch path as a relative or not
 232+ */
 233+ function dropField( $table, $field, $patch, $fullpath = false ) {
 234+ if ( $this->db->fieldExists( $table, $field ) ) {
 235+ wfOut( "Table $table contains $field field. Dropping... " );
 236+ $this->applyPatch( $patch, $fullpath );
 237+ wfOut( "ok\n" );
 238+ } else {
 239+ wfOut( "...$table table does not contain $field field.\n" );
 240+ }
 241+ }
224242 }
225243
226244 class OracleUpdater extends DatabaseUpdater {
Index: trunk/phase3/includes/installer/MysqlUpdater.php
@@ -40,16 +40,16 @@
4141 array( 'addTable', 'logging', 'patch-logging.sql' ),
4242 array( 'addField', 'user', 'user_token', 'patch-user_token.sql' ),
4343 array( 'do_watchlist_update' ),
44 - array( 'do_user_update' ),
 44+ array( 'dropField', 'user', 'user_emailauthenticationtimestamp', 'patch-email-authentication.sql' ),
4545
4646 // 1.5
4747 array( 'do_schema_restructuring' ),
4848 array( 'addField', 'logging', 'log_params', 'patch-log_params.sql' ),
49 - array( 'check_bin', 'logging', 'log_title', 'patch-logging-title.sql', ),
 49+ array( 'check_bin', 'logging', 'log_title', 'patch-logging-title.sql', ),
5050 array( 'addField', 'archive', 'ar_rev_id', 'patch-archive-rev_id.sql' ),
5151 array( 'addField', 'page', 'page_len', 'patch-page_len.sql' ),
52 - array( 'do_inverse_timestamp' ),
53 - array( 'do_text_id' ),
 52+ array( 'dropField', 'revision', 'inverse_timestamp', 'patch-inverse_timestamp.sql' ),
 53+ array( 'addField', 'revision', 'rev_text_id', 'patch-rev_text_id.sql' ),
5454 array( 'addField', 'revision', 'rev_deleted', 'patch-rev_deleted.sql' ),
5555 array( 'addField', 'image', 'img_width', 'patch-img_width.sql' ),
5656 array( 'addField', 'image', 'img_metadata', 'patch-img_metadata.sql' ),
@@ -58,7 +58,7 @@
5959 array( 'doNamespaceSize' ),
6060 array( 'addField', 'image', 'img_media_type', 'patch-img_media_type.sql' ),
6161 array( 'do_pagelinks_update' ),
62 - array( 'do_drop_img_type' ),
 62+ array( 'dropField', 'image', 'img_type', 'patch-drop_img_type.sql' ),
6363 array( 'do_user_unique_update' ),
6464 array( 'do_user_groups_update' ),
6565 array( 'addField', 'site_stats', 'ss_total_pages', 'patch-ss_total_articles.sql' ),
@@ -69,7 +69,7 @@
7070
7171 // 1.6
7272 array( 'do_watchlist_null' ),
73 - array( 'do_logging_timestamp_index' ),
 73+ array( 'addIndex', 'logging', 'times', 'patch-logging-times-index.sql' ),
7474 array( 'addField', 'ipblocks', 'ipb_range_start', 'patch-ipb_range_start.sql' ),
7575 array( 'do_page_random_update' ),
7676 array( 'addField', 'user', 'user_registration', 'patch-user_registration.sql' ),
@@ -109,9 +109,9 @@
110110 array( 'addField', 'ipblocks', 'ipb_block_email', 'patch-ipb_emailban.sql' ),
111111 array( 'do_categorylinks_indices_update' ),
112112 array( 'addField', 'oldimage', 'oi_metadata', 'patch-oi_metadata.sql' ),
113 - array( 'do_archive_user_index' ),
114 - array( 'do_image_user_index' ),
115 - array( 'do_oldimage_user_index' ),
 113+ array( 'addIndex', 'archive', 'usertext_timestamp', 'patch-archive-user-index.sql' ),
 114+ array( 'addIndex', 'image', 'img_usertext_timestamp', 'patch-image-user-index.sql' ),
 115+ array( 'addIndex', 'oldimage', 'oi_usertext_timestamp', 'patch-oldimage-user-index.sql' ),
116116 array( 'addField', 'archive', 'ar_page_id', 'patch-archive-page_id.sql' ),
117117 array( 'addField', 'image', 'img_sha1', 'patch-img_sha1.sql' ),
118118

Status & tagging log