diff --git a/includes/VisualEditorHooks.php b/includes/VisualEditorHooks.php index 67682a3792..1ff6bba4c7 100644 --- a/includes/VisualEditorHooks.php +++ b/includes/VisualEditorHooks.php @@ -1008,14 +1008,19 @@ class VisualEditorHooks { ); $namespacesWithSubpages = $coreConfig->get( 'NamespacesWithSubpages' ); - // $namespacesWithSubpages is a map of namespace id to boolean value, we want - // to filter out namespaces that don't exist, not need to include those and it - // would increase the JavaScript config size. See T291727 + // Export as a list of namespaces where subpages are enabled instead of an object + // mapping namespaces to if subpages are enabled or not, so filter out disabled + // namespaces and then just use the keys. See T291729. + $namespacesWithSubpages = array_filter( $namespacesWithSubpages ); + $namespacesWithSubpagesEnabled = array_keys( $namespacesWithSubpages ); + // $wgNamespacesWithSubpages can include namespaces that don't exist, no need + // to include those in the JavaScript data. See T291727. + // Run this filtering after the filter for subpages being enabled, to reduce + // the number of calls needed to namespace info. $nsInfo = MediaWikiServices::getInstance()->getNamespaceInfo(); - $namespacesWithSubpages = array_filter( - $namespacesWithSubpages, - [ $nsInfo, 'exists' ], - ARRAY_FILTER_USE_KEY + $namespacesWithSubpagesEnabled = array_filter( + $namespacesWithSubpagesEnabled, + [ $nsInfo, 'exists' ] ); $vars['wgVisualEditorConfig'] = [ 'usePageImages' => $extensionRegistry->isLoaded( 'PageImages' ), @@ -1046,7 +1051,7 @@ class VisualEditorHooks { $veConfig->get( 'VisualEditorEnableWikitextBetaFeature' ) ), 'useChangeTagging' => $veConfig->get( 'VisualEditorUseChangeTagging' ), - 'namespacesWithSubpages' => $namespacesWithSubpages, + 'namespacesWithSubpages' => $namespacesWithSubpagesEnabled, 'specialBooksources' => urldecode( SpecialPage::getTitleFor( 'Booksources' )->getPrefixedURL() ), 'rebaserUrl' => $coreConfig->get( 'VisualEditorRebaserURL' ), 'restbaseUrl' => $coreConfig->get( 'VisualEditorRestbaseURL' ), diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js b/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js index 95888a19fd..e2e3dc0908 100644 --- a/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js +++ b/modules/ve-mw/ui/widgets/ve.ui.MWInternalLinkAnnotationWidget.js @@ -112,7 +112,7 @@ ve.ui.MWInternalLinkAnnotationWidget.prototype.onTextChange = function ( value ) value = targetData.title; this.input.query.setValue( targetData.title ); } - } else if ( namespacesWithSubpages[ basePageObj.namespace ] && value[ 0 ] === '/' ) { + } else if ( namespacesWithSubpages.indexOf( basePageObj.namespace ) !== -1 && value[ 0 ] === '/' ) { // This does make it more-difficult to deliberately link to a page in the // default namespace that starts with a / when you're on a subpage-allowing // namespace. However, the exact same trick you need to know to make it work