Wizardist has submitted this change and it was merged.

Change subject: Broken tabs at target NS if key == NS_name
......................................................................


Broken tabs at target NS if key == NS_name

If the tab key in $wgNamespaceRelations was equal to the extra
namespace, it would lead to assigning wrong keys into
pre-$navigation array and thus rewriting some tabs.

Change-Id: I9fe57285559b9b256c47d95dcc43ec24baec05d9
---
M NamespaceRelations_body.php
1 file changed, 24 insertions(+), 23 deletions(-)

Approvals:
  Wizardist: Verified; Looks good to me, approved



diff --git a/NamespaceRelations_body.php b/NamespaceRelations_body.php
index 0ee0615..4388b02 100644
--- a/NamespaceRelations_body.php
+++ b/NamespaceRelations_body.php
@@ -11,24 +11,28 @@
 
        /**
         * Processed $wgNamespaceRelations configuration
+        *
         * @var array
         */
        private $_namespaces;
 
        /**
         * References to $this->_namespaces per target
+        *
         * @var array
         */
        private $_namespacesToTarget;
 
        /**
         * References to $this->_namespaces per allowed namespace
+        *
         * @var array
         */
        private $_namespacesToNamespace;
 
        /**
         * Per-namespace array of patterns to match against the title
+        *
         * @var array
         */
        private $_namespacesSubjectPattern;
@@ -38,16 +42,16 @@
 
                $this->_namespaces = array();
                if ( !empty( $wgNamespaceRelations ) ) {
-                       $sortingWeight = self::STARTING_WEIGHT;
                        foreach ( $wgNamespaceRelations as $key => $data ) {
-                               $this->setNamespace( $key, null, array(
-                                       'message'    => 'nstab-extra-' . $key,
-                                       'namespace'  => $data['namespace'],
-                                       'target'     => $data['target'],
-                                       'inMainPage' => isset( 
$data['inMainPage'] ) ? $data['inMainPage'] : false,
-                                       'query'      => isset( $data['query'] ) 
? $data['query'] : '',
-                                       'hideTalk'   => isset( 
$data['hideTalk'] ) ? $data['hideTalk'] : false
-                               ) );
+                               $this->setNamespace( $key, null,
+                                       array(
+                                            'message'    => 'nstab-extra-' . 
$key,
+                                            'namespace'  => $data['namespace'],
+                                            'target'     => $data['target'],
+                                            'inMainPage' => isset( 
$data['inMainPage'] ) ? $data['inMainPage'] : false,
+                                            'query'      => isset( 
$data['query'] ) ? $data['query'] : '',
+                                            'hideTalk'   => isset( 
$data['hideTalk'] ) ? $data['hideTalk'] : false
+                                       ) );
                                if ( !isset( $data['weight'] ) ) {
                                        $this->setNamespace( $key, 'weight', 
$this->generateWeight() );
                                } else {
@@ -125,8 +129,7 @@
                                if ( $title->equals( $tabOptions['title'] ) ) {
                                        $tabOptions['isActive'] = true;
                                }
-                               $tabs[$key] = $this->makeTab( 
$this->getNamespace( $key, 'target' ),
-                                       $this->getCustomTargetTitle( $key, 
$rootText, true ), $tabOptions );
+                               $tabs[$key] = $this->makeTab( 
$this->getNamespace( $key, 'target' ), $this->getCustomTargetTitle( $key, 
$rootText, true ), $tabOptions );
                                unset( $tabOptions );
                        }
                } elseif ( array_key_exists( $subjectNS, 
$this->_namespacesToTarget ) ) { // in additional NS
@@ -163,15 +166,11 @@
                                if ( $title->equals( $tabOptions['title'] ) ) {
                                        $tabOptions['isActive'] = true;
                                }
-                               $tabs[$key] = $this->makeTab( 
$this->getNamespace( $key, 'target' ),
-                                       $this->getCustomTargetTitle( $key, 
$rootText, true ), $tabOptions );
+                               $tabs[$key] = $this->makeTab( 
$this->getNamespace( $key, 'target' ), $this->getCustomTargetTitle( $key, 
$rootText, true ), $tabOptions );
                                unset( $tabOptions );
 
                                if ( isset( $tabs['talk'] ) ) {
-                                       if ( ( 
$tabs['subject']['title']->isMainPage()
-                                               && $this->getNamespace( $key, 
'inMainPage' )
-                                               && $this->getNamespace( $key, 
'hideTalk' ) )
-                                               || $this->getNamespace( $key, 
'hideTalk' )
+                                       if ( ( 
$tabs['subject']['title']->isMainPage() && $this->getNamespace( $key, 
'inMainPage' ) && $this->getNamespace( $key, 'hideTalk' ) ) || 
$this->getNamespace( $key, 'hideTalk' )
                                        ) {
                                                unset( $tabs['talk'] );
                                        }
@@ -183,7 +182,9 @@
 
                $this->sortNavigation( $tabs ); // sort the tabs according to 
their weights
                $navigation = array(); // rebuild the navigation
-               list( $subjectTabId, $talkTabId ) = $this->getDefaultTabsIDs( 
$title ); // get Subject&Talk IDs
+
+               // get Subject&Talk IDs
+               list( $subjectTabId, $talkTabId ) = $this->getDefaultTabsIDs( 
$tabs['subject']['title'] );
                foreach ( $tabs as $key => $definition ) {
                        $tabId = $key;
                        // assign real IDs to default $navigation members
@@ -192,10 +193,7 @@
                        } elseif ( $key === 'talk' ) {
                                $tabId = $talkTabId;
                        }
-                       $navigation[$tabId] = $skinTemplate->tabAction(
-                               $definition['title'], $definition['messages'], 
$definition['isActive'], $definition['query'],
-                               $definition['checkExists']
-                       );
+                       $navigation[$tabId] = $skinTemplate->tabAction( 
$definition['title'], $definition['messages'], $definition['isActive'], 
$definition['query'], $definition['checkExists'] );
                        // for subject/talk it's essential, otherwise MediaWiki 
will just ignore it
                        $navigation[$tabId]['context'] = $key;
                }
@@ -369,7 +367,10 @@
                        $talkId = $subjectId . '_talk';
                }
 
-               return array( $subjectId, $talkId );
+               return array(
+                       $subjectId,
+                       $talkId
+               );
        }
 
        /**

-- 
To view, visit https://gerrit.wikimedia.org/r/66333
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I9fe57285559b9b256c47d95dcc43ec24baec05d9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/NamespaceRelations
Gerrit-Branch: master
Gerrit-Owner: Wizardist <p.selits...@gmail.com>
Gerrit-Reviewer: Wizardist <p.selits...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to