-
Notifications
You must be signed in to change notification settings - Fork 190
Rails 5.0 Redux #66
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
Rails 5.0 Redux #66
Conversation
Thanks for the pull request, and welcome! The Rails team is excited to review your changes, and you should hear from @sikachu (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
Summary of Previous Updates This PR:
(PRs with strikethroughs have been closed by their creators in deference to this one.) |
6098fee
to
b2768c9
Compare
I don't have time until this evening or later on next week to review and catch up on these PRs. I've pinged other core team members to take a look at this if they can do it sooner. Thanks for your patience! |
@sikachu Thanks! Fortunately, with all the closures, there aren't many PRs to look at! :-) |
logger.silence_logger do | ||
model = @@session_class.find_by_session_id(id) | ||
if !model | ||
id = generate_sid unless ActiveRecord.version.to_s.start_with?('4.') |
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.
Seems dangerous to compare this to the to_s in case that implementation changes. Not sure of best practice here but it might be better to go with ActiveRecord::VERSION::MAJOR == 4
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.
What do you mean by "in case the implementation changes"? I added the #to_s
because Rails.version
returns a String
and at the moment I was getting a Gem::Version
from AR.version
(Rails.version
was undefined in this scope).
Also, the new Gemspec
only indicates compatibility until prior to 5.1. I doubt they'd change the implementation of this function barring a newly discovered bug or security issues that somehow forced a specific return type that couldn't be cast to a string..
The fact that the start_with?
arg is suffixed with a dot should avoid ambiguity, I would think, even if it makes the solution hacky. That is, unless you're thinking of some case that I'm not (in which case please tell me).
Regardless though, ActiveRecord::VERSION::MAJOR == 4
is much cleaner, so assuming it works in all relevant Rails versions, I'll switch the code over to that tonight. Thanks for the suggestion!
I also reviewed this PR and in my opinion it doesn't worth to keep this gem backward compatible if the price is to have these if/else statements in the code. The session is loaded at each request and it will have some performance impact. But that might be just me. |
Hm. Most of the added if/thens are to the tests. There's 1 or 2 max extra comparisons run on each page load, I think, and these (will) compare two constant integers. That said, if the owners want the extra operations removed, I'm happy to oblige. |
|
Ok, so three from those two methods. Gems routinely have code that runs differently to ensure compatibility with various ruby/rails versions. In the end, these statements can't add up to more than a dozen or so CPU cycles per page load. I think we're starting to descend into really picayune territory at that point, given the speeds of contemporary processors. |
It is not easy to benchmark this in a real world scenario, but you can easily check how much slower something if you do an |
@gregmolnar, so I'm just getting a chance to look at this again now. Idea/potential compromise: I think the only (non-test) file where we have this backward-compatibility issue is Would you have any objections/concerns if there was a module that extended I think this might be the better solution all-around, especially if it's mutually agreeable. I don't think it's necessary to change the way the tests work, since speed optimization really isn't critical there and they're hardly slow to begin with. (I will still take @kddeisz's suggestion for how the versions are compared though.) |
c533c62
to
a1f8a56
Compare
@gregmolnar, please peruse the new changes at your leisure. They are in keeping with my most recent comment and your concerns (I hope/believe) about added CPU cycles. |
@sikachu, just a gentle reminder to glance at this if you get a chance (no one else on the core team seems to have). |
@sikachu, just another gentle reminder to look at this when you can. The second beta of Rails 5 was just released and the RC(s) as well as the initial release of Rails 5 are all tentatively scheduled within the month of February, so I'm anxious to get this reviewed, merged (after making any changes you may request) and released so that if any bugs crop up they can be addressed before people begin to use Rails 5 in production environments. |
gem 'actionpack', '>= 5.0.0.alpha', '< 5.1' | ||
gem 'activerecord', '>= 5.0.0.alpha', '< 5.1' | ||
gem 'railties', '>= 5.0.0.alpha', '< 5.1' | ||
gem 'rack', '>= 2.0.0.alpha', '< 3' |
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 can be ~> 2,0
now per RubyGems dependency list.
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.
Ruby Gems has ~> 2.x
. Perhaps it's equivalent to what I have now? Current release of rack
is still 2.0.0.alpha..
If ~> 2.x
isn't equivalent I would have to guess we need to point to the rack
github repo for now? I can check later on the equivalence, but ultimately your call as to what to do.
If we change the version requirement and don't point to github and it doesn't match the alpha release, we'll obviously get an error..
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 mistyped; Yeah, I wonder how/why it's picking up that dependency given it's a prerelease version. Let me experimenting with it a bit.
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.
Ok. Otherwise I can do that later. Just on a phone now. I doubt there will be any breaking changes between the alpha and the final 2.0.0 release (and we're running separate appraisals against both the master branch and the alpha release regardless) so I'm more concerned the rest of the code passes muster with you since I know your time is ultra limited.
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.
It works because 2.x
is a prerelease version, which comes before 2.0.*
. So yes, they are equivalent.
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.
Yep, I think I just learned this today that passing any string to the version requirement turns on the prerelease flag. So this is good.
- Closes rails#55 - Excises support for Rails 4 into new (conditionally included) mod. (This commit adapted in part from code by @gregmolnar.)
@sikachu So I went to implement your suggested change, but the best I could do (while keeping the legacy code in a separate file) was rename |
For the sake of documenting the change, this newest commit also contains a tiny tweak wherein I moved the |
@sikachu can this be merged/released then? |
Yep, I think this is good. Thank you for your patch. I'm going to merge your change, but I'm not going to cut the gem until the RC drops, as things could still change between beta2 and RC. I believe you can use Bundler to point the gem to this repository in the meantime to test the gem out. |
Fix compatibility issue with Rails 5.0
Sounds fair. (Though it should be noted that some of the commits in the PR have nothing to do with Rails 5.) In any case, it's only a couple of weeks, so I'm optimistic of my survival chances. :-p |
Also, merging this PR incorporated or made irrelevant 5 PRS and fully addressed 2 issues in this repo, so you may notice the queue is a little lighter now. :-) |
Thank you too, @sikachu! |
rails/activerecord-session_store#66 added rails 5 compatibility to the activerecord-session_store gem Without this, we were not able to support UI load balancing which requires session information be stored in the database. The restriction on the logging gem also had to be removed as it was causing a dependency issue versioned as it was. https://bugzilla.redhat.com/show_bug.cgi?id=1300018
Building and expanding on the great work @gregmolnar in PR #59 (resolving issue #55), this PR offers an improved implementation of Rails 5.0 compatibility that does not sacrifice backward compatibility with Rails versions in the 4.x series, resolves all deprecations/warnings related to the edge versions of Ruby and Rails
(with the exception of the deprecation addressed by #64), and is eminently ready to merge.Advice/ideas/questions/suggestions/etc welcome as always.