From 9d6b0e8206f0992cc81d264d556b1d2ea66f7abf Mon Sep 17 00:00:00 2001 From: "James D. Forrester" Date: Fri, 26 Jan 2024 12:48:18 -0500 Subject: [PATCH] Follow-Up 27f913cc96: Drop complicated MobileContext injection, now unused Change-Id: I8b32abd4bcc0b588972c65956d08c4b29bf6b4aa --- extension.json | 3 --- includes/GadgetLoadConditions.php | 5 +---- includes/Hooks.php | 22 ++-------------------- 3 files changed, 3 insertions(+), 27 deletions(-) diff --git a/extension.json b/extension.json index 10f0d064..c87c284a 100644 --- a/extension.json +++ b/extension.json @@ -96,9 +96,6 @@ "services": [ "GadgetsRepo", "UserOptionsLookup" - ], - "optional_services": [ - "MobileFrontend.Context" ] }, "GadgetCodeEditorHooks": { diff --git a/includes/GadgetLoadConditions.php b/includes/GadgetLoadConditions.php index 7adc5180..b54e787d 100644 --- a/includes/GadgetLoadConditions.php +++ b/includes/GadgetLoadConditions.php @@ -38,22 +38,19 @@ class GadgetLoadConditions { private $namespace; /** @var string */ private $contentModel; - /** @var bool */ - private $isMobileView; /** @var string|null */ private $withGadgetParam; /** * @param OutputPage $out */ - public function __construct( OutputPage $out, bool $isMobileView = false ) { + public function __construct( OutputPage $out ) { $this->user = $out->getUser(); $this->skin = $out->getSkin(); $this->action = $out->getContext()->getActionName(); $this->namespace = $out->getTitle()->getNamespace(); $this->contentModel = $out->getTitle()->getContentModel(); $this->withGadgetParam = $out->getRequest()->getRawVal( 'withgadget' ); - $this->isMobileView = $isMobileView; } /** diff --git a/includes/Hooks.php b/includes/Hooks.php index 9d0a5b7c..eab3c062 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -57,7 +57,6 @@ use MediaWiki\User\Hook\UserGetDefaultOptionsHook; use MediaWiki\User\Options\UserOptionsLookup; use MediaWiki\User\User; use MessageSpecifier; -use MobileContext; use OOUI\HtmlSnippet; use RequestContext; use Skin; @@ -83,18 +82,13 @@ class Hooks implements { private GadgetRepo $gadgetRepo; private UserOptionsLookup $userOptionsLookup; - /** @phan-suppress-next-line PhanUndeclaredTypeProperty */ - private ?MobileContext $mobileContext; public function __construct( GadgetRepo $gadgetRepo, - UserOptionsLookup $userOptionsLookup, - // @phan-suppress-next-line PhanUndeclaredTypeParameter - ?MobileContext $mobileContext + UserOptionsLookup $userOptionsLookup ) { $this->gadgetRepo = $gadgetRepo; $this->userOptionsLookup = $userOptionsLookup; - $this->mobileContext = $mobileContext; } /** @@ -166,16 +160,6 @@ class Hooks implements } } - /** - * Check whether the gadget should load on the mobile domain based on its definition. - * - * @return bool - */ - private function isMobileView(): bool { - // @phan-suppress-next-line PhanUndeclaredClassMethod - return $this->mobileContext && $this->mobileContext->shouldDisplayMobileView(); - } - /** * GetPreferences hook handler. * @param User $user @@ -205,7 +189,6 @@ class Hooks implements } $skin = RequestContext::getMain()->getSkin(); - $isMobileView = $this->isMobileView(); foreach ( $gadgets as $section => $thisSection ) { foreach ( $thisSection as $gadget ) { // Only show option to enable gadget if it can be enabled @@ -281,13 +264,12 @@ class Hooks implements public function onBeforePageDisplay( $out, $skin ): void { $repo = $this->gadgetRepo; $ids = $repo->getGadgetIds(); - $isMobileView = $this->isMobileView(); if ( !$ids ) { return; } $enabledLegacyGadgets = []; - $conditions = new GadgetLoadConditions( $out, $isMobileView ); + $conditions = new GadgetLoadConditions( $out ); /** * @var $gadget Gadget