summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'MLEB/cldr/includes/TimeUnits.php')
-rw-r--r--MLEB/cldr/includes/TimeUnits.php23
1 files changed, 9 insertions, 14 deletions
diff --git a/MLEB/cldr/includes/TimeUnits.php b/MLEB/cldr/includes/TimeUnits.php
index 02c9916f..731e0d46 100644
--- a/MLEB/cldr/includes/TimeUnits.php
+++ b/MLEB/cldr/includes/TimeUnits.php
@@ -49,6 +49,8 @@ class TimeUnits extends CldrNames {
*/
private static function loadLanguage( $code ) {
if ( !isset( self::$cache[$code] ) ) {
+ self::$cache[$code] = [];
+
/* Load override for wrong or missing entries in cldr */
$override = __DIR__ . '/../LocalNames/' . self::getOverrideFileName( $code );
if ( Language::isValidBuiltInCode( $code ) && file_exists( $override ) ) {
@@ -56,6 +58,7 @@ class TimeUnits extends CldrNames {
require $override;
+ // @phan-suppress-next-line PhanImpossibleCondition
if ( is_array( $timeUnits ) ) {
self::$cache[$code] = $timeUnits;
}
@@ -65,21 +68,13 @@ class TimeUnits extends CldrNames {
if ( Language::isValidBuiltInCode( $code ) && file_exists( $filename ) ) {
$timeUnits = false;
require $filename;
+ // @phan-suppress-next-line PhanImpossibleCondition
if ( is_array( $timeUnits ) ) {
- if ( isset( self::$cache[$code] ) ) {
- // Add to existing list of localized time units
- self::$cache[$code] = self::$cache[$code] + $timeUnits;
- } else {
- // No list exists, so create it
- self::$cache[$code] = $timeUnits;
- }
+ self::$cache[$code] = self::$cache[$code] + $timeUnits;
}
} else {
wfDebug( __METHOD__ . ": Unable to load time units for $filename\n" );
}
- if ( !isset( self::$cache[$code] ) ) {
- self::$cache[$code] = [];
- }
}
return self::$cache[$code];
@@ -122,18 +117,18 @@ class TimeUnits extends CldrNames {
// Figure out which unit (days, months, etc.) it makes sense to display
// the timestamp in, and get the number of that unit to use.
$unit = null;
+ $number = 0;
foreach ( $units as $code => $testUnit ) {
- $testNumber = $timeDifference->format( '%' . $code );
- if ( (int)$testNumber > 0 ) {
+ $testNumber = (int)$timeDifference->format( '%' . $code );
+ if ( $testNumber > 0 ) {
$unit = $testUnit;
$number = $testNumber;
}
}
// If it occurred less than 1 second ago, output 'just now' message.
- if ( !$unit ) {
+ if ( !$unit || !$number ) {
$output = wfMessage( 'just-now' )->inLanguage( $lang )->text();
-
return false;
}