clear-code / redmine_full_text_search

Full text search for Redmine
MIT License
63 stars 24 forks source link

500 error occurs when create ticket #55

Closed yassan closed 6 years ago

yassan commented 6 years ago

チケット作成時に、500エラーが必ず発生してしまいます。

チケット作成ボタンを押下すると以下のエラーが出ていました。

Started POST "/redmine/projects/test-niko/issues" for 10.xx.xx.xx at 2018-08-27 12:39:33 +0900
Processing by IssuesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"C6H7jdvLqyoLmQvveNoMCIm1Fs+9w44mwVx6ktWeJPBft5y3MkZyF22IKUoRjmTL376pCwEuVA62Z2xHt17nig==", "form_update_triggered_by"=>"", "issue"=>{"is_private"=>"0", "tracker_id"=>"6", "subject"=>"チケット作成テスト", "description"=>"", "status_id"=>"1", "priority_id"=>"4", "assigned_to_id"=>"157", "parent_issue_id"=>"", "start_date"=>"2018-08-27", "due_date"=>"", "estimated_hours"=>"", "done_ratio"=>"0", "watcher_user_ids"=>[""]}, "issue_template"=>"", "template_search_filter"=>"", "pwfmt_select_format"=>"textile", "pwfmt"=>{"formats"=>{"issue_description"=>"textile"}}, "was_default_status"=>"1", "commit"=>"作成", "project_id"=>"test-niko"}
  Current user: test (id=157)
  Rendered mailer/_issue.text.erb (9.4ms)
  Rendered mailer/issue_add.text.erb within layouts/mailer (16.4ms)
  Rendered mailer/_issue.html.erb (3.0ms)
  Rendered mailer/issue_add.html.erb within layouts/mailer (9.5ms)
Redirected to http://10.xx.xx.xx/redmine/issues/248957
Completed 302 Found in 612ms (ActiveRecord: 171.0ms)
Started GET "/redmine/issues/248957" for 10.xx.xx.xx at 2018-08-27 12:39:34 +0900
Processing by IssuesController#show as HTML
  Parameters: {"id"=>"248957"}
  Current user: test (id=157)
  Rendered issues/_action_menu.html.erb (11.0ms)
  Rendered plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb (258.9ms)
  Rendered issues/show.html.erb within layouts/base (336.2ms)
Completed 500 Internal Server Error in 439ms (ActiveRecord: 45.3ms)

ActionView::Template::Error (undefined method `display_score?' for #<#<Class:0x00007f1456e075d8>:0x00007f144c572dc8>
Did you mean?  display_comments_tree):
    1: <% if display_score? %>
    2:   <%
    3:   duration = nil
    4:   ActiveSupport::Notifications.subscribe("groonga.similar.search") do |*args|
  plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb:1:in `_plugins_full_text_search_app_views_issues_full_text_search__view_issues_show_description_bottom_html_erb__336950841572077697_69862578822200'
  lib/redmine/hook/view_listener.rb:59:in `block (2 levels) in render_on'
  lib/redmine/hook/view_listener.rb:57:in `map'
  lib/redmine/hook/view_listener.rb:57:in `block in render_on'
  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:96:in `call_hook'
  app/views/issues/show.html.erb:97:in `_app_views_issues_show_html_erb___2971280503261266164_69862578453100'
  app/controllers/issues_controller.rb:106:in `block (2 levels) in show'
  app/controllers/issues_controller.rb:99:in `show'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Backで戻った後にチケット一覧を見ると、チケットは作成出来ているようです。 ただし、そのチケットを参照しようとすると以下の500エラーが出て、表示できません。

Started GET "/redmine/issues/248957" for 10.xx.xx.xx at 2018-08-27 13:14:17 +0900
Processing by IssuesController#show as HTML
  Parameters: {"id"=>"248957"}
  Current user: test (id=157)
  Rendered issues/_action_menu.html.erb (7.7ms)
  Rendered plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb (288.8ms)
  Rendered issues/show.html.erb within layouts/base (331.0ms)
Completed 500 Internal Server Error in 384ms (ActiveRecord: 37.1ms)

ActionView::Template::Error (undefined method `display_score?' for #<#<Class:0x00007f1456e075d8>:0x00007f144e3ef080>
Did you mean?  display_comments_tree):
    1: <% if display_score? %>
    2:   <%
    3:   duration = nil
    4:   ActiveSupport::Notifications.subscribe("groonga.similar.search") do |*args|
  plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb:1:in `_plugins_full_text_search_app_views_issues_full_text_search__view_issues_show_description_bottom_html_erb__336950841572077697_69862578822200'
  lib/redmine/hook/view_listener.rb:59:in `block (2 levels) in render_on'
  lib/redmine/hook/view_listener.rb:57:in `map'
  lib/redmine/hook/view_listener.rb:57:in `block in render_on'
  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:96:in `call_hook'
  app/views/issues/show.html.erb:97:in `_app_views_issues_show_html_erb___2971280503261266164_69862578453100'
  app/controllers/issues_controller.rb:106:in `block (2 levels) in show'
  app/controllers/issues_controller.rb:99:in `show'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

