jenkins-bot has submitted this change and it was merged.

Change subject: Read extension.json files in the web updater
......................................................................


Read extension.json files in the web updater

The web updater reads LocalSettings.php in function scope to figure out
what extensions have been loaded. This doesn't work for extensions being
loaded through the ExtensionRegistry since they're only added to a
queue.

This adds the ability for the installer to read and get information from
the current extension load queue. LocalSettings.php is still read for
extensions that have not been converted yet.

Other uses of Installer::getExistingLocalSettings() were audited and
determined to be safe with regards to extension usage.

Extensions that register hooks using explicit globals
($GLOBALS['wgHooks']['FooBar']) are still broken.

Bug: T100414
Change-Id: Icc574a38a7947a1e3aff8622a4889e9dcfd7a4b2
(cherry picked from commit 648ef0d8687ce3efc404225263aa10ca45c244a5)
---
M includes/installer/DatabaseUpdater.php
M includes/registration/ExtensionRegistry.php
2 files changed, 35 insertions(+), 6 deletions(-)

Approvals:
  Legoktm: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/includes/installer/DatabaseUpdater.php 
b/includes/installer/DatabaseUpdater.php
index 702f850..7070790 100644
--- a/includes/installer/DatabaseUpdater.php
+++ b/includes/installer/DatabaseUpdater.php
@@ -145,15 +145,26 @@
                        return; // already loaded
                }
                $vars = Installer::getExistingLocalSettings();
-               if ( !$vars ) {
-                       return; // no LocalSettings found
+
+               $registry = ExtensionRegistry::getInstance();
+               $queue = $registry->getQueue();
+               // Don't accidentally load extensions in the future
+               $registry->clearQueue();
+
+               // This will automatically add "AutoloadClasses" to 
$wgAutoloadClasses
+               $data = $registry->readFromQueue( $queue );
+               $hooks = array( 'wgHooks' => array( 
'LoadExtensionSchemaUpdates' => array() ) );
+               if ( isset( 
$data['globals']['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
+                       $hooks = 
$data['globals']['wgHooks']['LoadExtensionSchemaUpdates'];
                }
-               if ( !isset( $vars['wgHooks'] ) || !isset( 
$vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
-                       return;
+               if ( $vars && isset( 
$vars['wgHooks']['LoadExtensionSchemaUpdates'] ) ) {
+                       $hooks = array_merge_recursive( $hooks, 
$vars['wgHooks']['LoadExtensionSchemaUpdates'] );
                }
                global $wgHooks, $wgAutoloadClasses;
-               $wgHooks['LoadExtensionSchemaUpdates'] = 
$vars['wgHooks']['LoadExtensionSchemaUpdates'];
-               $wgAutoloadClasses = $wgAutoloadClasses + 
$vars['wgAutoloadClasses'];
+               $wgHooks['LoadExtensionSchemaUpdates'] = $hooks;
+               if ( $vars && isset( $vars['wgAutoloadClasses'] ) ) {
+                       $wgAutoloadClasses += $vars['wgAutoloadClasses'];
+               }
        }
 
        /**
diff --git a/includes/registration/ExtensionRegistry.php 
b/includes/registration/ExtensionRegistry.php
index 0cdb2c1..4e690aa 100644
--- a/includes/registration/ExtensionRegistry.php
+++ b/includes/registration/ExtensionRegistry.php
@@ -109,6 +109,24 @@
        }
 
        /**
+        * Get the current load queue. Not intended to be used
+        * outside of the installer.
+        *
+        * @return array
+        */
+       public function getQueue() {
+               return $this->queued;
+       }
+
+       /**
+        * Clear the current load queue. Not intended to be used
+        * outside of the installer.
+        */
+       public function clearQueue() {
+               $this->queued = array();
+       }
+
+       /**
         * Process a queue of extensions and return their extracted data
         *
         * @param array $queue keys are filenames, values are ignored

-- 
To view, visit https://gerrit.wikimedia.org/r/227240
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Icc574a38a7947a1e3aff8622a4889e9dcfd7a4b2
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_25
Gerrit-Owner: Paladox <thomasmulhall...@yahoo.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipe...@gmail.com>
Gerrit-Reviewer: MarkAHershberger <m...@nichework.com>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to