[MediaWiki-commits] [Gerrit] mediawiki...MobileFrontend[specialpages]: Hygiene: Remove MobileContext::getConfigVariable

2018-01-11 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/403550 )

Change subject: Hygiene: Remove MobileContext::getConfigVariable
..


Hygiene: Remove MobileContext::getConfigVariable

Going forward we will make use of the FeatureManager for these kinds
of checks.

Given the complexity of the shouldShowWikibaseDescriptions method
I've not (yet) removed it, but have wired it up to the feature
management system.

We should also register features that have been promoted to stable
as if they are ever demoted to beta they will not appear in
Special:MobileOptions

Change-Id: I6aa1c66ec131a8db75d6e6128d4e3af78f351af0
---
M i18n/en.json
M i18n/qqq.json
M includes/MobileContext.php
M includes/MobileFrontend.body.php
M includes/MobileFrontend.hooks.php
M includes/ServiceWiring.php
M tests/phpunit/MobileContextTest.php
M tests/phpunit/context/MobileContextWikibaseDescriptionsTest.php
A tests/phpunit/features/FeaturesManagerTest.php
9 files changed, 118 insertions(+), 152 deletions(-)

Approvals:
  Pmiazga: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/i18n/en.json b/i18n/en.json
index 6f28ee9..ce5af11 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -299,5 +299,13 @@
"mobile-frontend-mobile-option-MFEnableWikidataDescriptions": "Title 
descriptions",

"mobile-frontend-mobile-option-MFEnableWikidataDescriptions-description": 
"Learn about the subject of the article with a short description below the 
title",
"mobile-frontend-mobile-option-MFLazyLoadReferences-description": "Load 
article references only when needed",
-   "mobile-frontend-send-feedback": "Send feedback"
+   "mobile-frontend-send-feedback": "Send feedback",
+   "mobile-frontend-mobile-option-MFLazyLoadImages-description": "Load 
article images only when needed.",
+   "mobile-frontend-mobile-option-MFLazyLoadImages": "Lazy load images",
+   "mobile-frontend-mobile-option-MFShowFirstParagraphBeforeInfobox": 
"Lead paragraph",
+   
"mobile-frontend-mobile-option-MFShowFirstParagraphBeforeInfobox-description": 
"Text will always show above infoboxes, improving performance and readability.",
+   "mobile-frontend-mobile-option-MFExpandAllSectionsUserOption": "Expand 
all sections by default",
+   
"mobile-frontend-mobile-option-MFExpandAllSectionsUserOption-description": 
"Disable section collapsing on mobile web.",
+   "mobile-frontend-mobile-option-MFEnableFontChanger": "Article font 
size",
+   "mobile-frontend-mobile-option-MFEnableFontChanger-description": 
"Control the font size of your reading experience."
 }
diff --git a/i18n/qqq.json b/i18n/qqq.json
index 7042381..47addc6 100644
--- a/i18n/qqq.json
+++ b/i18n/qqq.json
@@ -300,5 +300,13 @@
"mobile-frontend-mobile-option-MFEnableWikidataDescriptions": "An 
identifier for the wikidata descriptions subproject/feature",

"mobile-frontend-mobile-option-MFEnableWikidataDescriptions-description": "A 
description of the wikidata description subproject/feature",
"mobile-frontend-mobile-option-MFLazyLoadReferences-description": "A 
description of the lazy load references subproject/feature",
-   "mobile-frontend-send-feedback": "Link label for sending feedback to 
the mobile web beta"
+   "mobile-frontend-send-feedback": "Link label for sending feedback to 
the mobile web beta",
+   "mobile-frontend-mobile-option-MFLazyLoadImages-description": "Lazy 
load images feature description",
+   "mobile-frontend-mobile-option-MFLazyLoadImages": "Lazy load images 
feature name",
+   "mobile-frontend-mobile-option-MFShowFirstParagraphBeforeInfobox": 
"Lead paragraph feature name",
+   
"mobile-frontend-mobile-option-MFShowFirstParagraphBeforeInfobox-description": 
"Lead paragraph feature description",
+   "mobile-frontend-mobile-option-MFExpandAllSectionsUserOption": "Expand 
all sections feature name",
+   
"mobile-frontend-mobile-option-MFExpandAllSectionsUserOption-description": 
"Expand sections feature description",
+   "mobile-frontend-mobile-option-MFEnableFontChanger": "Article font size 
feature name",
+   "mobile-frontend-mobile-option-MFEnableFontChanger-description": "Font 
size feature description"
 }
diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 1da8860..84a6b30 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -141,90 +141,6 @@
}
 