実行環境はこちらです。 Redmine 3.4.3 redmine_full_text_search v0.7.3 PGroonga 2.1.1 ruby 2.3.7p456 Rails 4.2.8 PostgreSQL 10.5 CentOS Linux release 7.5.1804 (Core)

PostgreSQLは公式のyumリポジトリを追加してインストール。 PGroongaもyumでインストール。

また、Redmineの状態は以下です。

Environment:
  Redmine version                3.4.6.stable.17473
  Ruby version                   2.3.7-p456 (2018-03-28) [x86_64-linux]
  Rails version                  4.2.8
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.7.14
  Git                            2.16.4
  Filesystem                     
Redmine plugins:
  clipboard_image_paste          1.12
  full_text_search               0.7.2
  periodictask                   3.2.1
  redmine_banner                 0.1.2
  redmine_checklists             3.1.11
  redmine_default_custom_query   1.3.0
  redmine_favorite_projects      2.0.3
  redmine_issue_badge            0.0.6
  redmine_issue_templates        0.2.0
  redmine_local_avatars          1.0.3
  redmine_logs                   0.1.1
  redmine_niko_cale              1.1.3-dev
  redmine_people                 1.3.2
  redmine_persist_wfmt           1.1.0
  redmine_pivot_table            0.0.6
  redmine_theme_changer          0.3.1
  redmine_wiki_extensions        0.8.1
  redmine_wiki_lists             0.0.9
  redmine_work_time              0.3.4
  sidebar_hide                   0.0.8
  view_customize                 1.1.4

また、プラグインの設定で「スコアを表示」はOFFの状態です。

他のプラグインで display_score を使用しているものがあるのか確認したところ、 以下の結果となり、他プラグインには存在しません。

# find plugins -type f | xargs grep display_score
バイナリファイル plugins/full_text_search/.git/objects/pack/pack-80b3d37bafd17610dc6c6306f653c0132b46ab69.pack に一致しました
plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb:<% if display_score? %>
plugins/full_text_search/app/views/issues/full_text_search/_view_issues_show_description_bottom.html.erb:    <% if display_score? %>
plugins/full_text_search/app/views/search/index.html.erb:    <% if display_score? %>
plugins/full_text_search/app/views/search/index.html.erb:<%- if display_score? %>
plugins/full_text_search/app/views/settings/_full_text_search.html.erb:  <%= label_tag("settings[display_score]", l(:label_full_text_search_display_score)) %>
plugins/full_text_search/app/views/settings/_full_text_search.html.erb:  <%= check_box_tag("settings[display_score]", "1", settings.present? && settings["display_score"] == "1") %>
plugins/full_text_search/config/locales/en.yml:  label_full_text_search_display_score: Display score
plugins/full_text_search/config/locales/ja.yml:  label_full_text_search_display_score: スコアを表示
plugins/full_text_search/init.rb:  settings default: { display_score: "0" }, partial: "settings/full_text_search"
plugins/full_text_search/lib/full_text_search/hooks/settings_helper.rb:      def display_score?
plugins/full_text_search/lib/full_text_search/hooks/settings_helper.rb:        setting["display_score"] == "1"
akiko-pusu commented 6 years ago

@yassan こんにちは。 昨年、このエラーメッセージに近い状況が発生したので、何かのお役にたてればと思ってリンクさせていただきます。

Ref. https://github.com/two-pack/redmine_xlsx_format_issue_exporter/issues/50

上記の場合は、redmine_xlsx_format_issue_exporter というプラグインと、full_text_searchの双方でIssuesControllerに対するバッチを当てており、後から読み込まれたredmine_xlsx_format_issue_exporter のほうが勝ってしまい、full_text_searchで定義したメソッドが無い、という症状が出ていました。

同居しているプラグインで、redmineのコントローラに対してパッチを当てているもの(IssuesControllerあたり)について、該当するものがないか、あればそれだけ取り外してどうなるか、というのも確認につながるかなと思います。

iquiw commented 6 years ago

