r89481 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89480‎ | r89481 | r89482 >
Date:21:56, 4 June 2011
Author:maxsem
Status:ok (Comments)
Tags:
Comment:
Revert r89254:
* It breaks if any extension uses any global except $IP, $wgHooks or $wgAutoloadClasses. Some unit tests that try updating a virtual database are already affected.
* If we have LocalSettings.php, we already have it loaded - are there code paths that don't have it?
* Parsing PHP with regexes is fragile and scary
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseUpdater.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/DatabaseUpdater.php
@@ -73,7 +73,6 @@
7474 }
7575 $this->maintenance->setDB( $db );
7676 $this->initOldGlobals();
77 - $this->initIncludedExtensions();
7877 wfRunHooks( 'LoadExtensionSchemaUpdates', array( $this ) );
7978 }
8079
@@ -96,28 +95,6 @@
9796 }
9897
9998 /**
100 - * Try to include extensions from LocalSettings so their LocalExtensionSchemaChanges hooks can be run
101 - */
102 - private function initIncludedExtensions() {
103 - global $IP, $wgHooks, $wgAutoloadClasses;
104 - $ls = file_get_contents( "$IP/LocalSettings.php" );
105 - if ( $ls === false ) return;
106 - $matches = array();
107 - preg_match_all( '/[[:blank:]]*(?:require|include){1}(?:_once)?[[:blank:]]*\([[:blank:]]*"\$IP\/extensions\/([^\/].*)\/\1\.php"[[:blank:]]*\);[[:blank:]]*/i',
108 - $ls, $matches, PREG_SET_ORDER );
109 - unset( $ls );
110 -
111 - if ( !isset( $wgHooks ) )
112 - $wgHooks = array();
113 - if ( !isset( $wgAutoloadClasses ) )
114 - $wgAutoloadClasses = array();
115 -
116 - foreach ( $matches as $match ) {
117 - include_once ( "$IP/extensions/{$match[1]}/{$match[1]}.php" );
118 - }
119 - }
120 -
121 - /**
12299 * @throws MWException
123100 * @param DatabaseBase $db
124101 * @param bool $shared

Follow-up revisions

RevisionCommit summaryAuthorDate
r89529Follow-up r89254 and r89481: re-did loading extension updates properly, now u...maxsem19:52, 5 June 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r89254* trying to create a way to update/install extension already included in the ...freakolowsky13:43, 1 June 2011

Comments

#Comment by MaxSem (talk | contribs)   22:03, 4 June 2011

Another great way to break stuff I forgot to mention:

/* these extensions are broken -- don't reenable
require_once( "$IP/extensions/BreakYourSite/BreakYourSite.php" );
require_once( "$IP/extensions/WorksOnlyOnMW_1.1/WorksOnlyOnMW_1.1.php" );
*/

Status & tagging log