Page MenuHomePhabricator

Use of wfBCP47 was deprecated in MediaWiki 1.31. [Called from PageTranslationHooks::formatLanguageLink
Closed, ResolvedPublic

Description

PHP Deprecated: Use of wfBCP47 was deprecated in MediaWiki 1.31. [Called from PageTranslationHooks::formatLanguageLink in /www/dev.translatewiki.net/docroot/w/extensions/Translate/tag/PageTranslationHooks.php at line 557] in /www/dev.translatewiki.net/docroot/w/includes/debug/MWDebug.php on line 309

Event Timeline

abi_ claimed this task.
abi_ subscribed.

@Nikerabbit - The patch above has been abandoned. I believe that since the translate extension needs to support MediaWiki - 1.29 and above, we will need to add conditionals in addition to what's done in the previous patch.

I'd like to add a method to TranslateUtils called bcp47 which will check the version of MediaWiki and then use the appropriate method. This will be important in-case the global function wfBCP47 is removed in the future version.

Version checking will be done using,

global $wgVersion;
version_compare( $wgVersion, '1.31', '<' );

Minimum version of MediaWiki core that needs to be supported by MLEB extensions is now 1.31. Hence I think no versions checks are needed anymore (and if they are needed, I prefer is_callable( new method ).

OK, I was checking the MediaWiki version listed on the page here,

image.png (831×1 px, 183 KB)

I will restore and review the patch, and also update the version on that Wiki page.

I prefer is_callable( new method ).

I agree, that would be a better approach.

Change 494208 had a related patch set uploaded (by Abijeet Patro; owner: Abijeet Patro):
[mediawiki/extensions/Translate@master] Replaces usage of wfBCP47 with LanguageCode::bcp47

https://gerrit.wikimedia.org/r/494208

I reviewed the previous patch, and noticed that wrapper code was already added to the extension in this patch. Hence decided to abandon the previous patch mentioned here.

I've removed the wrapper added in TranslateUtils with direct calls to LanguageCode::bcp47 since we no longer need to maintain backward compatibility with MediaWiki versions < 1.31.

Testing

To test this I performed the following actions,

  1. Login
  2. Marking a new page for translation.
  3. Translating the translation units.
  4. Running the test cases under Translate extension tests folder.

All of the above worked as expected.

I've also updated the minimum version mentioned here.

Change 494208 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Replaces usage of wfBCP47 with LanguageCode::bcp47

https://gerrit.wikimedia.org/r/494208

abi_ moved this task from Under Review to QA on the User-abi_ board.

Moved to QA.

I have verified this with code search and testing.