jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/357744 )

Change subject: Fix warning in MwTimeIsoFormatter
......................................................................


Fix warning in MwTimeIsoFormatter

Language::getDatePreferences may return false, if date
format preferences are disabled, so we need to check
if it is an array in addition to in_array check.

$datePreferences (in the Messages*.php) file is false
for 11 languages, including Spanish (es) and Esperanto (eo).

Bug: T167360
Change-Id: Ifcc6191c108cc8c86d335274cc51d0dc7bc1136a
---
M lib/includes/Formatters/MwTimeIsoFormatter.php
M lib/tests/phpunit/Formatters/MwTimeIsoFormatterTest.php
2 files changed, 10 insertions(+), 1 deletion(-)

Approvals:
  Ladsgroup: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/includes/Formatters/MwTimeIsoFormatter.php 
b/lib/includes/Formatters/MwTimeIsoFormatter.php
index cf0127d..9835595 100644
--- a/lib/includes/Formatters/MwTimeIsoFormatter.php
+++ b/lib/includes/Formatters/MwTimeIsoFormatter.php
@@ -105,8 +105,9 @@
         */
        private function getDateFormat( $precision ) {
                $datePreference = 'dmy';
+               $datePreferences = $this->language->getDatePreferences();
 
-               if ( !in_array( $datePreference, 
$this->language->getDatePreferences() ) ) {
+               if ( $datePreferences === false || !in_array( $datePreference, 
$datePreferences ) ) {
                        $datePreference = 'default';
                }
 
diff --git a/lib/tests/phpunit/Formatters/MwTimeIsoFormatterTest.php 
b/lib/tests/phpunit/Formatters/MwTimeIsoFormatterTest.php
index 35107df..dd4c40f 100644
--- a/lib/tests/phpunit/Formatters/MwTimeIsoFormatterTest.php
+++ b/lib/tests/phpunit/Formatters/MwTimeIsoFormatterTest.php
@@ -514,6 +514,13 @@
                                '10000000',
                                'de'
                        ),
+
+                       // Spanish has no date preferences
+                       array(
+                               '+2017-01-16T00:00:00Z', 
TimeValue::PRECISION_DAY,
+                               '16 ene 2017',
+                               'es'
+                       ),
                );
 
                $argLists = array();
@@ -536,6 +543,7 @@
                        'ar', //replaces all numbers and separators
                        'bo', //replaces only numbers
                        'de', //switches separators
+                       'es', //no date preferences
                        'la', //defaults to genitive month names
                        'or', //replaces all numbers and separators
                );

-- 
To view, visit https://gerrit.wikimedia.org/r/357744
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ifcc6191c108cc8c86d335274cc51d0dc7bc1136a
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/extensions/Wikibase
Gerrit-Branch: master
Gerrit-Owner: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Aude <aude.w...@gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com>
Gerrit-Reviewer: Thiemo Mättig (WMDE) <thiemo.maet...@wikimedia.de>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to