Bug: Append to wgAutoloadClasses
authorErik Bernhardson <ebernhardson@wikimedia.org>
Wed, 19 Nov 2014 06:23:31 +0000 (22:23 -0800)
committerEBernhardson <ebernhardson@wikimedia.org>
Wed, 19 Nov 2014 06:33:51 +0000 (06:33 +0000)
When generating $wgAutoloadClasses for an extension the generator
currently outputs an assignment (=), but it is unlikely this is
the desired result. An extension wants to append to the existing
$wgAutoloadClasses. This bug is an unintended consequence of I75403ace
which changed the generator from assigning one key per line to using
an array literal.

This patch changes the output only when generating $wgAutoloadClasses
to the += operator which adds to the array any value that is not
already in the array.

Change-Id: I7d42ee5dc829991c6562878f0c90a06fadb1b6a6

includes/utils/AutoloadGenerator.php

index 8952947..98efd27 100644 (file)
@@ -150,6 +150,14 @@ class AutoloadGenerator {
                // sort for stable output
                ksort( $content );
 
+               // extensions using this generator are appending to the existing
+               // autoload.
+               if ( $this->variableName === 'wgAutoloadClasses' ) {
+                       $op = '+=';
+               } else {
+                       $op = '=';
+               }
+
                $output = implode( "\n\t", $content );
                file_put_contents(
                        $this->basepath . '/autoload.php',
@@ -159,7 +167,7 @@ class AutoloadGenerator {
 
 global \${$this->variableName};
 
-\${$this->variableName} = array(
+\${$this->variableName} {$op} array(
        {$output}
 );