From: Kunal Mehta Date: Tue, 13 Jan 2015 19:46:53 +0000 (-0800) Subject: registration: Ignore attributes that start with @ X-Git-Tag: 1.31.0-rc.0~12623^2 X-Git-Url: https://git.cyclocoop.org/%7B%24admin_url%7Dmembres/cotisations/rappels.php?a=commitdiff_plain;h=896b9b5c6559654b3f7fa7d7ce2d6b0fe36bbd14;p=lhc%2Fweb%2Fwiklou.git 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 --- 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