From bbf7fa8b343dc52b2001d72bc393d295507a7615 Mon Sep 17 00:00:00 2001 From: alistair3149 Date: Wed, 18 May 2022 14:20:51 -0400 Subject: [PATCH] fix(core): don't use `getActionName` < MW 1.38 getActionName does not exist before MW 1.38, use getAction instead Bug: #459 --- includes/Partials/PageTools.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/Partials/PageTools.php b/includes/Partials/PageTools.php index 6c7514c5..40c84be7 100644 --- a/includes/Partials/PageTools.php +++ b/includes/Partials/PageTools.php @@ -25,9 +25,11 @@ declare( strict_types=1 ); namespace Citizen\Partials; +use ContextSource; use Exception; use ExtensionRegistry; use MediaWiki\MediaWikiServices; +use Skin; use SkinTemplate; final class PageTools extends Partial { @@ -166,9 +168,18 @@ final class PageTools extends Partial { private function canHaveLanguages(): bool { $skin = $this->skin; - if ( $skin->getContext()->getActionName() !== 'view' ) { - return false; + if ( method_exists( Skin::class, 'getActionName' ) ) { + // >= MW 1.38 + if ( $skin->getContext()->getActionName() !== 'view' ) { + return false; + } + } else { + // < MW 1.38 + if ( $skin->getContext()->getAction() !== 'view' ) { + return false; + } } + $title = $skin->getTitle(); // Defensive programming - if a special page has added languages explicitly, best to show it. if ( $title && $title->isSpecialPage() && empty( $this->getLanguagesCached() ) ) {