This project is archived and is in readonly mode.
ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map
-
Rohit Arondekar
- State changed from new to open
- Assigned user set to Prem Sichanugrist (sikachu)
-
Prem Sichanugrist (sikachu)
- State changed from open to incomplete
- Assigned user changed from Prem Sichanugrist (sikachu) to Santiago Pastorino
This patch does apply on
master, but the test fails.I can see the code in
master(in#lookup) that it will create the time zone if it's not exists in the mapping. I don't know that this is the intended behavior or not.I'm assigning this to Santiago Pastorino to have a look on this one.
By the way, in your opinion do you think it would be better for Rails to update the
tzinfogem to require at least 0.3.22 then? -
Leigh Caplan
I've included a test that passes in master... I just stubbed out the lookup method to return nil, to ensure that we're not explicitly relying on the TZInfo to do the right thing. And I don't think that storing nil values in @zones_map is the intended behavior. If it is, then it was probably done without understanding how it can break other time zone functionality.
For a little background, our app had some calendar events with time zones which had been accidentally sanitized, so the ampersands were HTML encoded. The current TZInfo behavior is correct, and if it was included in Rails 2.3.8, an exception would've been raised as soon as we tried to use the bad time zone. Unfortunately, what actually happened was that some of our backends fielded these calendar event requests as soon as they started up, and nil values "poisoned" the @zones_map. The next time someone tried to draw a time zone menu, we got an exception while trying to sort @zones_map. As you can imagine, this was a really difficult issue to track down, and it required that we roll back to 2.3.5 until the problem was sorted out.
FWIW, I think it's a great idea to update the
tzinfodependency to 0.3.22, but only because it gives us the latest tzdata. I'm pretty sure this behavior is the same in 0.3.16. -
Repository
- Importance changed from to Low
(from [97a92a4cfddf819357ca09b4a91a5937b044e4d8]) test that unknown zones don't store mapping keys
[#4942 ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/97a92a4cfddf819357ca09b4a91a59... -
Repository
- State changed from incomplete to committed
(from [b2633f9f9323f5d5eca1c2c94bb7ae88ad276cda]) Don't store incorrect values in zones_map
[#4942 ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map state:committed]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/b2633f9f9323f5d5eca1c2c94bb7ae... -
Santiago Pastorino
- Milestone set to 2.3.9
- State changed from committed to open
I will push a backport in a couple of minutes
-
Santiago Pastorino
- Assigned user changed from Santiago Pastorino to José Valim
-
Repository
- State changed from open to committed
(from [70af7efa16fa429f7bbc3acfc1c587c8655edf7e]) Don't store incorrect values in zones_map backport
[#4942 ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map state:committed]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/70af7efa16fa429f7bbc3acfc1c587... -
Repository
(from [80473e035a166d270a204aedaf01c2b80415b8e4]) test that unknown zones don't store mapping keys
[#4942 ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map]
Signed-off-by: Santiago Pastorino santiago@wyeworks.com
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/80473e035a166d270a204aedaf01c2... -
Leigh Caplan
Hey guys,
The 2.3 backport patch causes some additional unexpected behavior. It will never use the stored value in zones_map, and create a new TimeZone object each time #[] is invoked. Here's a patch to fix it.
-
José Valim
Could you please include tests in the patch? Thanks!
-
Santiago Pastorino
Leigh your patch is ok but it's a performance improvement.
- if tz = lookup(arg) - zones_map[arg] ||= tzFrom this code you're removing note the ||=, if zones_map[arg] have something it will be returned before the assignation to tz. But i agree we can check zones_map[arg] before to not do some unneded lookups.
So José that doesn't need a test, all the things we need to test are already tested.
-
Leigh Caplan
Here's a patch with both the lookup fix and a test. I couldn't think of any way other than mocking out the call to
find_tzinfoseeing as object apparently doesn't get stored anywhere. If someone else has any better ideas, I'd be glad to hear them. -
Leigh Caplan
- Assigned user changed from José Valim to Santiago Pastorino
-
Santiago Pastorino
- Assigned user changed from Santiago Pastorino to José Valim
- State changed from committed to verified
We don't need this test for my it's ok to apply this patch
https://rails.lighthouseapp.com/projects/8994/tickets/4942/a/579448...
-
Repository
- State changed from verified to resolved
(from [78e4d88c7071c633ee1eb68f49b90719aa198eaa]) Rewrite the clause to pluck the existing value from zones_map before performing a lookup. [#4942 ActiveSupport::TimeZone.[] incorrectly stores bogus values in zones_map state:resolved]
Signed-off-by: José Valim jose.valim@gmail.com
http://github.com/rails/rails/commit/78e4d88c7071c633ee1eb68f49b907... -
plind
Does this solve this problem: http://stackoverflow.com/questions/3027704/nomethoderror-for-time-z... ?
-
Leigh Caplan
@plind yes, sorry I didn't see this for a month. This resolves the issue.
