aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUmherirrender <umherirrender_de.wp@web.de>2025-03-26 21:52:34 +0100
committerUmherirrender <umherirrender_de.wp@web.de>2025-03-26 21:55:55 +0100
commit5d7d6c85337d1920fc6a9b7f0713a7abc51c90aa (patch)
treecabc1409af190de8a3ea556fc31aa329eb81d23b
parent3177abfd57041ad249851a4dc9f7f162507fa903 (diff)
downloadmediawikicore-5d7d6c85337d1920fc6a9b7f0713a7abc51c90aa.tar.gz
mediawikicore-5d7d6c85337d1920fc6a9b7f0713a7abc51c90aa.zip
language: No longer support manual construction of Language objects
Bug: T343771 Change-Id: I8f6d57599211eb6c8c29bde3abaccac78c6dc97e
-rw-r--r--RELEASE-NOTES-1.442
-rw-r--r--includes/language/Language.php69
2 files changed, 11 insertions, 60 deletions
diff --git a/RELEASE-NOTES-1.44 b/RELEASE-NOTES-1.44
index 0f74aa5ae6ba..ff2a1b765b64 100644
--- a/RELEASE-NOTES-1.44
+++ b/RELEASE-NOTES-1.44
@@ -251,6 +251,8 @@ because of Phabricator reports.
been unused as a status code by UploadBase for more than 14 years.
* MediaWikiIntegrationTestCase::$tablesUsed, deprecated since 1.41, has been
removed. The framework detects changed tables since 1.41 automatically.
+* MediaWiki\Language\Language class no longer supports manually calling the
+ constructor, use LanguageFactory instead.
* The MediaWiki\Config\MutableConfig interface now extends
MediaWiki\Config\Config. Implementing MutableConfig without implementing
Config is no longer possible.
diff --git a/includes/language/Language.php b/includes/language/Language.php
index 6e795ec41ad5..1bc40326681b 100644
--- a/includes/language/Language.php
+++ b/includes/language/Language.php
@@ -64,7 +64,6 @@ use NumberFormatter;
use RuntimeException;
use StringUtils;
use UtfNormal\Validator as UtfNormalValidator;
-use Wikimedia\Assert\Assert;
use Wikimedia\AtEase\AtEase;
use Wikimedia\Bcp47Code\Bcp47Code;
use Wikimedia\DebugInfo\DebugInfoTrait;
@@ -331,68 +330,18 @@ class Language implements Bcp47Code {
// @codeCoverageIgnoreEnd
/**
- * @internal Calling this directly is deprecated. Use LanguageFactory instead.
- *
- * @param string|null $code Which code to use. Passing null is deprecated in 1.35, hard-deprecated since 1.43.
- * @param NamespaceInfo|null $namespaceInfo
- * @param LocalisationCache|null $localisationCache
- * @param LanguageNameUtils|null $langNameUtils
- * @param LanguageFallback|null $langFallback
- * @param LanguageConverterFactory|null $converterFactory
- * @param HookContainer|null $hookContainer
- * @param Config|null $config
+ * @internal Use LanguageFactory instead.
*/
public function __construct(
- $code = null,
- ?NamespaceInfo $namespaceInfo = null,
- ?LocalisationCache $localisationCache = null,
- ?LanguageNameUtils $langNameUtils = null,
- ?LanguageFallback $langFallback = null,
- ?LanguageConverterFactory $converterFactory = null,
- ?HookContainer $hookContainer = null,
- ?Config $config = null
+ string $code,
+ NamespaceInfo $namespaceInfo,
+ LocalisationCache $localisationCache,
+ LanguageNameUtils $langNameUtils,
+ LanguageFallback $langFallback,
+ LanguageConverterFactory $converterFactory,
+ HookContainer $hookContainer,
+ Config $config
) {
- if ( !func_num_args() ) {
- // Old calling convention, deprecated
- wfDeprecatedMsg(
- __METHOD__ . ' without providing all services is deprecated',
- '1.35'
- );
- if ( static::class === 'Language' ) {
- $this->mCode = 'en';
- } else {
- $this->mCode = str_replace( '_', '-', strtolower( substr( static::class, 8 ) ) );
- }
-
- $services = MediaWikiServices::getInstance();
- $this->namespaceInfo = $services->getNamespaceInfo();
- $this->localisationCache = $services->getLocalisationCache();
- $this->langNameUtils = $services->getLanguageNameUtils();
- $this->langFallback = $services->getLanguageFallback();
- $this->converterFactory = $services->getLanguageConverterFactory();
- $this->hookContainer = $services->getHookContainer();
- $this->hookRunner = new HookRunner( $this->hookContainer );
- $this->config = $services->getMainConfig();
- return;
- }
-
- Assert::parameter( $code !== null, '$code',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $namespaceInfo !== null, '$namespaceInfo',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $localisationCache !== null, '$localisationCache',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $langNameUtils !== null, '$langNameUtils',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $langFallback !== null, '$langFallback',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $converterFactory !== null, '$converterFactory',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $hookContainer !== null, '$hookContainer',
- 'Parameters cannot be null unless all are omitted' );
- Assert::parameter( $config !== null, '$config',
- 'Parameters cannot be null unless all are omitted' );
-
$this->mCode = $code;
$this->namespaceInfo = $namespaceInfo;
$this->localisationCache = $localisationCache;