-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent server blow up when iterating over TimeWithZone Range #11474
Conversation
@pixeltrix can you take a look? |
I think I'd rather override |
Reworked as @pixeltrix suggested. |
@bogdan you might need to do Also you probably need to require 'active_support/core_ext/object/acts_like' as one of the Active Model tests is failing with a |
@pixeltrix made all changes you've suggested. |
|
||
def step_with_time_with_zone(n = 1, &block) | ||
ensure_iteration_allowed | ||
step_withot_time_with_zone(n, &block) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be step_without_time_with_zone
😉
Prevent server blow up when iterating over TimeWithZone Range
Prevent server blow up when iterating over TimeWithZone Range
@bogdan thanks - sorry for the delay |
I would backport it to 3.2 as it is critical issue when people migrate from 1.8 to 1.9. But it is for you to decide. |
Changelog entry for pr #11474
Changelog entry for pr #11474 Conflicts: activesupport/CHANGELOG.md
@pixeltrix @bogdan The merge of this has broken iteration over I can monkey patch for now - my solution is to raise only if it |
@mjtko I personally was against those So, I agree. |
@bogdan Yeah, I was looking for your original patch pre- |
@mjtko didn't find it with |
😧 I didn't realise that you can't iterate over |
@pixeltrix sure. Its quite strange that ruby iterates over |
Any news on this problem? Just had to monkey patch the Range Class 😟 |
@madwire do you mean the original issue or that |
@pixeltrix sorry I mean the |
In #11474 we prevented TWZ ranges being iterated over which matched Ruby's handling of Time ranges and as a consequence `include?` stopped working with both Time ranges and TWZ ranges. However in ruby/ruby@b061634 support was added for `include?` to use `cover?` for 'linear' objects. Since we have no way of making Ruby consider TWZ instances as 'linear' we have to override `Range#include?`. Fixes #30799.
In #11474 we prevented TWZ ranges being iterated over which matched Ruby's handling of Time ranges and as a consequence `include?` stopped working with both Time ranges and TWZ ranges. However in ruby/ruby@b061634 support was added for `include?` to use `cover?` for 'linear' objects. Since we have no way of making Ruby consider TWZ instances as 'linear' we have to override `Range#include?`. Fixes #30799.
Iterating over a Range of Time is impossible in ruby:
But it is still possible with ActiveSupport::TimeWithZone
In good case current process is stuck with IO.
In worth case server disk space blow up with production.log file.
This was a huge problem for us and caused a down time on our production app.
In order to prevent that we can generate #succ deprecation warning only once.
And remove TimeWithZone#succ as soon as Time#succ will be removed.