Problem/Motivation

E.g. https://www.drupal.org/pift-ci-job/620182

Failing tests:

User.Drupal\user\Tests\UserTimeZoneTest

✗ testUserTimeZone
fail: [Other] Line 67 of core/modules/user/src/Tests/UserTimeZoneTest.php:
Date should be Chile summer time; five hours ahead of PST.

fail: [Other] Line 69 of core/modules/user/src/Tests/UserTimeZoneTest.php:
Date should be Chile time; four hours ahead of PST

fail: [Other] Line 71 of core/modules/user/src/Tests/UserTimeZoneTest.php:
Date should be Chile time; three hours ahead of PDT.

@mpdonadio mentioned that there was a recent change to Chile's timezone rules. This may be an actual bug in HEAD as the assertion in question is for a date in 2007, and Chile's timezone rules have actually changed a few times since then.

Proposed resolution

Fix HEAD or the test, depending.

Remaining tasks

TBD

User interface changes

API changes

Data model changes

CommentFileSizeAuthor
#17 interdiff-12-17.txt911 bytesmpdonadio
#17 2860663-17.patch3.48 KBmpdonadio
#12 2860663-12.patch3.04 KBmpdonadio
#11 2860663-test-only.patch1007 bytesmpdonadio
#9 2860663-09.patch1.82 KBmpdonadio
#6 2860663-test-only.patch3.77 KBmpdonadio
#5 2860663-test-only.patch212 bytesmpdonadio
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

xjm created an issue. See original summary.

xjm’s picture

mpdonadio’s picture

Assigned: Unassigned » mpdonadio

Is this constantly failing, or intermittent?

I think we need to do two things:

1. Either on admin/reports/status or admin/config/regional/settings, we need to output the results of `timezone_version_get()`. I suspect these dev versions of PHP are using the newer timezonedb that have the Chile change. This should also be logged in a test (UserTimeZoneTest may be best here).

