Skip to content
This repository has been archived by the owner on Apr 10, 2023. It is now read-only.

Fix Redmine 5.0 / Rails 6.1 / Zeitwerk #233

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

taikii
Copy link
Contributor

@taikii taikii commented Sep 18, 2022

  1. Make to can load hook with Zeitwerk
  2. Replace with update method
    update_attributes was removed on Rails 6.1.
  3. remove controller_issues_new_after_save hook
    controller_issues_new_after_save raises "ActiveRecord::StaleObjectError Attempted to update a stale object: Issue." in Rails 6.1.
    This exception can be suppressed by calling reload first, but the existence of this method seems unnecessary.
    Because it seems that after_save does not call reload from Redmine 4.0.

Regards

@taikii
Copy link
Contributor Author

taikii commented Sep 24, 2022

Added fixes for REST API.

@PowerKiKi
Copy link
Collaborator

I get the following error when navigating to /settings/plugin/redmine_tags. Do you have the same one ? Are you able to fix it ?

Started GET "/settings/plugin/redmine_tags" for 127.0.0.1 at 2022-09-26 14:49:38 +0200
Processing by SettingsController#plugin as HTML
  Parameters: {"id"=>"redmine_tags"}
   (0.8ms)  SELECT MAX(`tokens`.`updated_on`) FROM `tokens` WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = '5997798e9477f8416a08486a447021869079a300' AND `tokens`.`action` = 'session'
  ↳ app/models/user.rb:479:in `verify_session_token'
  Token Update All (8.6ms)  UPDATE `tokens` SET `tokens`.`updated_on` = '2022-09-26 14:49:38' WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = '5997798e9477f8416a08486a447021869079a300' AND `tokens`.`action` = 'session'
  ↳ app/models/user.rb:483:in `verify_session_token'
   (0.7ms)  SELECT MAX(`settings`.`updated_on`) FROM `settings`
  ↳ app/models/setting.rb:280:in `check_cache'
  User Load (0.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`type` = 'User' AND `users`.`status` = 1 AND `users`.`id` = 1 LIMIT 1
  ↳ app/controllers/application_controller.rb:117:in `find_current_user'
  Current user: admin (id=1)
  Rendering layout layouts/admin.html.erb
  Rendering settings/plugin.html.erb within layouts/admin
  Rendered plugins/redmine_tags/app/views/tags/_general.html.erb (Duration: 2.6ms | Allocations: 1036)
  Rendered plugins/redmine_tags/app/views/tags/_manage_tags.html.erb (Duration: 17.8ms | Allocations: 3811)
  Rendered common/_tabs.html.erb (Duration: 22.4ms | Allocations: 5278)
  Rendered plugins/redmine_tags/app/views/tags/_settings.html.erb (Duration: 23.0ms | Allocations: 5410)
  Rendered settings/plugin.html.erb within layouts/admin (Duration: 24.7ms | Allocations: 5729)
  Rendered layout layouts/admin.html.erb (Duration: 25.0ms | Allocations: 5798)
Completed 500 Internal Server Error in 53ms (ActiveRecord: 10.8ms | Allocations: 8895)


  
ActionView::Template::Error (undefined method `available_tags' for Issue:Class):
    1: <% tags = Issue.available_tags %>
    2: <% unless tags.empty? %>
    3:   <table class="list issues">
    4:     <thead>
  
plugins/redmine_tags/app/views/tags/_manage_tags.html.erb:1
app/views/common/_tabs.html.erb:21
app/views/common/_tabs.html.erb:20:in `each'
app/views/common/_tabs.html.erb:20
app/helpers/application_helper.rb:498:in `render_tabs'
plugins/redmine_tags/app/views/tags/_settings.html.erb:17
app/views/settings/plugin.html.erb:6
app/views/settings/plugin.html.erb:4
lib/redmine/sudo_mode.rb:61:in `sudo_mode'
127.0.0.1 - - [26/Sep/2022:14:49:38 CEST] "GET /settings/plugin/redmine_tags HTTP/1.1" 500 244533
http://localhost:3000/admin/plugins -> /settings/plugin/redmine_tags

@PowerKiKi
Copy link
Collaborator

I merged the migration to GitHub Actions in #236. It is failing for now, but if you rebase this PR on top of master, then the tests should eventually pass.

controller_issues_new_after_save raises "ActiveRecord::StaleObjectError Attempted to update a stale object: Issue." in Rails 6.1.
This exception can be suppressed by calling reload first, but the existence of this method seems unnecessary.
Because it seems that after_save does not call reload from Redmine 4.0.
@taikii
Copy link
Contributor Author

taikii commented Sep 26, 2022

@PowerKiKi Wow, great job!
"Run Redmine rake tasks" passed, but I got errors in the test...

@PowerKiKi
Copy link
Collaborator

@taikii if you are able to get this working, I will merge it.

However, I won't spend more time myself on this. I will migrate to https://github.com/AlphaNodes/additional_tags. It can migrate data from redmine_tags transparently when installing, and it already supports Redmine 5.

@PowerKiKi PowerKiKi mentioned this pull request Nov 3, 2022
@taikii
Copy link
Contributor Author

taikii commented Nov 5, 2022

@PowerKiKi It seems the error in CI is not caused by this PR. Sorry I don't have time to investigate the error.
Also I'm using my branch and don't see any problems.

@PowerKiKi
Copy link
Collaborator

Fair enough 👍

Maybe someone else can help fix the CI, and then I'll merge it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants