jenkins-bot has submitted this change and it was merged.
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.
We only recently started using core to generate this list 2 weeks ago
and since then we've hit various bugs so it's obviously not in a usable
state. As a result we should revert back to the tried and tested way of
2 years of generating 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, 16 insertions(+), 10 deletions(-)
Approvals:
Kaldari: Looks good to me, approved
jenkins-bot: Verified
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..845ff05 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,20 @@
}
/**
+ * Rewrites the language list so that it cannot be contaminated by
other extensions with things other than languages
+ * See bug 57094.
+ * @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: merged
Gerrit-Change-Id: I09a870aa8e2a8b9be8c45b54d5c646ae5b105cf9
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>
Gerrit-Reviewer: Bartosz DziewoĆski <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: Kaldari <[email protected]>
Gerrit-Reviewer: Parent5446 <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits