Legoktm has uploaded a new change for review. https://gerrit.wikimedia.org/r/210856
Change subject: [WIP] registration: Allow extensions to specify which MW core versions are supported ...................................................................... [WIP] registration: Allow extensions to specify which MW core versions are supported * Introduces composer/composer as a dependency, pinned to a specific commit * New CoreVersionChecker class provides a wrapper around composer's LinkConstraint classes Still WIP because of some weird issues with being >= an alpha version... Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10 --- M autoload.php M composer.json M includes/registration/ExtensionProcessor.php M includes/registration/ExtensionRegistry.php M includes/registration/Processor.php 5 files changed, 33 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core refs/changes/56/210856/1 diff --git a/autoload.php b/autoload.php index d158481..c9237dd 100644 --- a/autoload.php +++ b/autoload.php @@ -270,6 +270,7 @@ 'CopyJobQueue' => __DIR__ . '/maintenance/copyJobQueue.php', 'CoreParserFunctions' => __DIR__ . '/includes/parser/CoreParserFunctions.php', 'CoreTagHooks' => __DIR__ . '/includes/parser/CoreTagHooks.php', + 'CoreVersionChecker' => __DIR__ . '/includes/registration/CoreVersionChecker.php', 'CreateAndPromote' => __DIR__ . '/maintenance/createAndPromote.php', 'CreateFileOp' => __DIR__ . '/includes/filebackend/FileOp.php', 'CreditsAction' => __DIR__ . '/includes/actions/CreditsAction.php', diff --git a/composer.json b/composer.json index 0789eee..ac28310 100644 --- a/composer.json +++ b/composer.json @@ -16,6 +16,7 @@ "wiki": "https://www.mediawiki.org/" }, "require": { + "composer/composer": "dev-master#bc45d9185513575434021527d7756420e9f4b2cf", "cssjanus/cssjanus": "1.1.1", "ext-iconv": "*", "leafo/lessphp": "0.5.0", diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 23a2993..318e891 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -150,6 +150,15 @@ ); } + public function getConstraints( array $info ) { + $constraints = array(); + if ( isset( $info['supports'] ) ) { + $constraints[ExtensionRegistry::MEDIAWIKI_CORE] = $info['supports']; + } + + return $constraints; + } + protected function extractHooks( array $info ) { if ( isset( $info['Hooks'] ) ) { foreach ( $info['Hooks'] as $name => $value ) { diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index d938f07..0f003bb 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -11,6 +11,8 @@ */ class ExtensionRegistry { + const MEDIAWIKI_CORE = 'MediaWiki'; + /** * @var BagOStuff */ @@ -117,8 +119,10 @@ * @throws Exception */ public function readFromQueue( array $queue ) { + global $wgVersion; $data = array( 'globals' => array( 'wgAutoloadClasses' => array() ) ); $autoloadClasses = array(); + $coreVersionParser = new CoreVersionChecker( $wgVersion ); foreach ( $queue as $path => $mtime ) { $json = file_get_contents( $path ); if ( $json === false ) { @@ -138,6 +142,15 @@ $processor = $this->getProcessor( 'default' ); } $processor->extractInfo( $path, $info ); + $constraints = $processor->getConstraints( $info ); + if ( isset( $constraints[self::MEDIAWIKI_CORE] ) ) { + if ( !$coreVersionParser->check( $constraints[self::MEDIAWIKI_CORE] ) ) { + throw new Exception( + "{$info['name']} is not compatible with the current MediaWiki core (version {$wgVersion}): " + . $constraints[self::MEDIAWIKI_CORE] + ); + } + } } foreach ( $this->processors as $processor ) { $data = array_merge_recursive( $data, $processor->getExtractedInfo() ); diff --git a/includes/registration/Processor.php b/includes/registration/Processor.php index 391f108..a891a49 100644 --- a/includes/registration/Processor.php +++ b/includes/registration/Processor.php @@ -29,4 +29,13 @@ * 'attributes' - registration info which isn't a global variable */ public function getExtractedInfo(); + + /** + * Get the constraints for the provided info + * + * @since 1.26 + * @param array $info + * @return array + */ + public function getConstraints( array $info ); } -- To view, visit https://gerrit.wikimedia.org/r/210856 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7785827216e16c596356d0ae42d6b30f3f179f10 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/core Gerrit-Branch: master Gerrit-Owner: Legoktm <legoktm.wikipe...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits