r92432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92431‎ | r92432 | r92433 >
Date:14:46, 18 July 2011
Author:reedy
Status:deferred
Tags:
Comment:
* (bug 29948) Extension AdvancedMeta should create needed data base table automatically

Made format a little more common with other MW extensions
Modified paths:
  • /trunk/extensions/AdvancedMeta/AdvancedMeta.php (modified) (history)
  • /trunk/extensions/AdvancedMeta/AdvancedMeta.sql (modified) (history)

Diff [purge]

Index: trunk/extensions/AdvancedMeta/AdvancedMeta.php
@@ -1,5 +1,7 @@
22 <?php
33
 4+if ( !defined( 'MEDIAWIKI' ) ) die( 'This is an extension to the MediaWiki software and cannot be used standalone.' );
 5+
46 /**
57 * MediaWiki Advanced Meta extension
68 * Add meta data to individual pages or entire namespaces
@@ -21,6 +23,21 @@
2224 $wgExtensionMessagesFiles['MWAdvancedMeta'] = dirname( __FILE__ ) . '/MWAdvancedMeta.i18n.php';
2325 MWAdvancedMeta::setup();
2426
 27+$wgHooks['LoadExtensionSchemaUpdates'][] = 'efAdvancedMetaSchemaUpdates';
 28+
 29+/**
 30+ * @param $updater DatabaseUpdater
 31+ * @return bool
 32+ */
 33+function efAdvancedMetaSchemaUpdates( $updater ) {
 34+ $base = dirname( __FILE__ );
 35+ switch ( $updater->getDB()->getType() ) {
 36+ case 'mysql':
 37+ $updater->addExtensionUpdate( array( 'addTable', 'ext_meta',
 38+ "$base/AdvancedMeta.sql", true ) ); // Initial install tables
 39+ }
 40+}
 41+
2542 class MWAdvancedMeta {
2643
2744 private static $instance = null;
@@ -30,18 +47,11 @@
3148 * @return MWAdvancedMeta the plugin object, which you can use to set settings.
3249 */
3350 public static function setup() {
34 -
35 - // check for wiki
36 - if ( !defined( 'MEDIAWIKI' ) ) {
37 - throw new Exception( 'This is an extension to the MediaWiki software and cannot be used standalone.' );
38 - }
39 -
4051 // create plugin
4152 if ( self::$instance === null ) {
4253 self::$instance = new self();
4354 }
4455 return self::$instance;
45 -
4656 }
4757
4858 private $indexedPages = array( NS_MAIN, NS_PROJECT );
Index: trunk/extensions/AdvancedMeta/AdvancedMeta.sql
@@ -1,4 +1,4 @@
2 -CREATE TABLE /*_*/dbprefix_ext_meta (
 2+CREATE TABLE /*_*/ext_meta (
33 `pageid` INT(8) NOT NULL,
44 `rindex` tinyint(1) NOT NULL,
55 `rfollow` tinyint(1) NOT NULL,

Status & tagging log