mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 06:24:08 +00:00
Don't include null
in the namespaces where VE can be enabled
Bug: T291728 Change-Id: I2cb168a21c559e61bf2c9e881d46f7f23110e826
This commit is contained in:
parent
abd115c054
commit
492fcfbd9f
|
@ -626,7 +626,7 @@ class ApiVisualEditor extends ApiBase {
|
|||
// Note: existing numeric keys might exist, and so array_merge cannot be used
|
||||
(array)$config->get( 'VisualEditorAvailableNamespaces' ) +
|
||||
(array)ExtensionRegistry::getInstance()->getAttribute( 'VisualEditorAvailableNamespaces' );
|
||||
return array_values( array_unique( array_map( static function ( $namespace ) {
|
||||
$namespaceIds = array_values( array_unique( array_map( static function ( $namespace ) {
|
||||
// Convert canonical namespace names to IDs
|
||||
$nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo();
|
||||
$idFromName = $nsInfo->getCanonicalIndex( strtolower( $namespace ) );
|
||||
|
@ -636,6 +636,8 @@ class ApiVisualEditor extends ApiBase {
|
|||
// Allow namespaces to be specified by ID as well
|
||||
return $nsInfo->exists( $namespace ) ? $namespace : null;
|
||||
}, array_keys( array_filter( $availableNamespaces ) ) ) ) );
|
||||
// Remove `null` if there were any namespaces that didn't exist, T291728
|
||||
return array_values( array_diff( $namespaceIds, [ null ] ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,7 +48,7 @@ class ApiVisualEditorTest extends MediaWikiIntegrationTestCase {
|
|||
'Foobar' => true,
|
||||
] ] );
|
||||
$this->assertSame(
|
||||
[ 0, -1, null, 10, 11 ],
|
||||
[ 0, -1, 10, 11 ],
|
||||
ApiVisualEditor::getAvailableNamespaceIds( $config )
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue