r76959 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r76958‎ | r76959 | r76960 >
Date:21:08, 18 November 2010
Author:ialex
Status:ok
Tags:
Comment:
Converted GlobalUsage extension to use the new version of the LoadExtensionSchemaUpdates hook
Modified paths:
  • /trunk/extensions/GlobalUsage/GlobalUsageHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/GlobalUsage/GlobalUsageHooks.php
@@ -118,15 +118,29 @@
119119 /**
120120 * Hook to apply schema changes
121121 */
122 - public static function onLoadExtensionSchemaUpdates() {
123 - global $wgExtNewTables, $wgExtNewIndexes, $wgDBtype;
 122+ public static function onLoadExtensionSchemaUpdates( $updater = null ) {
124123 $dir = dirname( __FILE__ );
125 - if ( $wgDBtype == 'mysql' || $wgDBtype == 'sqlite' ) {
126 - $wgExtNewTables[] = array( 'globalimagelinks', "$dir/GlobalUsage.sql" );
127 - $wgExtNewIndexes[] = array( 'globalimagelinks', 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.sql" );
128 - } else if ( $wgDBtype == 'postgresql' ) {
129 - $wgExtNewTables[] = array( 'globalimagelinks', "$dir/GlobalUsage.pg.sql" );
130 - $wgExtNewIndexes[] = array( 'globalimagelinks', 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.pg.sql" );
 124+ if ( $updater === null ) {
 125+ global $wgExtNewTables, $wgExtNewIndexes, $wgDBtype;
 126+ if ( $wgDBtype == 'mysql' || $wgDBtype == 'sqlite' ) {
 127+ $wgExtNewTables[] = array( 'globalimagelinks', "$dir/GlobalUsage.sql" );
 128+ $wgExtNewIndexes[] = array( 'globalimagelinks', 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.sql" );
 129+ } else if ( $wgDBtype == 'postgresql' ) {
 130+ $wgExtNewTables[] = array( 'globalimagelinks', "$dir/GlobalUsage.pg.sql" );
 131+ $wgExtNewIndexes[] = array( 'globalimagelinks', 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.pg.sql" );
 132+ }
 133+ } else {
 134+ if ( $updater->getDB()->getType() == 'mysql' || $updater->getDB()->getType() == 'sqlite' ) {
 135+ $updater->addExtensionUpdate( array( 'addTable', 'globalimagelinks',
 136+ "$dir/GlobalUsage.sql", true ) );
 137+ $updater->addExtensionUpdate( array( 'addIndex', 'globalimagelinks',
 138+ 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.sql", true ) );
 139+ } else if ( $updater->getDB()->getType() == 'postgresql' ) {
 140+ $updater->addExtensionUpdate( array( 'addTable', 'globalimagelinks',
 141+ "$dir/GlobalUsage.pg.sql", true ) );
 142+ $updater->addExtensionUpdate( array( 'addIndex', 'globalimagelinks',
 143+ 'globalimagelinks_wiki_nsid_title', "$dir/patches/patch-globalimagelinks_wiki_nsid_title.pg.sql", true ) );
 144+ }
131145 }
132146 return true;
133147 }

Status & tagging log