r81603 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81602‎ | r81603 | r81604 >
Date:21:07, 6 February 2011
Author:ialex
Status:deferred (Comments)
Tags:
Comment:
Converted Wikilog extension to use the new version of the LoadExtensionSchemaUpdates hook
Modified paths:
  • /trunk/extensions/Wikilog/WikilogHooks.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Wikilog/WikilogHooks.php
@@ -322,19 +322,32 @@
323323 *
324324 * @todo Add support for PostgreSQL and SQLite databases.
325325 */
326 - static function ExtensionSchemaUpdates() {
327 - global $wgDBtype, $wgExtNewFields, $wgExtPGNewFields, $wgExtNewIndexes, $wgExtNewTables;
328 -
 326+ static function ExtensionSchemaUpdates( $updater = null ) {
329327 $dir = dirname( __FILE__ ) . '/';
330328
331 - if ( $wgDBtype == 'mysql' ) {
332 - $wgExtNewTables[] = array( "wikilog_wikilogs", "{$dir}wikilog-tables.sql" );
333 - $wgExtNewIndexes[] = array( "wikilog_comments", "wlc_timestamp", "{$dir}archives/patch-comments-indexes.sql" );
 329+ if ( $updater === null ) {
 330+ global $wgDBtype, $wgExtNewIndexes, $wgExtNewTables;
 331+ if ( $wgDBtype == 'mysql' ) {
 332+ $wgExtNewTables[] = array( "wikilog_wikilogs", "{$dir}wikilog-tables.sql" );
 333+ $wgExtNewIndexes[] = array( "wikilog_comments", "wlc_timestamp", "{$dir}archives/patch-comments-indexes.sql" );
 334+ } else {
 335+ // TODO: PostgreSQL, SQLite, etc...
 336+ print "\n" .
 337+ "Warning: There are no table structures for the Wikilog\n" .
 338+ "extension other than for MySQL at this moment.\n\n";
 339+ }
334340 } else {
335 - // TODO: PostgreSQL, SQLite, etc...
336 - print "\n" .
337 - "Warning: There are no table structures for the Wikilog\n" .
338 - "extension other than for MySQL at this moment.\n\n";
 341+ if ( $updater->getDB()->getType() == 'mysql' ) {
 342+ $updater->addExtensionUpdate( array( 'addTable', "wikilog_wikilogs",
 343+ "{$dir}wikilog-tables.sql", true ) );
 344+ $updater->addExtensionUpdate( array( 'addIndex', "wikilog_comments",
 345+ "wlc_timestamp", "{$dir}archives/patch-comments-indexes.sql", true ) );
 346+ } else {
 347+ // TODO: PostgreSQL, SQLite, etc...
 348+ print "\n" .
 349+ "Warning: There are no table structures for the Wikilog\n" .
 350+ "extension other than for MySQL at this moment.\n\n";
 351+ }
339352 }
340353 return true;
341354 }

Comments

#Comment by Juliano (talk | contribs)   16:44, 11 February 2011

Thanks, but what is the documentation of this new parameter? Manual:Hooks/LoadExtensionSchemaUpdates says nothing.

#Comment by 😂 (talk | contribs)   20:40, 11 February 2011

$updater is a subclass of DatabaseUpdater.

Status & tagging log