diff options
author | jenkins-bot <jenkins-bot@gerrit.wikimedia.org> | 2022-10-06 20:59:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@wikimedia.org> | 2022-10-06 20:59:22 +0000 |
commit | 774b86384d2d1c4d36d997a017a7b55d5255f973 (patch) | |
tree | 56ed9b883518da4f499be4ddb58782fb85949ce0 | |
parent | 78caf43bacfa98a8904d433da24481dea7fbc8d0 (diff) | |
parent | aaf463562b5099c4baed63680e7acbb6ef9b5675 (diff) |
Merge "Skin: Map namespaces to associated pages inside runOnSkinTemplateNavigationHooks" into wmf/1.40.0-wmf.3wmf/1.40.0-wmf.3
-rw-r--r-- | includes/skins/SkinTemplate.php | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/includes/skins/SkinTemplate.php b/includes/skins/SkinTemplate.php index 6827795bb8b3..567fbb1a8bef 100644 --- a/includes/skins/SkinTemplate.php +++ b/includes/skins/SkinTemplate.php @@ -1148,6 +1148,8 @@ class SkinTemplate extends Skin { * @since 1.37 */ protected function runOnSkinTemplateNavigationHooks( SkinTemplate $skin, &$content_navigation ) { + $beforeHookAssociatedPages = array_keys( $content_navigation['associated-pages'] ); + $beforeHookNamespaces = array_keys( $content_navigation['namespaces'] ); $title = $this->getRelevantTitle(); if ( $title->canExist() ) { $this->getHookRunner()->onSkinTemplateNavigation( $skin, $content_navigation ); @@ -1159,6 +1161,21 @@ class SkinTemplate extends Skin { // Equiv to SkinTemplateContentActions, run $this->getHookRunner()->onSkinTemplateNavigation__Universal( $skin, $content_navigation ); + // The new `associatedPages` menu (added in 1.39) + // should be backwards compatibile with `namespaces`. + // To do this we look for hook modifications to both keys. If modifications are not + // made the new key, but are made to the old key, associatedPages reverts back to the + // links in the namespaces menu. + // It's expected in future that `namespaces` menu will become an alias for `associatedPages` + // at which point this code can be removed. + $afterHookNamespaces = array_keys( $content_navigation[ 'namespaces' ] ); + $afterHookAssociatedPages = array_keys( $content_navigation[ 'associated-pages' ] ); + $associatedPagesChanged = count( array_diff( $afterHookAssociatedPages, $beforeHookAssociatedPages ) ) > 0; + $namespacesChanged = count( array_diff( $afterHookNamespaces, $beforeHookNamespaces ) ) > 0; + // If some change occurred to namespaces via the hook, revert back to namespaces. + if ( !$associatedPagesChanged && $namespacesChanged ) { + $content_navigation['associated-pages'] = $content_navigation['namespaces']; + } } /** @@ -1525,26 +1542,8 @@ class SkinTemplate extends Skin { $content_navigation['namespaces'] = $namespaces; $content_navigation['associated-pages'] = $associatedPages; - $beforeHookAssociatedPages = array_keys( $content_navigation['associated-pages'] ); - $beforeHookNamespaces = array_keys( $content_navigation['namespaces'] ); $this->runOnSkinTemplateNavigationHooks( $this, $content_navigation ); - // The new `associatedPages` menu (added in 1.39) - // should be backwards compatibile with `namespaces`. - // To do this we look for hook modifications to both keys. If modifications are not - // made the new key, but are made to the old key, associatedPages reverts back to the - // links in the namespaces menu. - // It's expected in future that `namespaces` menu will become an alias for `associatedPages` - // at which point this code can be removed. - $afterHookNamespaces = array_keys( $content_navigation[ 'namespaces' ] ); - $afterHookAssociatedPages = array_keys( $content_navigation[ 'associated-pages' ] ); - $associatedPagesChanged = count( array_diff( $afterHookAssociatedPages, $beforeHookAssociatedPages ) ) > 0; - $namespacesChanged = count( array_diff( $afterHookNamespaces, $beforeHookNamespaces ) ) > 0; - // If some change occurred to namespaces via the hook, revert back to namespaces. - if ( !$associatedPagesChanged && $namespacesChanged ) { - $content_navigation['associated-pages'] = $content_navigation['namespaces']; - } - // Setup xml ids and tooltip info foreach ( $content_navigation as $section => &$links ) { foreach ( $links as $key => &$link ) { |