r89660 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89659‎ | r89660 | r89661 >
Date:17:33, 7 June 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
Get rid of addNewExtension()/getNewExtensions() method of adding new extensions (added in r81266). Since r85021, this isn't necessary because we run old updates like we should. Fix the 3 extensions using it. Reverts most of r81266, all of r84868, tiny part of r86741. Also ping r89653 which is what caused me to look at this again.
Modified paths:
  • /trunk/extensions/CodeReview/CodeReview.php (modified) (history)
  • /trunk/extensions/ConfirmAccount/ConfirmAccount.php (modified) (history)
  • /trunk/extensions/Math/Math.hooks.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -31,12 +31,6 @@
3232 protected $extensionUpdates = array();
3333
3434 /**
35 - * Used to hold schema files during installation process
36 - * @var array
37 - */
38 - protected $newExtensions = array();
39 -
40 - /**
4135 * Handle to the database subclass
4236 *
4337 * @var DatabaseBase
@@ -177,23 +171,6 @@
178172 }
179173
180174 /**
181 - * Add a brand new extension to MediaWiki. Used during the initial install
182 - * @param $ext String Name of extension
183 - * @param $sqlPath String Full path to the schema file
184 - */
185 - public function addNewExtension( $ext, $sqlPath ) {
186 - $this->newExtensions[ strtolower( $ext ) ] = $sqlPath;
187 - }
188 -
189 - /**
190 - * Get the list of extensions that registered a schema with our DB type
191 - * @return array
192 - */
193 - public function getNewExtensions() {
194 - return $this->newExtensions;
195 - }
196 -
197 - /**
198175 * Get the list of extension-defined updates
199176 *
200177 * @return Array
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -183,26 +183,9 @@
184184 if ( !$status->isOK() ) {
185185 return $status;
186186 }
187 - $updater = DatabaseUpdater::newForDB( $this->db );
188 - $extensionUpdates = $updater->getNewExtensions();
189187
190 - $ourExtensions = array_map( 'strtolower', $this->getVar( '_Extensions' ) );
191 -
192 - foreach( $ourExtensions as $ext ) {
193 - if( isset( $extensionUpdates[$ext] ) ) {
194 - $this->db->begin( __METHOD__ );
195 - $error = $this->db->sourceFile( $extensionUpdates[$ext] );
196 - if( $error !== true ) {
197 - $this->db->rollback( __METHOD__ );
198 - $status->warning( 'config-install-tables-failed', $error );
199 - } else {
200 - $this->db->commit( __METHOD__ );
201 - }
202 - }
203 - }
204 -
205188 // Now run updates to create tables for old extensions
206 - $updater->doUpdates( array( 'extensions' ) );
 189+ DatabaseUpdater::newForDB( $this->db )->doUpdates( array( 'extensions' ) );
207190
208191 return $status;
209192 }
Index: trunk/extensions/Math/Math.hooks.php
@@ -104,7 +104,10 @@
105105 * @param $updater DatabaseUpdater
106106 * @return bool
107107 */
108 - static function onLoadExtensionSchemaUpdates( $updater ) {
 108+ static function onLoadExtensionSchemaUpdates( $updater = null ) {
 109+ if( is_null( $updater ) ) {
 110+ throw new MWException( "Math extension is only necessary in 1.18 or above" );
 111+ }
109112 $map = array(
110113 'mysql' => 'math.sql',
111114 'sqlite' => 'math.sql',
@@ -115,10 +118,8 @@
116119 );
117120 $base = dirname( __FILE__ );
118121 $type = $updater->getDB()->getType();
119 - if ( array_key_exists( $type, $map ) ) {
120 - $file = $map[$type];
121 - $sql = "$base/db/$file";
122 - $updater->addNewExtension( 'CodeReview', $sql );
 122+ if ( isset( $map[$type] ) ) {
 123+ $sql = dirname( __FILE__ ) . '/db/' . $map[$type];
123124 $updater->addExtensionTable( 'math', $sql );
124125 } else {
125126 throw new MWException( "Math extension does not currently support $type database." );
Index: trunk/extensions/CodeReview/CodeReview.php
@@ -241,7 +241,6 @@
242242 $base = dirname( __FILE__ );
243243 switch ( $updater->getDB()->getType() ) {
244244 case 'mysql':
245 - $updater->addNewExtension( 'CodeReview', "$base/codereview.sql" );
246245 $updater->addExtensionUpdate( array( 'addTable', 'code_rev',
247246 "$base/codereview.sql", true ) ); // Initial install tables
248247 $updater->addExtensionUpdate( array( 'addField', 'code_rev', 'cr_diff',
@@ -283,7 +282,6 @@
284283 "$base/archives/codereview-repopath.sql", true ) );
285284 break;
286285 case 'sqlite':
287 - $updater->addNewExtension( 'CodeReview', "$base/codereview.sql" );
288286 $updater->addExtensionUpdate( array( 'addTable', 'code_rev', "$base/codereview.sql", true ) );
289287 $updater->addExtensionUpdate( array( 'addTable', 'code_signoffs', "$base/archives/code_signoffs.sql", true ) );
290288 $updater->addExtensionUpdate( array( 'addField', 'code_signoffs', 'cs_user',
Index: trunk/extensions/ConfirmAccount/ConfirmAccount.php
@@ -274,7 +274,7 @@
275275 }
276276 } else {
277277 if ( $updater->getDB()->getType() == 'mysql' ) {
278 - $updater->addNewExtension( 'ConfirmAccount', "$base/ConfirmAccount.sql" );
 278+ $updater->addExtensionUpdate( array( 'addTable', 'account_requests', "$base/ConfirmAccount.sql", true ) );
279279
280280 $updater->addExtensionUpdate( array( 'addField', 'account_requests', 'acr_filename',
281281 "$base/archives/patch-acr_filename.sql", true ) );
@@ -285,7 +285,7 @@
286286
287287 $updater->addExtensionUpdate( array( 'addIndex', 'account_requests', 'acr_email', "$base/archives/patch-email-index.sql", true ) );
288288 } else if ( $updater->getDB()->getType() == 'postgres' ) {
289 - $updater->addNewExtension( 'ConfirmAccount', "$base/ConfirmAccount.pg.sql" );
 289+ $updater->addExtensionUpdate( array( 'addTable', 'account_requests', "$base/ConfirmAccount.pg.sql", true ) );
290290
291291 $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_held', "TIMESTAMPTZ" ) );
292292 $updater->addExtensionUpdate( array( 'addPgField', 'account_requests', 'acr_filename', "TEXT" ) );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r81266(bug 26857) Fatal error during installation enabling 'Vector' extension (or a...demon20:00, 31 January 2011
r84868Use $updater->addNewExtensionreedy18:17, 27 March 2011
r85021(bug 28237) Installer doesn't create extension tablesmaxsem17:32, 30 March 2011
r86741Breaking the 'math' table setup out to Math extension. Should be the last mai...brion21:37, 22 April 2011
r89653Fix r85021: extension tables weren't created in some casesmaxsem15:52, 7 June 2011

Comments

#Comment by Hashar (talk | contribs)   18:31, 7 June 2011

looks like the whole stuff need a backport to 1.18 isn't it?

#Comment by 😂 (talk | contribs)   18:32, 7 June 2011

And 1.17, if it'll go cleanly.

#Comment by Tim Starling (talk | contribs)   00:09, 22 June 2011

It's too late for 1.17.

#Comment by 😂 (talk | contribs)   00:12, 22 June 2011

Yeah that's fine, removed the tag.

Status & tagging log