From 896b9b5c6559654b3f7fa7d7ce2d6b0fe36bbd14 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Tue, 13 Jan 2015 11:46:53 -0800 Subject: [PATCH] registration: Ignore attributes that start with @ Allow these to be used for fake comments or other information that should not be loaded. Change-Id: Id79cd8b18988b94db565b2ddbc31ee6f17a89fca --- includes/registration/ExtensionProcessor.php | 3 ++- .../registration/ExtensionProcessorTest.php | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/includes/registration/ExtensionProcessor.php b/includes/registration/ExtensionProcessor.php index 45bea64b50..14fc532e52 100644 --- a/includes/registration/ExtensionProcessor.php +++ b/includes/registration/ExtensionProcessor.php @@ -129,7 +129,8 @@ class ExtensionProcessor implements Processor { foreach ( $info as $key => $val ) { if ( in_array( $key, self::$globalSettings ) ) { $this->storeToArray( "wg$key", $val, $this->globals ); - } elseif ( !in_array( $key, $this->processed ) ) { + // Ignore anything that starts with a @ + } elseif ( $key[0] !== '@' && !in_array( $key, $this->processed ) ) { $this->storeToArray( $key, $val, $this->attributes ); } } diff --git a/tests/phpunit/includes/registration/ExtensionProcessorTest.php b/tests/phpunit/includes/registration/ExtensionProcessorTest.php index 221c2580c5..e57c2b340a 100644 --- a/tests/phpunit/includes/registration/ExtensionProcessorTest.php +++ b/tests/phpunit/includes/registration/ExtensionProcessorTest.php @@ -18,6 +18,23 @@ class ExtensionProcessorTest extends MediaWikiTestCase { 'name' => 'FooBar', ); + /** + * @covers ExtensionProcessor::extractInfo + */ + public function testExtractInfo() { + // Test that attributes that begin with @ are ignored + $processor = new ExtensionProcessor(); + $processor->extractInfo( $this->dir, self::$default + array( + '@metadata' => array( 'foobarbaz' ), + 'AnAttribute' => array( 'omg' ), + ) ); + + $extracted = $processor->getExtractedInfo(); + $attributes = $extracted['attributes']; + $this->assertArrayHasKey( 'AnAttribute', $attributes ); + $this->assertArrayNotHasKey( '@metadata', $attributes ); + } + public static function provideRegisterHooks() { return array( // No hooks -- 2.20.1