Problem/Motivation
Currently, tests/core/bootstrap.php sets the timezone to be UTC because (from core/tests/bootstrap.php):
// Set the default timezone. While this doesn't cause any tests to fail, PHP
// complains if 'date.timezone' is not set in php.ini.
date_default_timezone_set('UTC');
UTC is not a good choice because it may mask problems. We run TestBot outside of the root directory to make sure we don't have any code that accidentally relies on or only works when the base URL is /. Choosing a TZ at the far edge is similar. Dates in are stored as UTC in the database. By choosing something close to the extreme, you will expose bugs that assume UTC b/c you often have day rollover when the TZ is applied to the value pulled from the database. Thought would need to go into whether a large positive value or a large negative value make more sense for finding potential bugs.
Proposed resolution
Set a timezone near the extreme to catch edge cases, and then fix any tests that break.
Remaining tasks
Do it.
User interface changes
N/A
API changes
N/A
Data model changes
N/A
Beta phase evaluation
Issue category | Task because we choose and change the default timezone used by unit tests, thus improving the test suite. |
---|---|
Issue priority | Normal because there is nothing broken at the moment. |
Unfrozen changes | Unfrozen because it only changes tests, more specific it changes the default timezone that all unit tests use. |
Prioritized changes | While not in the list of prioritized changes, the purpose of this is to prevent TZ related regressions and reduce the fragility of the testing system in general, where there are cases when tests pass or fail depending on when they run of where they run (TestBot vs Local). |
Disruption | None |
Comment | File | Size | Author |
---|---|---|---|
#38 | unit_tests_should_use_a-2498619-38.patch | 1.5 KB | Anonymous (not verified) |
#38 | interdiff-35-38.txt | 759 bytes | Anonymous (not verified) |
#35 | unit_tests_should_use_a-2498619-35.patch | 1.18 KB | Anonymous (not verified) |
#32 | unit_tests_should_use_a-2498619-32.patch | 1.19 KB | Anonymous (not verified) |
#28 | DE_2498619.patch | 473 bytes | Anonymous (not verified) |
Comments
Comment #1
mpdonadioI think the only failure will be in \Drupal\Tests\Core\Datetime\DateTest
Comment #5
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThe list of timezones is finite: http://us.php.net/manual/en/timezones.php
The db that is used can be consulted in
PECL's » timezonedb
, so I downloaded that and it has a header file where all possibilities are listed. There, you can see the exact values.These are values between 0 and 696076, so we definitely don't want to choose a negative value.
Then, looking at http://us.php.net/manual/en/timezones.others.php we can see that some timezones only are listed for backwards compatibility but shouldn't be used (e.g. WET and ZULU).
In conclusion, "Asia/Tokyo" as proposed in #1 is as good as any. And choosing something far away from the default UTC seems the sane thing to do. So let's keep that.
Comment #6
mpdonadioI'm not sure if those numbers really correspond to anything related to the offset. UTC, WET, Zulu, and GMT are all essentially the same thing (though WET would also include DST whenever that happens, and UTC and GMT are technically different but equivalent for most practical purposes as far as computers are concerned), but they all have different numbers in that header. I think they are indexes into the "database" that is in that header after the list of zones.
Comment #7
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedYes, but that would be the number that is internally used by PECL? I think I've misunderstood the thing to research completely...
Judging from "related to the offset", did you mean something more like:
If we look at a list of timezones, and we find:
Then the question is whether or not we want to use something more "edge case like", e.g.:
In that case I'm not sure if it would make a big difference in finding bugs, but it couldn't harm us to choose Pacific/Kiritimati (UTC+14:00). They are the first to reach a new day.
Fwiw, on the other far edge we have UTC-12:00, which (TIL) apparently is only used by ships.
Comment #16
mpdonadioYeah, I was talking about picking something closer to the international date line. We should probably run some tests to see what happens at UTC-11, UTC-12, UTC+11, UTC+12, UTC+13, and UTC+14. I honestly don't know what +-12, +13 and +14 will do; they are kinda super edge cases.
Comment #17
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedOk, so here goes:
UTC-12: seems not to have a readable alias
UTC-11: Pacific/Midway
UTC+11: Asia/Magadan
UTC+11:30: Pacific/Norfolk
UTC+12: Pacific/Auckland
UTC+12:45: Pacific/Chatham
UTC+13: Pacific/Tongatapu
UTC+14: Pacific/Kiritimati
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedWell, that's an interesting result.
The "extra fails" for Asia/Magadan are:
The other "extra fails" are similar.
It seems like the one we are looking for is "Asia/Magada" then?
Comment #26
mpdonadioThanks for doing those.
These are some odd results. I wonder if DST was also in play for those? Need to mull this one over and do some reading.
Comment #27
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedNone of these timezones use DST, however all of them experimented with the concept. Based on the info on timezoneconvertor.com and wikipedia.org, it seems that these changes at least correlate with the extra failures.
UTC-11: Pacific/Midway: DST ended on Wed 30-Nov-1983 with no actual change change -> no extra failure
UTC+11: Asia/Magadan: Moscow+08 (Moscow+07 after 2014-10-26) -> failure for 10 years and 100 years
UTC+11:30: Pacific/Norfolk: DST ended on Mon 1-Jan-1951, 18 minutes forward-> failure for 100 years
UTC+12: Pacific/Auckland: DST ended on Sun 5-Apr-2015, backward 1 hour -> no extra failure
UTC+12:45: Pacific/Chatham: DST ended on Sun 5-Apr-2015, backward 1 hour -> no extra failure
UTC+13: Pacific/Tongatapu: DST ended on Sun 27-Jan-2002, 1 hour backwards -> failure for 100 years
UTC+14: Pacific/Kiritimati: DST ended on Sun 1-Jan-1995 with no actual change -> failure for 100 years
I can reproduce these failures on my local machine. According to phpinfo(), it uses the system timezone information (so not the pecl timezonedb). If my timezone database version was build between 10/2014 and 04/2015 (not sure how to check), then the extra failures seem to be caused by these jumps in time.
So to get back to the question at hand, if we want edge case we could pick one with historical changes in DST and fix the test accordingly. However, I don't think fixing the failures would look very logical. Someone just browsing the test would definitely not get that. That makes me lean towards using "Pacific/Midway".
Note that all this commotion is caused by a single function call. Do we have use cases other than diff()?
As for the diff() function itself, we could also look to a timezone that uses DST? If we do that, we should expand the test coverage in datetest, to test all months in a certain year. We don't have that now.
Comment #28
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedThese are two examples that have DST:
- America/Los_Angeles: −08:00 (DST is −07:00)
- America/Denver: −07:00 (DST is −06:00)
Comment #31
mpdonadioComment #32
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedI don't think we want a super edge case, so I'd say we pick one with DST.
Comment #33
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedAdded beta eval.
Comment #34
mpdonadioLets go with something a little more extreme. I think Australia/Sydney would be good. UTC+10 and it participates in DST.
Comment #35
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedOk, sure!
Comment #36
mpdonadioPatch looks good, ran locally w/o any fails. IS and Beta Eval are updated and reflect why this change would be good for 8.0.x. This is good to go from my perspective.
Comment #37
alexpottIf we're going to do this then we need a comment to explain why Australia/Sydney.
Comment #38
Anonymous (not verified) CreditAttribution: Anonymous at XIO commentedFair enough. How about we borrow some text from the IS?
Comment #39
jhodgdonI was asked to take a look at the docs in the interdiff here. They look fine to me. Since that was the only reason the patch was set to Needs Work above, back to RTBC.
Comment #40
alexpottCommitted ef105e7 and pushed to 8.0.x. Thanks!
Thanks for adding the beta evaluation to the issue summary.