jenkins-bot has submitted this change and it was merged.
Change subject: registration: Prevent loading the same thing twice
......................................................................
registration: Prevent loading the same thing twice
Normally the registry load queue should filter out duplicates, but if
people do weird things with symlinks, throw a useful error message if
the double-loading makes it all the way to the processor.
Bug: T121493
Change-Id: I47f5cd754e5f3c91e6b83a6d0ab542404347a421
---
M includes/registration/ExtensionProcessor.php
M tests/phpunit/includes/registration/ExtensionProcessorTest.php
2 files changed, 28 insertions(+), 2 deletions(-)
Approvals:
Alex Monk: Looks good to me, approved
jenkins-bot: Verified
diff --git a/includes/registration/ExtensionProcessor.php
b/includes/registration/ExtensionProcessor.php
index cab889f..074a962 100644
--- a/includes/registration/ExtensionProcessor.php
+++ b/includes/registration/ExtensionProcessor.php
@@ -294,6 +294,11 @@
}
}
+ /**
+ * @param string $path
+ * @param array $info
+ * @throws Exception
+ */
protected function extractCredits( $path, array $info ) {
$credits = array(
'path' => $path,
@@ -305,7 +310,17 @@
}
}
- $this->credits[$credits['name']] = $credits;
+ $name = $credits['name'];
+
+ // If someone is loading the same thing twice, throw
+ // a nice error (T121493)
+ if ( isset( $this->credits[$name] ) ) {
+ $firstPath = $this->credits[$name]['path'];
+ $secondPath = $credits['path'];
+ throw new Exception( "It was attempted to load $name
twice, from $firstPath and $secondPath." );
+ }
+
+ $this->credits[$name] = $credits;
}
/**
diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
index 843f576..590644f 100644
--- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php
+++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php
@@ -118,7 +118,8 @@
'_prefix' => 'eg',
'Bar' => 'somevalue'
),
- ) + self::$default;
+ 'name' => 'FooBar2',
+ );
$processor->extractInfo( $this->dir, $info, 1 );
$processor->extractInfo( $this->dir, $info2, 1 );
$extracted = $processor->getExtractedInfo();
@@ -194,6 +195,16 @@
}
/**
+ * @covers ExtensionProcessor::extractCredits
+ */
+ public function testExtractCredits() {
+ $processor = new ExtensionProcessor();
+ $processor->extractInfo( $this->dir, self::$default, 1 );
+ $this->setExpectedException( 'Exception' );
+ $processor->extractInfo( $this->dir, self::$default, 1 );
+ }
+
+ /**
* @covers ExtensionProcessor::extractResourceLoaderModules
* @dataProvider provideExtractResourceLoaderModules
*/
--
To view, visit https://gerrit.wikimedia.org/r/261608
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I47f5cd754e5f3c91e6b83a6d0ab542404347a421
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Legoktm <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Paladox <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
Gerrit-Reviewer: saper <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits