registration: Ignore attributes that start with @
authorKunal Mehta <legoktm@gmail.com>
Tue, 13 Jan 2015 19:46:53 +0000 (11:46 -0800)
committerKunal Mehta <legoktm@gmail.com>
Tue, 13 Jan 2015 19:49:09 +0000 (11:49 -0800)
Allow these to be used for fake comments or other information
that should not be loaded.

Change-Id: Id79cd8b18988b94db565b2ddbc31ee6f17a89fca

includes/registration/ExtensionProcessor.php
tests/phpunit/includes/registration/ExtensionProcessorTest.php

index 45bea64..14fc532 100644 (file)
@@ -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 );
                        }
                }
index 221c258..e57c2b3 100644 (file)
@@ -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