From f095d0d771e375ac8b94e2b3f0f9bb2555e8f1b5 Mon Sep 17 00:00:00 2001 From: Fomafix Date: Tue, 5 Jun 2018 13:46:57 +0200 Subject: [PATCH] Linker: Force type Language for $lang in tocList and generateTOC The call of wfGetLangObj( $lang ) is not necessary anymore. $lang still defaults to user interface language on unset parameter. This change is a follow-up to I15b65fec987641885374dfef9e1229ea405f7c30. Change-Id: I6f12097a0e6cf7d6035d1164092c8b87c58e2bee --- RELEASE-NOTES-1.34 | 3 +++ includes/DummyLinker.php | 4 ++-- includes/Linker.php | 14 ++++---------- 3 files changed, 9 insertions(+), 12 deletions(-) diff --git a/RELEASE-NOTES-1.34 b/RELEASE-NOTES-1.34 index 6ab79c237a..1bd4980b76 100644 --- a/RELEASE-NOTES-1.34 +++ b/RELEASE-NOTES-1.34 @@ -288,6 +288,9 @@ because of Phabricator reports. * (T222637) Passing ResourceLoaderModule objects to ResourceLoader::register() or $wgResourceModules is no longer supported. Use the 'class' or 'factory' option of the array format instead. +* The parameter $lang of the functions generateTOC and tocList in Linker and + DummyLinker must be in type Language when present. Other types are + deprecated since 1.33. * … === Deprecations in 1.34 === diff --git a/includes/DummyLinker.php b/includes/DummyLinker.php index e46c45e6ea..00d66bf13c 100644 --- a/includes/DummyLinker.php +++ b/includes/DummyLinker.php @@ -345,11 +345,11 @@ class DummyLinker { return Linker::tocLineEnd(); } - public function tocList( $toc, $lang = null ) { + public function tocList( $toc, Language $lang = null ) { return Linker::tocList( $toc, $lang ); } - public function generateTOC( $tree, $lang = null ) { + public function generateTOC( $tree, Language $lang = null ) { return Linker::generateTOC( $tree, $lang ); } diff --git a/includes/Linker.php b/includes/Linker.php index 2e0011cf44..f20795d769 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1667,16 +1667,11 @@ class Linker { * * @since 1.16.3 * @param string $toc Html of the Table Of Contents - * @param string|Language|bool|null $lang Language for the toc title, defaults to user language. - * The types string and bool are deprecated. + * @param Language|null $lang Language for the toc title, defaults to user language * @return string Full html of the TOC */ - public static function tocList( $toc, $lang = null ) { + public static function tocList( $toc, Language $lang = null ) { $lang = $lang ?? RequestContext::getMain()->getLanguage(); - if ( !$lang instanceof Language ) { - wfDeprecated( __METHOD__ . ' with type other than Language for $lang', '1.33' ); - $lang = wfGetLangObj( $lang ); - } $title = wfMessage( 'toc' )->inLanguage( $lang )->escaped(); @@ -1709,11 +1704,10 @@ class Linker { * * @since 1.16.3. $lang added in 1.17 * @param array $tree Return value of ParserOutput::getSections() - * @param string|Language|bool|null $lang Language for the toc title, defaults to user language. - * The types string and bool are deprecated. + * @param Language|null $lang Language for the toc title, defaults to user language * @return string HTML fragment */ - public static function generateTOC( $tree, $lang = null ) { + public static function generateTOC( $tree, Language $lang = null ) { $toc = ''; $lastLevel = 0; foreach ( $tree as $section ) { -- 2.20.1