Linker: Force type Language for $lang in tocList and generateTOC
authorFomafix <fomafix@googlemail.com>
Tue, 5 Jun 2018 11:46:57 +0000 (13:46 +0200)
committerFomafix <fomafix@googlemail.com>
Tue, 16 Jul 2019 05:03:59 +0000 (07:03 +0200)
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
includes/DummyLinker.php
includes/Linker.php

index 6ab79c2..1bd4980 100644 (file)
@@ -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 ===
index e46c45e..00d66bf 100644 (file)
@@ -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 );
        }
 
index 2e0011c..f20795d 100644 (file)
@@ -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 ) {