Closed (fixed)
Project:
Date
Version:
7.x-2.x-dev
Component:
Date API
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
21 Aug 2014 at 07:57 UTC
Updated:
22 May 2017 at 15:40 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
bugster commentedIf you don't pass a DateTimeZone object but the string timezone, it does not fail. DateObject also accepts the string version.
Guess the documentation is a bit misleading @param object $timezone.
Comment #2
jojonaloha commentedThis bug was introduced in #2261395: date_now is not respecting changes to timezone.
The reason is DateTimeZone doesn't have a __toString() method and the issue assumed it was always a string, even though the code comment suggests it is always an object.
Attached patch updates the code comment to better reflect the accepted parameters (same as the DateObject constructor), and fixes the bug by handling DateTimeZone objects when building the static variable name.
Comment #5
jojonaloha commentedRe-rolled patch attached.
Comment #6
Yurii Krysiuk commentedComment #7
Yurii Krysiuk commentedComment #9
moymilo commentedReviewed patch and manualy tested, looks like all work fine.
Comment #10
podarokPlease, use Early define pattern here
Example:
https://github.com/propeoplemd/cibox/wiki/PHP-JavaScript-SCSS-SASS-best-...
Comment #11
v1nk commentedComment #12
andypostshould be in else
if (instance) use getName()
else concatenation
Comment #13
v1nk commented@andypost
Removed else regarding @podarok comment. So how it should be right ?
Comment #15
podarokThanks @v1nk , #11 committed
Comment #16
jojonaloha commentedSorry, but #11 does not fix the issue, it just adds more code that suffers from the same problem. I think a test is needed.
Comment #17
StevenWill commentedThe patch from #5 fixed the issue for me.
Comment #18
podarok@jojonaloha can you please be more specific with a real example of the problem?
Thanks in advance
Comment #19
jojonaloha commentedAttached is a patch with a simpletest. This is my first time writing a SimpleTest test, and the tests are purely sanity checks, but do fail on the exception.
First patch contains only the test, second patch contains the test and a re-roll of my originally proposed fix.
Comment #22
jojonaloha commentedLet's try this again. This one should fail.
Comment #24
jojonaloha commentedThis one should pass.
Comment #26
sebastien m. commentedHere is an update of the #24 patch, but matching to date-7.x-2.9 release.
Hope it helps,
Thanks
Comment #29
jojonaloha commentedPatch #24 is still passing and the one to be used against 7.x-2.x-dev. Moving back to needs review.
Comment #30
sebastien m. commentedWhat about this issue ?
Comment #31
sebastien m. commented#26 is only provided to work on 7.x-2.9.
Comment #32
rosk0Assuming fixed because included in 7.x-2.10 release.
@Sebastien @Actualys Please create a follow up issue if you think that there is something to be fixed.
Comment #34
jojonaloha commentedThis is not fixed. If you applied the patch in #22, which only includes a test, and ran the tests you would see the exception described in this ticket still. See attached screenshot (against a fresh Drupal 7.54 install and Date 7.x-dev + the patch in #22).
I've also re-ran the tests with the patch in #24 and it passes. So #24 is still the patch to use to fix this issue. Please re-open this issue as it is not fixed, 7.x-2.10 only included the patch in #11 which still suffers from this bug, as does the latest dev version.
Comment #35
jojonaloha commentedI've opened #2880395: Fatal error: DateTimeZone could not be converted to string as a follow-up to this issue since this one is closed and I cannot re-open it.