From c33ca6218f9748959d889a1a4d0f6cc048cdcf0c Mon Sep 17 00:00:00 2001 From: Fomafix Date: Wed, 13 Sep 2017 14:57:44 +0200 Subject: [PATCH] parser: Deprecate string type for $lang arg in DateFormatter::getInstance The parameter $lang is not used with type string in the Git repository: https://codesearch.wmflabs.org/search/?q=DateFormatter%3A%3AgetInstance This function is only used with type Language and without parameter. The support for the language as string will be removed with Change-ID I677ab561d67b63f0c86f65fadf9319e41444a22a. The removal of the support for the type string simplifies the code. Change-Id: I0c0ab46ffc0fab6b68672940e979ad7e5754a7d1 --- RELEASE-NOTES-1.31 | 2 ++ includes/parser/DateFormatter.php | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/RELEASE-NOTES-1.31 b/RELEASE-NOTES-1.31 index 588d0767e2..2c071b53b0 100644 --- a/RELEASE-NOTES-1.31 +++ b/RELEASE-NOTES-1.31 @@ -239,6 +239,8 @@ changes to languages because of Phabricator reports. * CommentStore::insertWithTemplate * The method ResourceLoaderModule::getPosition(), deprecated in 1.29, has been removed. * The DeferredStringifier class is deprecated, use Message::listParam() instead. +* The type string for the parameter $lang of DateFormatter::getInstance is + deprecated. == Compatibility == MediaWiki 1.31 requires PHP 5.5.9 or later. Although HHVM 3.18.5 or later is supported, diff --git a/includes/parser/DateFormatter.php b/includes/parser/DateFormatter.php index 605a873b7d..0a4a60e9e5 100644 --- a/includes/parser/DateFormatter.php +++ b/includes/parser/DateFormatter.php @@ -126,13 +126,16 @@ class DateFormatter { /** * Get a DateFormatter object * - * @param Language|string|null $lang In which language to format the date + * @param Language|null $lang In which language to format the date * Defaults to the site content language * @return DateFormatter */ public static function getInstance( $lang = null ) { global $wgContLang, $wgMainCacheType; + if ( is_string( $lang ) ) { + wfDeprecated( __METHOD__ . ' with type string for $lang', '1.31' ); + } $lang = $lang ? wfGetLangObj( $lang ) : $wgContLang; $cache = ObjectCache::getLocalServerInstance( $wgMainCacheType ); -- 2.20.1