I previously got the same error with redmine_persist_wfmt (https://github.com/clear-code/redmine_full_text_search/issues/36#issuecomment-324549675).

I am no longer using redmine_persist_wfmt as redmine_full_text_search is more valuable to me.

yassan commented 6 years ago

@iquiw Thank you, good information :+1: So, It was the same case... But, I want to use redmine_persist_wfmt( https://github.com/pinzolo/redmine_persist_wfmt/ ).

@akiko-pusu 情報ありがとうございます。そんな挙動もあるんですね。とても参考になりました。上にも書いてますが、プラグイン外したら、チケット作成出来るようになったので同じ原因のようです。

redmine_persist_wfmt - issues_controller_patch.rb#L21

akiko-pusu commented 6 years ago

@yassan I found the related issue at redmine.org and commented. Ref. https://www.redmine.org/issues/28133

akiko-pusu commented 6 years ago

Hi, I could reproduce this issue and made tiny workaround considering above comment. I don't know if this patch is effective with other database (such as MySQL, MariaDB and production env).

diff --git a/init.rb b/init.rb
index cc88405..f651997 100644
--- a/init.rb
+++ b/init.rb
@@ -2,6 +2,7 @@ require_dependency "full_text_search/hooks/search_index_options_content_bottom_h
 require_dependency "full_text_search/hooks/issues_show_description_bottom_hook"
 require_dependency "full_text_search/hooks/similar_issues_helper"
 require "full_text_search/searcher"
+require_dependency "full_text_search/hooks/search_helper"

 Redmine::Plugin.register :full_text_search do
   name 'Full Text Search plugin'
@@ -31,5 +32,4 @@ Rails.configuration.to_prepare do
   Journal.include(FullTextSearch::SimilarSearcher::Model)
   SearchHelper.prepend(FullTextSearch::Hooks::SearchHelper)
   SearchController.prepend(FullTextSearch::Hooks::ControllerSearchIndex)
-  IssuesHelper.include(FullTextSearch::Hooks::SimilarIssuesHelper)
 end
diff --git a/lib/full_text_search/hooks/similar_issues_helper.rb b/lib/full_text_search/hooks/similar_issues_helper.rb
index ac7d729..b8ce0d6 100644
--- a/lib/full_text_search/hooks/similar_issues_helper.rb
+++ b/lib/full_text_search/hooks/similar_issues_helper.rb
@@ -22,3 +22,4 @@ module FullTextSearch
     end
   end
 end
+IssuesHelper.prepend(FullTextSearch::Hooks::SimilarIssuesHelper)

If above patch is applied IssuesHelper's ancestors and methods are following:

irb(main):004:0* IssuesHelper.ancestors
=> [FullTextSearch::Hooks::SimilarIssuesHelper, FullTextSearch::Hooks::SettingsHelper, IssuesHelper, Redmine::Export::PDF::IssuesPdfHelper, ApplicationHelper, Redmine::Helpers::URL, Redmine::Hook::Helper, Redmine::Themes::Helper, Redmine::SudoMode::Helper, Redmine::Pagination::Helper, GravatarHelper::PublicMethods, Redmine::I18n, Redmine::WikiFormatting::Macros::Definitions]

irb(main):005:0> IssuesHelper.instance_methods
=> [:render_similar_issues, :display_score?, :render_issue_tooltip, :issue_list, :grouped_issue_list, :issue_heading, :render_issue_subject_with_tree, :render_descendants_tree, :render_issue_relations, :issue_estimated_hours_details, :issue_spent_hours_details, :bulk_edit_error_messages, 

.... snip ...

It seems forum messages and comments against news article are not searched correctly. (Sorry I don't know much about this plugin's feature...)

Hope any help.

Env info

1 vagrant@ubuntu-xenial:~/work/redmine-3.4.6⟫ bin/rake about
About your application's environment
Rails version             4.2.8
Ruby version              2.3.1-p112 (x86_64-linux-gnu)
RubyGems version          2.5.2.1
Rack version              1.6.10
Middleware                Rack::Sendfile, Rack::ContentLength, ActionDispatch::Static, Rack::Lock, #<ActiveSupport::Cache::Strategy::LocalCache::Middleware:0x0000000456b3b0>, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag, RequestStore::Middleware, OpenIdAuthentication
Application root          /home/vagrant/work/redmine-3.4.6
Environment               production
Database adapter          postgresql
Database schema version   20170810052427
yassan commented 6 years ago

こちらの環境でも上記の対応で動作を確認しました。

y503unavailable commented 6 years ago

@akiko-pusu ありがとうございます。 full text searchと、 https://github.com/ixti/redmine_tags を同居させると、 チケット作成/表示時に 同じく display_score? でエラー発生していましたが、 上記パッチにて解消しました。

CENTOS7 mariadb bundle exec rake about RAILS_ENV=production About your application's environment Rails version 4.2.8 Ruby version 2.4.4-p296 (x86_64-linux) RubyGems version 2.6.14.1 Rack version 1.6.10 Middleware Rack::Sendfile, Rack::ContentLength, ActionDispatch::Static, Rack::Lock, #, Rack::Runtime, Rack::MethodOverride, ActionDispatch::RequestId, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::DebugExceptions, ActionDispatch::RemoteIp, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::XmlParamsParser, Rack::Head, Rack::ConditionalGet, Rack::ETag, RequestStore::Middleware, OpenIdAuthentication Application root /var/lib/redmine Environment production Database adapter mysql2 Database schema version 20180122193833