summaryrefslogtreecommitdiff
path: root/languages/ConverterRule.php
diff options
context:
space:
mode:
authorPierre Schmitz <pierre@archlinux.de>2015-12-17 09:15:42 +0100
committerPierre Schmitz <pierre@archlinux.de>2015-12-17 09:44:51 +0100
commita1789ddde42033f1b05cc4929491214ee6e79383 (patch)
tree63615735c4ddffaaabf2428946bb26f90899f7bf /languages/ConverterRule.php
parent9e06a62f265e3a2aaabecc598d4bc617e06fa32d (diff)
Update to MediaWiki 1.26.0
Diffstat (limited to 'languages/ConverterRule.php')
-rw-r--r--languages/ConverterRule.php26
1 files changed, 15 insertions, 11 deletions
diff --git a/languages/ConverterRule.php b/languages/ConverterRule.php
index e6625c1a..e3a4f77e 100644
--- a/languages/ConverterRule.php
+++ b/languages/ConverterRule.php
@@ -155,18 +155,20 @@ class ConverterRule {
$to = trim( $v[1] );
$v = trim( $v[0] );
$u = explode( '=>', $v, 2 );
- // if $to is empty, strtr() could return a wrong result
- if ( count( $u ) == 1 && $to && in_array( $v, $variants ) ) {
+ // if $to is empty (which is also used as $from in bidtable),
+ // strtr() could return a wrong result.
+ if ( count( $u ) == 1 && $to !== '' && in_array( $v, $variants ) ) {
$bidtable[$v] = $to;
} elseif ( count( $u ) == 2 ) {
$from = trim( $u[0] );
$v = trim( $u[1] );
+ // if $from is empty, strtr() could return a wrong result.
if ( array_key_exists( $v, $unidtable )
&& !is_array( $unidtable[$v] )
- && $to
+ && $from !== ''
&& in_array( $v, $variants ) ) {
$unidtable[$v] = array( $from => $to );
- } elseif ( $to && in_array( $v, $variants ) ) {
+ } elseif ( $from !== '' && in_array( $v, $variants ) ) {
$unidtable[$v][$from] = $to;
}
}
@@ -220,17 +222,17 @@ class ConverterRule {
// display current variant in bidirectional array
$disp = $this->getTextInBidtable( $variant );
// or display current variant in fallbacks
- if ( !$disp ) {
+ if ( $disp === false ) {
$disp = $this->getTextInBidtable(
$this->mConverter->getVariantFallbacks( $variant ) );
}
// or display current variant in unidirectional array
- if ( !$disp && array_key_exists( $variant, $unidtable ) ) {
+ if ( $disp === false && array_key_exists( $variant, $unidtable ) ) {
$disp = array_values( $unidtable[$variant] );
$disp = $disp[0];
}
// or display frist text under disable manual convert
- if ( !$disp && $this->mConverter->mManualLevel[$variant] == 'disable' ) {
+ if ( $disp === false && $this->mConverter->mManualLevel[$variant] == 'disable' ) {
if ( count( $bidtable ) > 0 ) {
$disp = array_values( $bidtable );
$disp = $disp[0];
@@ -325,7 +327,7 @@ class ConverterRule {
&& isset( $unidtable[$v] )
) {
if ( isset( $this->mConvTable[$v] ) ) {
- $this->mConvTable[$v] = array_merge( $this->mConvTable[$v], $unidtable[$v] );
+ $this->mConvTable[$v] = $unidtable[$v] + $this->mConvTable[$v];
} else {
$this->mConvTable[$v] = $unidtable[$v];
}
@@ -383,9 +385,11 @@ class ConverterRule {
if ( !$this->mBidtable && !$this->mUnidtable ) {
if ( isset( $flags['+'] ) || isset( $flags['-'] ) ) {
- // fill all variants if text in -{A/H/-|text} without rules
- foreach ( $this->mConverter->mVariants as $v ) {
- $this->mBidtable[$v] = $rules;
+ // fill all variants if text in -{A/H/-|text}- is non-empty but without rules
+ if ( $rules !== '' ) {
+ foreach ( $this->mConverter->mVariants as $v ) {
+ $this->mBidtable[$v] = $rules;
+ }
}
} elseif ( !isset( $flags['N'] ) && !isset( $flags['T'] ) ) {
$this->mFlags = $flags = array( 'R' => true );