-
Notifications
You must be signed in to change notification settings - Fork 902
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
Drop support for rails 3 #898
Conversation
What do you think, Ben? @batter |
Please merge #896 before this, in case of conflict. |
In #895, Sean asked: > .. since it looks like the next version is planned to be 6.0.0, how would > you feel about dropping support for Rails 3 in that version? It has > reached end of life, meaning it no longer receives security patches. We > don't recommend that gem authors continue to support it. To which, I responded: > We could continue maintaining PT 5 if we had to, so I think it's > fine to drop support for rails 3 in PT 6. If Ben agrees, I'd be > happy to make that change. I'll just update the gemspec and drop > testing support, for starters. We can clean up the conditionals in > the code over time.
c359b2d
to
94bf3e0
Compare
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as paper-trail-gem#898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as paper-trail-gem#898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as paper-trail-gem#898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as paper-trail-gem#898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
Ben, can you please weigh in on this? Thanks. @batter |
Initially I was reluctant to endorse this since it didn't seem like there was a great reason to drop support for ActiveRecord 3, however, after looking more closely at the code in #899, it appears that the functionality and supporting methods for retrieving diffs between objects changed in memory vs the database via As both you and @sgrif noted, since we're looking to merge these changes to support AR 5.1 more effectively in before releasing PaperTrail 6, this seems like the appropriate time to do it, as major releases are the appropriate time to make incompatible API changes and drop backwards compatibility as per semantic versioning standards. In addition, it seems like that it could cause significant complexity to attempt to continue supporting both AR 3 and future versions. I also agree that we could continue backporting some bugfixes (or even functionality) to PT 5 if significant and worthy alterations were found. I'm always in support of changes that reduce complexity. TLDR - I was reluctant initially but I think it's appropriate since it reduces complexity going forward and makes it easier to support future versions of ActiveRecord. |
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as #898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
This updates the code to work with Rails 5.1.0.alpha, as of commit rails/rails@1bdc395. The biggest change was to call the new methods provided by `ActiveRecord::Dirty` when needed. In the next version of Rails after 5.1, dirty will be "cleared" before after_save callbacks are run. This means that code in an after_save callback will behave the same as if it was run after calling `.save`. Since the concept of "changed" is fairly nebulous, two new method sets were introduced with names that specify whether they're operating on changes from what we think is in the database to what's in memory, or the changes that were just persisted. Paper trail will now use the latter set of methods if available and called from an after_ callback. There were a few other unrelated changes required to get this working on master. The first was the change from `appear_as_new_record` to `appear_as_unpersisted`. This was due to a single test that broke as a result of rails/rails@c546a2b where reifying a version with a nil has_one association was persisting the change to the foreign key. I am actually unsure how that commit caused the problem (or more specifically, I'm unsure how it was passing before). However, as best as I can tell, the purpose of `appear_as_new_record` was to attempt to prevent the callbacks in `AutosaveAssociation` (which is the module responsible for persisting foreign key changes earlier than most people want most of the time because backwards compatibility or the maintainer hates himself or something) from running. By also stubbing out `persisted?` we can actually prevent those. A more stable option might be to use `suppress` instead, similar to the other branch in `reify_has_one`. The remaining breakage was due to the `Song` model relying on internals that have changed from underneath it. From Rails 5 onwards there is a public API available to do what it wants, so we can just use that instead. This commit is not expected to pass on Rails 3, as paper-trail-gem#898 makes it sound like support might be dropped. If this needs to be ammended to support Rails 3, I will do so, but I will also grumble very loudly about it.
In #895, Sean asked:
To which, I responded: