X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=maintenance%2FconvertExtensionToRegistration.php;h=4ae95587030b64ae04cba34a93af653b6536175d;hb=3597e03663453c0596c69cb7f36070bade7ec6af;hp=7c87e1012648b30c65dc4c973d3b30fa444670b7;hpb=37ad7b09f50e3d4c03e89981d3068e71fde464ef;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/convertExtensionToRegistration.php b/maintenance/convertExtensionToRegistration.php index 7c87e10126..4ae9558703 100644 --- a/maintenance/convertExtensionToRegistration.php +++ b/maintenance/convertExtensionToRegistration.php @@ -63,10 +63,10 @@ class ConvertExtensionToRegistration extends Maintenance { } protected function getAllGlobals() { - $processor = new ReflectionClass( 'ExtensionProcessor' ); + $processor = new ReflectionClass( ExtensionProcessor::class ); $settings = $processor->getProperty( 'globalSettings' ); $settings->setAccessible( true ); - return $settings->getValue() + $this->formerGlobals; + return array_merge( $settings->getValue(), $this->formerGlobals ); } public function execute() { @@ -82,7 +82,7 @@ class ConvertExtensionToRegistration extends Maintenance { unset( $var ); $arg = $this->getArg( 0 ); if ( !is_file( $arg ) ) { - $this->error( "$arg is not a file.", true ); + $this->fatalError( "$arg is not a file." ); } require $arg; unset( $arg ); @@ -120,7 +120,7 @@ class ConvertExtensionToRegistration extends Maintenance { $this->hasWarning = true; } elseif ( strpos( $name, $configPrefix ) === 0 ) { // Most likely a config setting - $this->json['config'][substr( $name, strlen( $configPrefix ) )] = $value; + $this->json['config'][substr( $name, strlen( $configPrefix ) )] = [ 'value' => $value ]; } elseif ( $configPrefix !== 'wg' && strpos( $name, 'wg' ) === 0 ) { // Warn about this $this->output( 'Warning: Skipped global "' . $name . '" (' . @@ -144,6 +144,11 @@ class ConvertExtensionToRegistration extends Maintenance { unset( $this->json[$key] ); } } + // Set a requirement on the MediaWiki version that the current MANIFEST_VERSION + // was introduced in. + $out['requires'] = [ + ExtensionRegistry::MEDIAWIKI_CORE => ExtensionRegistry::MANIFEST_VERSION_MW_VERSION + ]; $out += $this->json; // Put this at the bottom $out['manifest_version'] = ExtensionRegistry::MANIFEST_VERSION; @@ -160,14 +165,14 @@ class ConvertExtensionToRegistration extends Maintenance { protected function handleExtensionFunctions( $realName, $value ) { foreach ( $value as $func ) { if ( $func instanceof Closure ) { - $this->error( "Error: Closures cannot be converted to JSON. " . - "Please move your extension function somewhere else.", 1 + $this->fatalError( "Error: Closures cannot be converted to JSON. " . + "Please move your extension function somewhere else." ); } // check if $func exists in the global scope if ( function_exists( $func ) ) { - $this->error( "Error: Global functions cannot be converted to JSON. " . - "Please move your extension function ($func) into a class.", 1 + $this->fatalError( "Error: Global functions cannot be converted to JSON. " . + "Please move your extension function ($func) into a class." ); } } @@ -230,16 +235,23 @@ class ConvertExtensionToRegistration extends Maintenance { public function handleHooks( $realName, $value ) { foreach ( $value as $hookName => &$handlers ) { + if ( $hookName === 'UnitTestsList' ) { + $this->output( "Note: the UnitTestsList hook is no longer necessary as " . + "long as your tests are located in the \"tests/phpunit/\" directory. " . + "Please see for more details.\n" + ); + } foreach ( $handlers as $func ) { if ( $func instanceof Closure ) { - $this->error( "Error: Closures cannot be converted to JSON. " . - "Please move the handler for $hookName somewhere else.", 1 + $this->fatalError( "Error: Closures cannot be converted to JSON. " . + "Please move the handler for $hookName somewhere else." ); } // Check if $func exists in the global scope if ( function_exists( $func ) ) { - $this->error( "Error: Global functions cannot be converted to JSON. " . - "Please move the handler for $hookName inside a class.", 1 + $this->fatalError( "Error: Global functions cannot be converted to JSON. " . + "Please move the handler for $hookName inside a class." ); } } @@ -296,5 +308,5 @@ class ConvertExtensionToRegistration extends Maintenance { } } -$maintClass = 'ConvertExtensionToRegistration'; +$maintClass = ConvertExtensionToRegistration::class; require_once RUN_MAINTENANCE_IF_MAIN;