Closed (fixed)
Project:
Drupal core
Version:
8.5.x-dev
Component:
migration system
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
5 Jun 2017 at 17:15 UTC
Updated:
26 Jan 2018 at 19:29 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
heddnFor backwards compatibility, I think I'd like to see the 'timezone' setting map to both to/from. And this now an API change now it is in the code base, so I think this should at least start with 8.4.x
Comment #3
mpdonadioI am actually wondering now if not converting to UTC for FormatDate::transform() is a bug, since that is the implicit TZ for field storage.
Comment #4
ozinIf we work with date fields then we need to have date in the DATETIME_STORAGE_TIMEZONE also use DATETIME_DATETIME_STORAGE_FORMAT or DATETIME_DATE_STORAGE_FORMAT. I think make sense to set as defaut TZ DATETIME_STORAGE_TIMEZONE.
Comment #5
ozinComment #6
heddnPlease don't remove this parameter. It should remain for backwards compatibility. And the comment updated accordingly.
Please don't remove test coverage either. Add to the test coverage.
Stray changes.
Stray changes.
Comment #7
ozinComment #8
heddnI like the new to/from config options. But the previous timezone should be kept for BC and should map both to/from when set.
Comment #9
mpdonadioThis test case also need to remain unchanged. We just need to add a new data set to the provider to test different from/to time zones.
Comment #10
ozin@mpdonadio, @heddn thanks for reviewing, I've fixed yours remarks, please check.
Comment #11
ozinNot sure about Example usage, I've changed it according to new options?
Comment #12
heddnThis is deprecated and should be noted as such and explain what it does if it is used.
we still need to read this config option. It should be used as the to/from if no to/from is set. Remember, folks are already using this code base and have configuration setup to use this process plugin in its previous state. We need to support them using this, while still allowing new functionality for setting to/from as distinct parts.
Tests will likely fail, since we aren't using the timezone config option any more.
Comment #13
ozinHi @heddn, I run test and they are ok, also if I change code like this
then test with timezone option will fail, it returns "2004-12-19T04:19:42" when from/to timezone is set to America/Managua
Comment #14
taran2lHm, as far as I know, migration is experimental. I think this allows to break BC, if needed. Otherwise, we will have bloated codebase from the beginning.
Comment #15
mpdonadio#14, Migrate is experimental, but currently considered beta. These should retain BC whenever possible.
Comment #16
ozinIf we use $timezone as from/to when from/to are empty then we will need to adjust timezone test check #13
Comment #17
heddnWe should also trigger a warning when the deprecated method is used. See https://www.drupal.org/node/2856615.
I don't think we need to modify the existing tests at all, they should still continue to work as previously. What we should do is add more tests for a divergent TZ.
Comment #18
taran2lOkay, makes sense.
So, the next steps are:
Anything else?
Comment #19
heddnre #18, that sounds about right. I'd also add that this will need a draft CR.
Comment #20
volegerAdded few tests
Added deprecation info
Set default timezone during the installation process to make valid expected values.
Comment #21
taran2lPlease format message accordingly to the deprecation policy, see https://www.drupal.org/node/2856615
Using
$this->configuration['timezone']must trigger deprecation error, see https://www.drupal.org/node/2856615, however cannot find an example in core. Anyone to help?Also deprecation policy mentions
Any examples of such kind of unit test?
Comment #22
taran2lAnswering my own questions.
Good examples are
Drupal\Component\Render\FormattableMarkupand unit testDrupal\Tests\Component\Render\FormattableMarkupTestComment #23
volegerComment #24
taran2lChanges since last patch:
However, deprecation policy states:
Should we keep testing of timezone configuration key?
Comment #25
taran2lComment #26
heddnVery close. Just a couple small things. The testing for legacy that was added here seems sufficient to me.
Nit: this should read use to and from. Not just from.
Same applies here.
Comment #27
volegerComment #28
heddnLooks good.
Comment #29
mpdonadioWhy is this needed? We set a non-UTC zone in the test bootstrap (#2498619: Unit tests should use a default timezone other that UTC) to catch problems; running as UTC can mask subtle bugs.
Comment #30
ozinHi @mpdonadio
We did for cases where $to_timezone is not set, so we need to know expected default timezone, because for users is not clear which timezone is used in the test and which result is expected. I think for out test it is ok to have the UTC as default timezone.
Comment #31
mpdonadio#30, everything run through phpunit should have 'Australia/Sydney' as the default TZ since we set it in the bootstrap; some of the other test bases may set their own (need to double check this). Were you seeing something other that this? Or different results when run locally vs on testbot? If so, we may have a larger problem to address.
Comment #32
taran2lActually, comments by @mpdonadio uncovered interesting thing:
Old code wasn't doing any TZ conversion at all, because it was using the same tz
New patch is coming soon
Comment #33
mpdonadioIt's probably not accurate to say that no conversion is being done. The $timezone from the setting is being passed to the constructor, which is used when parsing the $value (and should match the TZ if output in the $toFormat) unless an explicit offset is used in $value. This is working as expected, but I want to add an additional test case.
Comment #34
mpdonadioDELETED
Comment #35
mpdonadioBlerg. Please hold off on posting patches. There is also a very subtle edge case bug here that I need to talk to @heddn about tomorrow.
Comment #36
mpdonadioWork in progress.
Comment #37
mpdonadioThis double checks the assumption that we are indeed 'Australia/Sydney' per the phpunit bootstrap. I haven't updated the new test cases to account for this, so tests will fail. Will post that next.
This is a really subtle quirk. -0600 is an offset, not a time zone; it just happens to be the offset for 'America/Managua'. We missed this in the original patch. Still digging into this a bit to make sure we haven't really uncovered a problem with an edge case in DateTimePlus.
Comment #38
mpdonadioOn these two, look at the fails in FormatDateTest::testDeprecatedTimezoneConfigurationKey(). It's easier to do
vendor/bin/phpunit --debug core/modules/migrate/tests/src/Unit/process/FormatDateTest.php
so you can see the expected/actual better. Not sure what is going on, esp when you compare against https://3v4l.org/0j6hK which behaves as I would expect, other than DateTime::createFromFormat() ignore the $timezone when it is part of the format.
Comment #42
taran2lI've checked everything couple times. And Drupal's code on top of DateTime behaves exactly as PHP internals.
\DateTimePlus::createFromFormat()ignores passed timezone, if passed time specifies a timezone (i.e. format contains). However, as you noticed-0600is not a timezone, but an offset. So, when using a legacy timezone code the expected output should be2004-12-19T10:19:42-06:00 -06:00.Drupal can try to fix this quirk in PHP behavior by setting a timezone if it's passed. However, it should be done in
DateTimePlus, not here (follow up issue?). Also, interesting question would be: what to do if offset doesn't match the timezone.Setting this to needs review.
Comment #43
mpdonadioThis issue is soft blocked on #2889814: DateTimePlus doesn't apply the correct time zone when converting a string with an offset right now. In that issue we either need to decide on whether to make the code match the advertised API docs, or update the API docs to match what the code actually does. Right now, I am leaning towards the later.
The problem with this is that it only partially tests the $timezone parameter. The FormatDate docs refer to the DateTimePlus docs, which leads us to the issue described above. At a minimum, I think the above method needs to be converted to use a provider to test various combinations of passing in an offset, a proper time zone, and not passing in anything for $timezone. Then once we resolve #2889814: DateTimePlus doesn't apply the correct time zone when converting a string with an offset we can either adjust the code and/or update the docs to be a bit more specific about how TZ conversion is handled.
Comment #44
taran2lI agree with not blocking this issue with the #2889814: DateTimePlus doesn't apply the correct time zone when converting a string with an offset, we have too much examples of such approach in core issue queue already (sadly).
We cover passing a proper timezone and not passing a timezone at all. I can add more tests with passing timezones that do not match offset in time value.
Comment #45
johnpicozziTested and appears to be working correct.
Comment #46
mpdonadioI'm confirming with the other datetime maintainer that we are OK with a doc fix for the DateTimePlus quirk (to align all of the docs to be consistent with how \DateTime really works).
So, I think we should
- Update testDeprecatedTimezoneConfigurationKey to use a provider to cover the different cases of zone name, offset, etc, to prevent any regressions.
- Double check the new parameters for the same thing
- Update the docs on this plugin to mention the quirk with the from timezone being ignored with the offset; the most popular date format will likely be the ISO one w/ the offset. This will prevent confusion.
Comment #47
heddnSomewhat novice tasks in #40. phpunit data provider, double checking parameters, updating docs. Yup. That all sounds do-able.
Comment #49
jofitzWe've waited 5 months for a novice that has never appeared so I'm jumping in.
Patch in #42 no longer applies. Re-rolled (before addressing @mpdonadio's comments in #46).
Comment #50
jofitzAdded data provider.
Comment #51
heddnSome feedback to ponder.
Nit. Can we get the point release updated here? Or just say in 8.4.x; I'm not recalling how we normally do that in core.
Let's check if to_timezone is set and use it before defaulting to NULL.
This is already fixed, so maybe we should remove this already?
I don't see any other examples of
@expectedDeprecationin core. Are we using$this->expectedException()instead?Comment #52
mpdonadioJust double checked, and yes `$this->expectedException()` is the preferred now.
Comment #53
jofitzAddressed points 1-3 in #51, but I disagree about point 4; @expectedDeprecation appears a few times in the codebase. If we were to use $this->setExpectedException() what would be the Exception Name?
Comment #54
jofitzRemoved a couple of lines from the patch included in error.
Comment #55
quietone commentedTook a brief look and it really nice to have the timezone here. Thanks everyone.
Points #51-2,3,4 have been addressed.
In #51-1 heddn queried if this should be deprecated in 8.4.0 or 8.4.x. The text hasn't changed, is this intended or an oversight?
Comment #56
jofitzI had misunderstood #51-1 and removed any mention of 8.4.0. I have now replaced it with 8.4.x (and in the @trigger_error too).
Comment #57
heddnAll feedback addressed. Ready to go.
Comment #59
jofitzRe-tested. Appears to have been a testbot fault. Back to RTBC.
Comment #61
jofitzRe-tested. Appears to have been a testbot fault (again). Back to RTBC.
Comment #63
heddnNon-related testbot failure.
Comment #65
heddnComment #66
heddnComment #67
heddnComment #68
larowlanAdded review credit for @heddn
Comment #70
larowlanCommitted 5b62f5d and pushed to 8.5.x
published change record
Comment #71
mpdonadioSince Migrate is still a beta experimental, is this 8.4.x eligible?
Comment #72
quietone commented@mpdonadio, I understand that the answer is no. A similar question was asked in #2796393: Migration process plugin not working with multiple source IDs, comment #38. In the next comment xjm responded,
.
where 'there' is this link, https://www.drupal.org/core/release-cycle-overview#current-development-c...