From: Kunal Mehta Date: Tue, 12 May 2015 16:26:24 +0000 (-0700) Subject: registration: Don't ignore empty array config settings when converting X-Git-Tag: 1.31.0-rc.0~11339^2 X-Git-Url: http://git.cyclocoop.org/%28?a=commitdiff_plain;h=e66864878a19c007ecc8be2bb3089da870f2933f;p=lhc%2Fweb%2Fwiklou.git registration: Don't ignore empty array config settings when converting Remember which settings we set to an empty array and then only skip those settings. The weird variable name "$__settings" is used to avoid any conflicts similar to what eval.php does. Bug: T98739 Change-Id: Iefbf8a98fd433cfbe0087aca6821d90c2786b0cb --- diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php index 06370e92de..e978ae24b1 100644 --- a/maintenance/convertExtensionToRegistration.php +++ b/maintenance/convertExtensionToRegistration.php @@ -61,7 +61,10 @@ class ConvertExtensionToRegistration extends Maintenance { public function execute() { // Extensions will do stuff like $wgResourceModules += array(...) which is a // fatal unless an array is already set. So set an empty value. - foreach ( array_merge( $this->getAllGlobals(), array_keys( $this->custom ) ) as $var ) { + // And use the weird $__settings name to avoid any conflicts + // with real poorly named settings. + $__settings = array_merge( $this->getAllGlobals(), array_keys( $this->custom ) ); + foreach ( $__settings as $var ) { $var = 'wg' . $var; $$var = array(); } @@ -70,15 +73,18 @@ class ConvertExtensionToRegistration extends Maintenance { // Try not to create any local variables before this line $vars = get_defined_vars(); unset( $vars['this'] ); + unset( $vars['__settings'] ); $this->dir = dirname( realpath( $this->getArg( 0 ) ) ); $this->json = array(); $globalSettings = $this->getAllGlobals(); foreach ( $vars as $name => $value ) { - // If an empty array, assume it's the default we set, so skip it - if ( is_array( $value ) && count( $value ) === 0 ) { + $realName = substr( $name, 2 ); // Strip 'wg' + + // If it's an empty array that we likely set, skip it + if ( is_array( $value ) && count( $value ) === 0 && in_array( $realName, $__settings ) ) { continue; } - $realName = substr( $name, 2 ); // Strip 'wg' + if ( isset( $this->custom[$realName] ) ) { call_user_func_array( array( $this, $this->custom[$realName] ), array( $realName, $value, $vars ) ); } elseif ( in_array( $realName, $globalSettings ) ) {