Allow extensions which are using "$eg" or any other prefix to migrate.
Extensions can override the default of "wg" by setting a magic "_prefix"
key in the "config" object.
Note that the migration helper script will not be able to automatically
migrate custom-prefixed configuration settings.
Bug: T97186
Change-Id: I79203cd5e3a2405b92ad01da869de3bd3d359d19
"config": {
"type": "object",
"description": "Configuration options for this extension",
+ "properties": {
+ "_prefix": {
+ "type": "string",
+ "default": "wg",
+ "description": "Prefix to put in front of configuration settings when exporting them to $GLOBALS"
+ }
+ },
"patternProperties": {
"^[a-zA-Z_\u007f-\u00ff][a-zA-Z0-9_\u007f-\u00ff]*$": {
"type": ["object", "array", "string", "integer", "null", "boolean"],
*/
protected function extractConfig( array $info ) {
if ( isset( $info['config'] ) ) {
+ if ( isset( $info['config']['_prefix'] ) ) {
+ $prefix = $info['config']['_prefix'];
+ unset( $info['config']['_prefix'] );
+ } else {
+ $prefix = 'wg';
+ }
foreach ( $info['config'] as $key => $val ) {
if ( $key[0] !== '@' ) {
- $this->globals["wg$key"] = $val;
+ $this->globals["$prefix$key"] = $val;
}
}
}
'@IGNORED' => 'yes',
),
) + self::$default;
+ $info2 = array(
+ 'config' => array(
+ '_prefix' => 'eg',
+ 'Bar' => 'somevalue'
+ ),
+ ) + self::$default;
$processor->extractInfo( $this->dir, $info, 1 );
+ $processor->extractInfo( $this->dir, $info2, 1 );
$extracted = $processor->getExtractedInfo();
$this->assertEquals( 'somevalue', $extracted['globals']['wgBar'] );
$this->assertEquals( 10, $extracted['globals']['wgFoo'] );
$this->assertArrayNotHasKey( 'wg@IGNORED', $extracted['globals'] );
+ // Custom prefix:
+ $this->assertEquals( 'somevalue', $extracted['globals']['egBar'] );
}
public static function provideExtracttExtensionMessagesFiles() {