気づき #751
未完了PluginのRedmine本体バージョン間設計変更点収集(Redmine3.x/Rails4)
0%
説明
PluginのRedmine本体バージョン間設計変更点収集(Redmine3.x/Rails4)
Redmineバージョン間の変更により、結果的にPluginに不具合が発生し、
運用コストが増える事が良くあります。
そのようなロスを減らすため、対応に必要な情報を収集蓄積してみます。(試行)
対応方法が判れば、修正待ちではなく、自分で修正し動かすことも可能になる筈。
記入項目(案)
- 変更があったバージョン:項目名
- Redmine本体側変更内容(RAILS.Ruby変更含)
- Plugin側の変更方法、発生条件
- 対応サンプル
- 補足
関連資料¶
Rails アップグレードガイド
https://railsguides.jp/upgrading_ruby_on_rails.html
Redmine4時代のプラグイン開発
https://www.slideshare.net/douhashi/redmine4-redminetokyo-13
P55
Rails5で消えるAPI
before_filter after_filter
alias_method_chain
https://www.slideshare.net/naitoh1/redmine-260-300newfeature
P30 Redmine3プラグイン対応の壁
Rails3.2->Rails4.1
routing match廃止(RAILS4)
Redmine プラグインチュートリアル for V4.x系
https://qiita.com/rbtgr/items/12a1f33361700359e235
プラグイン作成時期(Rails Ver差異)により、新規作成時のコードも異なる。
主にRedmine2/3間のコード差異部分を解説した記事(Redmine4分は本家のプラグインチュートリアル参照)
Redmine3.4:Use safe_attributes for user preferences¶
本体側変更¶
Use safe_attributes for user preferences.
http://www.redmine.org/projects/redmine/repository/revisions/15688
Plugin側の変更方法、発生条件¶
user preferencesの設定に、safe_attributes を利用する。
対応サンプル¶
https://github.com/haru/redmine_theme_changer/issues/1
https://github.com/haru/redmine_theme_changer/commit/ab1b5f4f4193004845c74ac6ee81dd43c5dc66f3
補足¶
Redmine3.4:ActionView::Template::Error (undefined method `remote' for #<Hash:)¶
本体側変更¶
http://www.redmine.org/issues/26637
QueryFilter#remote is defined at source:tags/3.4.2/app/models/query.rb#L192 .
↑の変更箇所
http://www.redmine.org/projects/redmine/repository/revisions/16170
Don't preload all filter values when displaying issues/time entries
http://www.redmine.org/issues/24787
Possible values for all filters are currently preloaded and included in the view as JSON objects when listing issues or time entries.
This can be slow when there are many projects or users. Adding new filters (eg. #17720) would also add more overhead.
The values for a given filter should be loaded when a user adds the filter only, by using an AJAX request .
Plugin側の変更方法、発生条件¶
Redmine-backlogsにてこのエラーが発生していたが、
Redmine本体の下記部分を変更したところ動作した。(Redmine4.1ベース)
(この変更が適切かは確認していない。これで動いたという事実だけ。)
変更箇所
app/models/query.rb
def available_filters_as_json
変更内容
https://www.redmine.org/issues/26637#note-8
The variable filter is of type ActiveSupport::OrderedHash and keys should be accessed with [:key_name_as_symbol] and not as method name.
対応サンプル¶
補足¶
Redmine3.4: plugin view中の@settings¶
本体側変更:¶
Plugin側の変更方法、発生条件¶
対応サンプル¶
Configure -> Custom CSS always empty in Redmine 3.4.0
https://github.com/martin-denizet/redmine_custom_css/issues/13
I can put custom CSS into the text box into the configuration,
and it is saved to the database and included in every page.
But after saving, the text box is immediately displayed empty again.
plugins/redmine_custom_css/app/views/settings/_custom_css.html.erb
- <%= text_area_tag 'settings[css]', @settings[:css] >
+ <= text_area_tag 'settings[css]', settings['css'] %>
Redmine3.4:コアのメソッド修正対応例¶
コアのメソッド修正対応例
issue_count_by_group→result_count_by_group
本体側変更:¶
ソース修正箇所
Get the count by group from the query directly.
https://redmine.org/projects/redmine/repository/revisions/16387
2017-03-09 21:01
models/issue_query.rb からdef issue_count_by_group 削除
models/query.rb def result_count_by_group 追加
上記revisionにて、呼び出し箇所修正
Plugin側の変更方法、発生条件¶
queryの
issue_count_by_group→result_count_by_group
対応サンプル¶
https://github.com/Restream/redmine_custom_reports/issues/38
Redmine3.0:findの対応¶
本体側変更¶
Redmine本体ではなくRails側変更による
Plugin側の変更方法、発生条件¶
find→find_by、where、、
対応サンプル¶
https://github.com/haru/redmine_theme_changer/commit/f00b1a71dadd58f285b2a24d3f82acb1360488e7
https://github.com/tkusukawa/redmine_work_time/commit/19e3e110708fcdeaf77cca4eb24a851a96d4c6dc
Redmine3.0:attr_accessible¶
本体側変更:¶
Plugin側の変更方法、発生条件¶
modelにattr_accessible で定義追加する
対応サンプル¶
https://github.com/tkusukawa/redmine_work_time/commit/19e3e110708fcdeaf77cca4eb24a851a96d4c6dc
Redmine3.0:routing¶
本体側変更:¶
Plugin側の変更方法、発生条件¶
config/routes.rb routing情報 :via追加
対応サンプル¶
https://github.com/akiko-pusu/redmine_banner/commit/0b77e7fc094665ae841a862a34251b43f450fb26
奈良 裕記 さんが6年以上前に更新
以下未整理
(一部プラグインのみ影響と思われるものも含む。)
Fixes a error with IssueController change of Redmine r16387. refs #30
"NoMethodError: undefined method `issue_count_by_group'"
https://github.com/two-pack/redmine_xlsx_format_issue_exporter/commit/d4df8aa91dafb91b855f3d89608f766461bea994
Following commit of Redmine removed issue_count_by_group.
See http://www.redmine.org/projects/redmine/repository/revisions/16387
2017/1/29
Redmine updates to load associations of query results more efficiently.
https://github.com/two-pack/redmine_xlsx_format_issue_exporter/issues/29
See http://www.redmine.org/issues/24865
It effects this plugin and occurs error with exporting.
RAILS5対応
https://github.com/two-pack/redmine_xlsx_format_issue_exporter/issues/47
Redmine3.3
Redmine 3.3.0 - Internal error when trying to access new issues form from all issues list
https://github.com/akiko-pusu/redmine_issue_templates/issues/40
Redmine3.3.1
Failed in case change setting into false. (on Redmine3.3.1 or later)
https://github.com/akiko-pusu/redmine_issue_badge/issues/23
NoMethodError in SettingsController#plugin
undefined method `permit!' for nil:NilClass
修正
奈良 裕記 さんが約6年前に更新
Redmine3.4?:Rendering
Rendering bug after upgrading to Redmine 3.4.2
https://github.com/anteo/redmine_custom_workflows/issues/88
adminのplugin設定メニューが化ける
本体側変更:
Plugin側の変更方法、発生条件
init.rb の menu追加部分で、 caption に加えてhtml も指定する。
対応サンプル
https://github.com/picman/redmine_custom_workflows/commit/ce493be7712e7fe046733d5865509f6e166acb7d
奈良 裕記 さんが約6年前に更新
status_button Redmine3.4での問題点1
■現象
status_button インストール後、チケット編集時にエラー発生する。
■ログ
Completed 500 Internal Server Error in 140ms (ActiveRecord: 16.9ms)
NoMethodError (undefined method `each' for nil:NilClass):
plugins/status_button/lib/issues_status_hook.rb:19:in `update_issues'
plugins/status_button/lib/issues_status_hook.rb:10:in `controller_issues_edit_before_save'
lib/redmine/hook.rb:61:in `block (2 levels) in call_hook'
lib/redmine/hook.rb:61:in `each'
lib/redmine/hook.rb:61:in `block in call_hook'
lib/redmine/hook.rb:58:in `tap'
lib/redmine/hook.rb:58:in `call_hook'
lib/redmine/hook.rb:91:in `call_hook'
app/controllers/issues_controller.rb:557:in `block in save_issue_with_child_records'
app/controllers/issues_controller.rb:546:in `save_issue_with_child_records'
app/controllers/issues_controller.rb:168:in `update'
lib/redmine/sudo_mode.rb:63:in `sudo_mode'
■修正点
plugins/status_button/lib/issues_status_hook
def update_issues(issue)
setting[:status_assigned_to].each { |s, a|
↓
setting['status_assigned_to'].each { |s, a|
奈良 裕記 さんが約6年前に更新
status_button Redmine3.4での問題点2
■現象
プラグインの設定変更が表示されない。
画面上で入力した設定値は保存されているが、設定値が表示されない状況。
■修正点
plugins/status_button/app/views/settings/_status_button_settings.html.erb
From
@settings[:status_assigned_to]
To
settings['status_assigned_to']
[root@32060 settings]# diff _status_button_settings.html.erb.old _status_button_settings.html.erb
3c3
< @settings = {:status_assigned_to => {}} unless @settings[:status_assigned_to] %>
---
@settings = {:status_assigned_to => {}} unless settings['status_assigned_to'] %>
8c8
< <%= check_box_tag 'settings[check_all_status]', true, @settings[:check_all_status] %>
---
<%= check_box_tag 'settings[check_all_status]', true, settings['check_all_status'] %>
12c12
< <%= check_box_tag 'settings[add_watcher]', true, @settings[:add_watcher] %>
---
<%= check_box_tag 'settings[add_watcher]', true, settings['add_watcher'] %>
25c25
< options_for_select(options, @settings[:status_assigned_to][status.id.to_s]),
---
options_for_select(options, settings['status_assigned_to'][status.id.to_s]),