Jdlrobson has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/99693


Change subject: Override language_urls template data to avoid hook abuse
......................................................................

Override language_urls template data to avoid hook abuse

Various extensions abuse the SkinTemplateOutputPageBeforeExec hook
to append things that are not language urls to this template variable.
Mobile expects these all to be actual languages - not links to edit languages
or other 'phantom' list items.

Let's generate this list ourself after the hook has run to ensure we get what
we need.

Bug: 58102
Bug: 57091
Bug: 57094

Change-Id: I09a870aa8e2a8b9be8c45b54d5c646ae5b105cf9
---
M includes/skins/MinervaTemplate.php
M includes/skins/SkinMinerva.php
2 files changed, 15 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/93/99693/1

diff --git a/includes/skins/MinervaTemplate.php 
b/includes/skins/MinervaTemplate.php
index fcece3b..0e33ef5 100644
--- a/includes/skins/MinervaTemplate.php
+++ b/includes/skins/MinervaTemplate.php
@@ -20,16 +20,7 @@
        }
 
        public function getLanguages() {
-               $langs = array();
-               // FIXME: Hack to workaround bug 57094
-               if ( $this->data['language_urls'] ) {
-                       foreach( $this->data['language_urls'] as $lang ) {
-                               if ( !isset( $lang['id'] ) || $lang['id'] !== 
'wbc-linkToItem' ) {
-                                       $langs[] = $lang;
-                               }
-                       }
-               }
-               return $langs;
+               return $this->data['language_urls'];
        }
 
        public function getDiscoveryTools() {
diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index 7ebb25c..72426da 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -49,6 +49,7 @@
                $this->prepareUserButton( $tpl );
                $this->prepareDiscoveryTools( $tpl );
                $this->preparePersonalTools( $tpl );
+               $this->prepareLanguages( $tpl );
                // FIXME: Remove need for a page-loading class
                $bottomScripts = Html::inlineScript(
                        "document.documentElement.className = 
document.documentElement.className.replace( 'page-loading', '' );"
@@ -223,6 +224,19 @@
        }
 
        /**
+        * Prepares the language list.
+        * @param QuickTemplate
+        */
+       protected function prepareLanguages( $tpl ) {
+               $language_urls = $this->getLanguages();
+               if ( count( $language_urls ) ) {
+                       $tpl->setRef( 'language_urls', $language_urls );
+               } else {
+                       $tpl->set( 'language_urls', false );
+               }
+       }
+
+       /**
         * Prepares a list of links that have the purpose of discovery in the 
main navigation menu
         * @param QuickTemplate
         */

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I09a870aa8e2a8b9be8c45b54d5c646ae5b105cf9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to