http://www.mediawiki.org/wiki/Special:Code/MediaWiki/73015

Revision: 73015
Author:   ialex
Date:     2010-09-14 20:21:56 +0000 (Tue, 14 Sep 2010)

Log Message:
-----------
Converted TitleKey extension to use the new LoadExtensionSchemaUpdates hook

Modified Paths:
--------------
    trunk/extensions/TitleKey/TitleKey_body.php

Modified: trunk/extensions/TitleKey/TitleKey_body.php
===================================================================
--- trunk/extensions/TitleKey/TitleKey_body.php 2010-09-14 20:17:05 UTC (rev 
73014)
+++ trunk/extensions/TitleKey/TitleKey_body.php 2010-09-14 20:21:56 UTC (rev 
73015)
@@ -109,25 +109,35 @@
         *
         * Status info is sent to stdout.
         */
-       static function schemaUpdates() {
-               global $wgDBtype;
-               $db = wfGetDB( DB_MASTER );
+       static function schemaUpdates( $updater = null ) {
+               if ( $updater === null ) { // < 1.17
+                       self::runUpdates( wfGetDB( DB_MASTER ) );
+               } else {
+                       $updater->addExtensionUpdate( array( array( __CLASS__, 
'addDBtable' ) ) );
+               }
+               return true;
+       }
+
+       public static function addDBtable( $updater ) {
+               self::runUpdates( $updater->getDB() );
+       }
+
+       private static function runUpdates( $db ) {
                if( $db->tableExists( 'titlekey' ) ) {
-                       echo "...titlekey already exists.\n";
+                       wfOut( "...titlekey table already exists.\n" );
                } else {
-                       echo "...creating titlekey table...\n";
-                       $sourcefile = $wgDBtype == 'postgres' ? 
'/titlekey.pg.sql' : '/titlekey.sql';
+                       wfOut( "Creating titlekey table..." );
+                       $sourcefile = $db->getType() == 'postgres' ? 
'/titlekey.pg.sql' : '/titlekey.sql';
                        $err = $db->sourceFile( dirname( __FILE__ ) . 
$sourcefile );
                        if( $err !== true ) {
                                throw new MWException( $err );
                        }
-                       
-                       echo "...populating titlekey table...\n";
+
+                       wfOut( "ok.\nPopulating titlekey table...\n" );
                        self::populateKeys();
                }
-               return true;
        }
-       
+
        /**
         * (Re)populate the titlekeys table with all page titles,
         * optionally starting from a given page id.



_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to