2. Short term we should change UserTimeZoneTest to use a different TZ that observes DST (to fix the critical). Long term, we should standardize the zone we use throughout tests, unless we are explicitly testing something and have picked the zones for particular reasons (eg, the TZ loop in the datatime field tests). Not to be US centric, but I think we should pick America/New_York, which maps to the North American Eastern Time Zone (I can't recall the official letter designation), and that book is at home). It observes DST, is far enough from UTC to show problems where there is a glitch, and I think these is less chance of another local change (which is my fear with choosing something outside the US).

For reference this is the database, https://github.com/eggert/tz, but work/changes are discussed on the tz mailing list (patches are posted to the list, they don't do pull requests).

heddn’s picture

mpdonadio’s picture

Status: Needs review » Needs work

The last submitted patch, 6: 2860663-test-only.patch, failed testing.

mpdonadio’s picture

This is in the notes for 2017a:

  Changes to past and future time zone abbreviations

    Switch to numeric time zone abbreviations for South America, as
    part of the ongoing project of removing invented abbreviations.
    This avoids the need to invent an abbreviation for the new Chilean
    new zone.  Similarly, switch from invented to numeric time zone
    abbreviations for Afghanistan, American Samoa, the Azores,
    Bangladesh, Bhutan, the British Indian Ocean Territory, Brunei,
    Cape Verde, Chatham Is, Christmas I, Cocos (Keeling) Is, Cook Is,
    Dubai, East Timor, Eucla, Fiji, French Polynesia, Greenland,
    Indochina, Iran, Iraq, Kiribati, Lord Howe, Macquarie, Malaysia,
    the Maldives, Marshall Is, Mauritius, Micronesia, Mongolia,
    Myanmar, Nauru, Nepal, New Caledonia, Niue, Norfolk I, Palau,
    Papua New Guinea, the Philippines, Pitcairn, Qatar, Réunion, St
    Pierre & Miquelon, Samoa, Saudi Arabia, Seychelles, Singapore,
    Solomon Is, Tokelau, Tuvalu, Wake, Vanuatu, Wallis & Futuna, and
    Xinjiang; for 20-minute daylight saving time in Ghana before 1943;
    for half-hour daylight saving time in Belize before 1944 and in
    the Dominican Republic before 1975; and for Canary Islands before
    1946, for Guinea-Bissau before 1975, for Iceland before 1969, for
    Indian Summer Time before 1942, for Indonesia before around 1964,
    for Kenya before 1960, for Liberia before 1973, for Madeira before
    1967, for Namibia before 1943, for the Netherlands in 1937-9, for
    Pakistan before 1971, for Western Sahara before 1977, and for
    Zaporozhye in 1880-1924.

I think this is the problem, but I need to figure out a way to arbiltrarilly swap the PHP zoneinfo locally to test this.

mpdonadio’s picture

xjm’s picture

+++ b/core/modules/user/src/Tests/UserTimeZoneTest.php
@@ -55,20 +55,21 @@ public function testUserTimeZone() {
-    $edit['timezone'] = 'America/Santiago';
+    $edit['timezone'] = 'America/New_York';

This will fix the failure by avoiding the problem, but aren't we eliminating coverage? Shouldn't user DST tests test exactly all the edge cases of DST for users all over the world, not just the North American ones? The reason Chile is being used is that it is the same longitude as LA but opposite latitude, so it is a good case of southern hemisphere. If we're replacing it because Chile is not reliable, can we replace it with something else in the southern hemisphere?

I guess this is discussed in #3. If we go the route of hotfixing HEAD and then fixing our specialer-case DST support and testing in a followup major, let's file it now and put it in @todos in the patch.

FWIW, his test dates to #11077: Introduce Daylight Saving Time for Drupal which was committed in 2008.

mpdonadio’s picture

mpdonadio’s picture

Here is an idea that we can keep the locations, but test the same things. Once I see the results from #11 and #12, I'll post a writeup.

mpdonadio’s picture

Ok, here is essentially what happened.

In the 2017a zoneinfo file which the 7-dev PHP branches are using, local zone names started to be replaced with numeric designations, because of a change in one of the local time zone rules.

So

2007-03-10 02:00 CLST
2007-03-11 05:00 CLT
2007-03-21 00:00 CLT

became

2007-03-10 02:00 -03
2007-03-11 05:00 -04
2007-03-21 00:00 -04

This is what caused the test fail: the 'T' placeholder is generating a different value for 2017a.

So, if we want to keep these test cases, but effectively test the same thing, we can use the 'I' placeholder, which is 1 when DST is being observed, and 0 if not (see #12). That will keep the spirit of the test; in fact you could argue that this is better because we are explicitly testing DST not implicitly testing it through what the abbreviations mean.

I'll try to find the thread about this change on the TZ mailing list for reference.

If you want to see what zoneinfo is used in which version, you can checkout https://3v4l.org/3sEMa, but that doesn't have the dev tips.

The last submitted patch, 11: 2860663-test-only.patch, failed testing.

cilefen’s picture

Issue tags: +Triaged D8 critical

@alexpott, @catch, @cottser, @xjm and I considered this issue and agree this is suitably a critical priority bug test failures in HEAD interrupt the work of project contributors.

Mile23’s picture

Status: Needs review » Needs work

I can confirm that the patch in #12 applies, passes locally on MAMP with PHP 7.0 (not dev), and PHP 5.6.

Just one thing:

+++ b/core/modules/user/src/Tests/UserTimeZoneTest.php
@@ -29,7 +29,7 @@ public function testUserTimeZone() {
     DateFormat::load('medium')
-      ->setPattern('Y-m-d H:i T')
+      ->setPattern('Y-m-d H:i I')
       ->save();

There should be a comment explaining why we chose this pattern. Basically explaining #13.

Also out of scope here:

  • This should be a BTB test.
  • It shouldn't be in the user module. It should probably be in system, since it needs system_test module.
mpdonadio’s picture

Mile23’s picture

Status: Needs review » Reviewed & tested by the community

Diggit. LGTM. Unfortunately I don't have a way to repro locally, but the testbot looks happy.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed fc3d289 to 8.4.x and be0f298 to 8.3.x. Thanks!

Nice fix that preserves the existing coverage - mpdonadio++

  • alexpott committed fc3d289 on 8.4.x
    Issue #2860663 by mpdonadio, xjm, Mile23: UserTimeZoneTest fails on PHP...

  • alexpott committed be0f298 on 8.3.x
    Issue #2860663 by mpdonadio, xjm, Mile23: UserTimeZoneTest fails on PHP...
xjm’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

David_Rothstein’s picture

This is causing test failures in Drupal 7 too, so here's an issue to backport it: #2880700: [D7] UserTimeZoneFunctionalTest fails on recent versions of PHP 7 and 7.1