Move version check inside PersonalUrls hook
Stop additional conditional hook if MW < 1.37, and move the check to inside the hook itself Bug: T299305 Change-Id: Ied1c5c0beee015d7b0a8d6bd750346f4a8a5aaa1
This commit is contained in:
@@ -25,6 +25,7 @@
|
|||||||
"GetBetaFeaturePreferences": "main",
|
"GetBetaFeaturePreferences": "main",
|
||||||
"GetPreferences": "main",
|
"GetPreferences": "main",
|
||||||
"MakeGlobalVariablesScript": "main",
|
"MakeGlobalVariablesScript": "main",
|
||||||
|
"PersonalUrls": "main",
|
||||||
"ResourceLoaderGetConfigVars": "main",
|
"ResourceLoaderGetConfigVars": "main",
|
||||||
"SkinAfterPortlet": "main",
|
"SkinAfterPortlet": "main",
|
||||||
"SkinTemplateNavigation::Universal": "main",
|
"SkinTemplateNavigation::Universal": "main",
|
||||||
|
|||||||
@@ -88,19 +88,7 @@ class Hooks implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function setVersionConstant() {
|
public static function setVersionConstant() {
|
||||||
global $wgHooks;
|
|
||||||
|
|
||||||
define( 'ULS_VERSION', '2020-07-20' );
|
define( 'ULS_VERSION', '2020-07-20' );
|
||||||
|
|
||||||
// For MediaWiki < 1.37, there is no `user-interface-preferences` menu. We use
|
|
||||||
// the PersonalUrls hook to make sure the language button is added.
|
|
||||||
// In MediaWiki > 1.37, the personal urls was split out into multiple new menus,
|
|
||||||
// In the new format, the `user-interface-preferences` is the most relevant place to put
|
|
||||||
// this button. Using the SkinTemplateNavigation::Universal hook will ensure the button is
|
|
||||||
// added to the correct menu.
|
|
||||||
if ( version_compare( MW_VERSION, '1.37', '<' ) ) {
|
|
||||||
$wgHooks['PersonalUrls'][] = "UniversalLanguageSelector\\Hooks::onPersonalUrls";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -233,6 +221,16 @@ class Hooks implements
|
|||||||
* @param SkinTemplate $skin
|
* @param SkinTemplate $skin
|
||||||
*/
|
*/
|
||||||
public function onPersonalUrls( &$personal_urls, &$title, $skin ): void {
|
public function onPersonalUrls( &$personal_urls, &$title, $skin ): void {
|
||||||
|
// For MediaWiki < 1.37, there is no `user-interface-preferences` menu. We use
|
||||||
|
// the PersonalUrls hook to make sure the language button is added.
|
||||||
|
// In MediaWiki >= 1.37, the personal urls was split out into multiple new menus,
|
||||||
|
// In the new format, the `user-interface-preferences` is the most relevant place to put
|
||||||
|
// this button. Using the SkinTemplateNavigation::Universal hook will ensure the button is
|
||||||
|
// added to the correct menu.
|
||||||
|
if ( version_compare( MW_VERSION, '1.37', '>=' ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$personal_urls = $this->addPersonalBarTrigger(
|
$personal_urls = $this->addPersonalBarTrigger(
|
||||||
$personal_urls,
|
$personal_urls,
|
||||||
$skin
|
$skin
|
||||||
|
|||||||
Reference in New Issue
Block a user