From 24a72730d6368b799cbc6eed10d3c8a257085805 Mon Sep 17 00:00:00 2001 From: Erik Bernhardson Date: Tue, 18 Nov 2014 22:23:31 -0800 Subject: [PATCH] Bug: Append to wgAutoloadClasses 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/includes/utils/AutoloadGenerator.php b/includes/utils/AutoloadGenerator.php index 8952947865..98efd274af 100644 --- a/includes/utils/AutoloadGenerator.php +++ b/includes/utils/AutoloadGenerator.php @@ -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} ); -- 2.20.1