From 14af941e8844ee738d276a5a884206fc72e690b7 Mon Sep 17 00:00:00 2001 From: Siddharth VP Date: Thu, 14 Oct 2021 10:16:01 +0530 Subject: [PATCH] Add global 'withgadget' query parameter for ad-hoc loading of gadgets When viewing pages, the 'withgadget=' query parameter can be used in the URL to load a gadget that isn't enabled by the user's preferences. The gadget is only loaded if all other conditions are still satisfied (supported skin, supported targets, required user rights). Bug: T29766 Change-Id: I5b30d4e0010561685eef661a515e2892045bb776 --- includes/GadgetHooks.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/GadgetHooks.php b/includes/GadgetHooks.php index 5649c85a..0290735e 100644 --- a/includes/GadgetHooks.php +++ b/includes/GadgetHooks.php @@ -172,6 +172,7 @@ class GadgetHooks { $lb = new LinkBatch(); $lb->setCaller( __METHOD__ ); $enabledLegacyGadgets = []; + $req = $out->getRequest(); /** * @var $gadget Gadget @@ -192,7 +193,7 @@ class GadgetHooks { // @todo: Emit warning for invalid peer? } } - if ( $gadget->isEnabled( $user ) + if ( ( $gadget->isEnabled( $user ) || $req->getRawVal( 'withgadget' ) === $id ) && $gadget->isAllowed( $user ) && $gadget->isSkinSupported( $out->getSkin() ) && ( in_array( $out->getTarget() ?? 'desktop', $gadget->getTargets() ) )