r73015 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r73014‎ | r73015 | r73016 >
Date:20:21, 14 September 2010
Author:ialex
Status:ok
Tags:
Comment:
Converted TitleKey extension to use the new LoadExtensionSchemaUpdates hook
Modified paths:
  • /trunk/extensions/TitleKey/TitleKey_body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/TitleKey/TitleKey_body.php
@@ -109,25 +109,35 @@
110110 *
111111 * Status info is sent to stdout.
112112 */
113 - static function schemaUpdates() {
114 - global $wgDBtype;
115 - $db = wfGetDB( DB_MASTER );
 113+ static function schemaUpdates( $updater = null ) {
 114+ if ( $updater === null ) { // < 1.17
 115+ self::runUpdates( wfGetDB( DB_MASTER ) );
 116+ } else {
 117+ $updater->addExtensionUpdate( array( array( __CLASS__, 'addDBtable' ) ) );
 118+ }
 119+ return true;
 120+ }
 121+
 122+ public static function addDBtable( $updater ) {
 123+ self::runUpdates( $updater->getDB() );
 124+ }
 125+
 126+ private static function runUpdates( $db ) {
116127 if( $db->tableExists( 'titlekey' ) ) {
117 - echo "...titlekey already exists.\n";
 128+ wfOut( "...titlekey table already exists.\n" );
118129 } else {
119 - echo "...creating titlekey table...\n";
120 - $sourcefile = $wgDBtype == 'postgres' ? '/titlekey.pg.sql' : '/titlekey.sql';
 130+ wfOut( "Creating titlekey table..." );
 131+ $sourcefile = $db->getType() == 'postgres' ? '/titlekey.pg.sql' : '/titlekey.sql';
121132 $err = $db->sourceFile( dirname( __FILE__ ) . $sourcefile );
122133 if( $err !== true ) {
123134 throw new MWException( $err );
124135 }
125 -
126 - echo "...populating titlekey table...\n";
 136+
 137+ wfOut( "ok.\nPopulating titlekey table...\n" );
127138 self::populateKeys();
128139 }
129 - return true;
130140 }
131 -
 141+
132142 /**
133143 * (Re)populate the titlekeys table with all page titles,
134144 * optionally starting from a given page id.

Status & tagging log