Skip to content

Commit

Permalink
Avoid use of deprecated wfBCP47() global function (#59)
Browse files Browse the repository at this point in the history
Uses SMW\Localizer, which already has the necessary backward-compatibility
code for use with MW < 1.31.
  • Loading branch information
cscott authored and kghbln committed Jul 4, 2018
1 parent 7a08d5e commit 079d9b3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/AnnotatedLanguageParserFunction.php
Expand Up @@ -5,6 +5,8 @@
use Title;
use Language;

use SMW\Localizer;

/**
* @license GNU GPL v2+
* @since 1.4
Expand Down Expand Up @@ -69,7 +71,7 @@ private function createTemplateInclusionCode( $source, $languageCode, $template
$wikitext = '';

$wikitext .= "|target-link=" . $this->modifyTargetLink( $source );
$wikitext .= "|lang-code=" . wfBCP47( $languageCode );
$wikitext .= "|lang-code=" . Localizer::asBCP47FormattedLanguageCode( $languageCode );
$wikitext .= "|lang-name=" . Language::fetchLanguageName( $languageCode );

$templateText .= '{{' . $template . $wikitext . '}}';
Expand Down
4 changes: 3 additions & 1 deletion src/InterlanguageLinkParserFunction.php
Expand Up @@ -6,6 +6,8 @@
use Title;
use Language;

use SMW\Localizer;

/**
* @license GNU GPL v2+
* @since 1.0
Expand Down Expand Up @@ -97,7 +99,7 @@ public function setRevisionModeState( $inRevisionMode ) {
*/
public function parse( $languageCode, $linkReference ) {

$languageCode = wfBCP47( $languageCode );
$languageCode = Localizer::asBCP47FormattedLanguageCode( $languageCode );

// Keep reference while editing is on going to avoid a possible lag when
// a DV is trying to access the page content language
Expand Down
4 changes: 3 additions & 1 deletion src/InterlanguageListParserFunction.php
Expand Up @@ -5,6 +5,8 @@
use Title;
use Language;

use SMW\Localizer;

/**
* @license GNU GPL v2+
* @since 1.0
Expand Down Expand Up @@ -91,7 +93,7 @@ private function createTemplateInclusionCode( array $languageTargetLinks, $templ

$wikitext .= "|#=" . $i++;
$wikitext .= "|target-link=" . $this->modifyTargetLink( $targetLink );
$wikitext .= "|lang-code=" . wfBCP47( $languageCode );
$wikitext .= "|lang-code=" . Localizer::asBCP47FormattedLanguageCode( $languageCode );
$wikitext .= "|lang-name=" . Language::fetchLanguageName( $languageCode );

$templateText .= '{{' . $template . $wikitext . '}}';
Expand Down
4 changes: 3 additions & 1 deletion src/Search/SearchResultModifier.php
Expand Up @@ -10,6 +10,8 @@
use SearchResultSet;
use SpecialSearch;

use SMW\Localizer;

/**
* @license GNU GPL v2+
* @since 1.0
Expand Down Expand Up @@ -148,7 +150,7 @@ public function applyLanguageFilterToResultMatches( $request, &$titleMatches, &$
return false;
}

$languageCode = wfBCP47( $request->getVal( 'languagefilter' ) );
$languageCode = Localizer::asBCP47FormattedLanguageCode( $request->getVal( 'languagefilter' ) );

if ( in_array( $languageCode, array( null, '', '-' ) ) ) {
return false;
Expand Down

0 comments on commit 079d9b3

Please sign in to comment.