From e9ac5dcf47f60b4339f7e4492db5815021537e3e Mon Sep 17 00:00:00 2001 From: Jon Robson Date: Fri, 2 Feb 2024 10:59:04 -0800 Subject: [PATCH] Allow Cite to define the reference preview module instead This provides backwards compatibility with Cite, if Cite has register its own preview module for reference tooltips. Bug: T355194 Change-Id: Iec6f3d4d6c5f765c151ae0dbba258049530e6bc0 --- includes/PopupsHooks.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/PopupsHooks.php b/includes/PopupsHooks.php index 59c6a42de..c26b57451 100644 --- a/includes/PopupsHooks.php +++ b/includes/PopupsHooks.php @@ -67,11 +67,17 @@ class PopupsHooks implements * @return array */ public static function getCustomPopupTypes(): array { + $rl = MediaWikiServices::getInstance()->getService( 'ResourceLoader' ); + // FIXME: If the module ext.cite.referencePreviews does not exist register reference previews. + // This code can be removed once T355194 is complete. + $others = $rl->getModule( 'ext.cite.referencePreviews' ) ? + [] : [ + 'ext.popups.referencePreviews' + ]; + return array_merge( ExtensionRegistry::getInstance()->getAttribute( 'PopupsPluginModules' - ), [ - 'ext.popups.referencePreviews' - ] ); + ), $others ); } /**