/**
-* Gets the value of a config variable whose value depends on whether 
the
-* user is a member of the beta group.
-*
-* @warning If the value of the config variable doesn't behave this 
way, then
-*  `null` is returned.
-*
-* @example
-* ```
-* $wgFoo = [
-*   'beta' => 'bar',
-*   'base' => 'baz',
-* ];
-* $wgQux = 'quux';
-* $wgCorge = [
-   

[MediaWiki-commits] [Gerrit] mediawiki...MobileFrontend[specialpages]: Hygiene: Remove MobileContext::getConfigVariable

2018-01-10 Thread Jdlrobson (Code Review)
Jdlrobson has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/403550 )

Change subject: Hygiene: Remove MobileContext::getConfigVariable
..

Hygiene: Remove MobileContext::getConfigVariable

Going forward we will make use of the FeatureManager for these kinds
of checks.

Given the complexity of the shouldShowWikibaseDescriptions method
I've not (yet) removed it, but have wired it up to the feature
management system.

Change-Id: I6aa1c66ec131a8db75d6e6128d4e3af78f351af0
---
M includes/MobileContext.php
M includes/MobileFrontend.body.php
M includes/MobileFrontend.hooks.php
M includes/ServiceWiring.php
M tests/phpunit/MobileContextTest.php
A tests/phpunit/features/FeaturesManagerTest.php
6 files changed, 86 insertions(+), 135 deletions(-)


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

diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index 1da8860..49d7cb7 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -141,90 +141,6 @@
}
 
/**
-* Gets the value of a config variable whose value depends on whether 
the
-* user is a member of the beta group.
-*
-* @warning If the value of the config variable doesn't behave this 
way, then
-*  `null` is returned.
-*
-* @example
-* ```
-* $wgFoo = [
-*   'beta' => 'bar',
-*   'base' => 'baz',
-* ];
-* $wgQux = 'quux';
-* $wgCorge = [
-*   'grault' => 'garply',
-* ];
-*
-* $context = MobileContext::singleton();
-* $context->getConfigVariable( 'Foo' ); // => 'baz'
-*
-* $context->setMobileMode( 'beta' );
-* $context->getConfigVariable( 'Foo' ); // => 'bar'
-*
-* // If the config variable isn't a dictionary, then its value will be
-* // returned returned regardless of whether the user is a member of 
the beta
-* // group.
-* $context->getConfigVariable( 'Qux' ); // => 'quux'
-*
-* // If the config variable is a dictionary but doesn't have "beta" or 
"base"
-* // entries, then `null` will be returned.
-* $context->getConfigVariable( 'Corge' ); // => null
-* ```
-*
-* @param string $variableName Config variable to be returned
-* @return mixed|null
-* @throws ConfigException If the config variable doesn't exist
-*
-* @TODO Should this be renamed, e.g. `getFlag`, or extracted?
-*/
-   public function getConfigVariable( $variableName ) {
-   $configVariable = $this->getMFConfig()->get( $variableName ) ?: 
[];
-
-   if ( !is_array( $configVariable ) ) {
-   return $configVariable;
-   }
-
-   if ( $this->isBetaGroupMember() && array_key_exists( 'beta', 
$configVariable ) ) {
-   return $configVariable['beta'];
-   } elseif ( array_key_exists( 'base', $configVariable ) ) {
-   return $configVariable['base'];
-   }
-   return null;
-   }
-
-   /**
-* Checks whether references should be lazy loaded for the current user
-* @return bool
-*/
-   public function isLazyLoadReferencesEnabled() {
-   return $this->getConfigVariable( 'MFLazyLoadReferences' );
-   }
-
-   /**
-* Checks whether images should be lazy loaded for the current user
-* @return bool
-*/
-   public function isLazyLoadImagesEnabled() {
-   return $this->getConfigVariable( 'MFLazyLoadImages' );
-   }
-
-   /**
-* Checks whether the first paragraph from the lead section should be
-* shown before all infoboxes that come earlier.
-* @return bool
-*/
-   public function shouldShowFirstParagraphBeforeInfobox() {
-   if ( $this->showFirstParagraphBeforeInfobox === null ) {
-   $this->showFirstParagraphBeforeInfobox = 
$this->getConfigVariable(
-   'MFShowFirstParagraphBeforeInfobox' );
-   }
-   return $this->showFirstParagraphBeforeInfobox;
-   }
-
-   /**
 * Detects whether the UA is sending the request from a device and, if 
so,
 * whether to display the mobile view to that device.
 *
@@ -1157,6 +1073,11 @@
 *  `wgMFDisplayWikibaseDescriptions` configuration variable for detail
 */
public function shouldShowWikibaseDescriptions( $feature ) {
+   $featureManager = \MediaWiki\MediaWikiServices::getInstance()
+   ->getService( 'MobileFrontend.FeaturesManager' );
+   $isEnabled = $featureManager->isAvailableInContext(
+