Skip to content
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

削除したカスタムフィールドの単語を検索時、エラー #108

Closed
Stag0007 opened this issue Jan 24, 2023 · 5 comments · Fixed by #109
Closed

削除したカスタムフィールドの単語を検索時、エラー #108

Stag0007 opened this issue Jan 24, 2023 · 5 comments · Fixed by #109

Comments

@Stag0007
Copy link

1.カスタムフィールド(リスト形式)を登録し、チケットにて値を選択。
2.カスタムフィールドごと削除した際
3.値にしていた単語を検索→下記エラーとなります。
Page not found
The page you were trying to access doesn't exist or has been removed.

production.logよりエラー内容。
ActiveRecord::RecordNotFound (Couldn't find CustomValue with 'id'=1476):

custom_valueにて記載IDが削除されていることを確認。
カスタムフィールド削除時、設定されていた値の検索でエラーとならないよう、
ご対応いただくことは可能でしょうか。
(カスタムフィールドを削除する際に気を付けていればよかったのですが。。。)

プラグインのバージョン:1.0.4

@komainu8
Copy link
Member

手元で問題を再現させたいので、下記の情報をいただけますか?

  • Redmineのバージョン
  • Rubyのバージョン
  • Ruby on Railsのバージョン
  • MySQL(MariaDB) or PostgreSQL のバージョン
  • Mroonga or PGroonga のバージョン

@HashidaTKS
Copy link
Contributor

手元でも再現することが確認できました。
一旦再現環境の情報を頂かなくても大丈夫そうです!

@Stag0007
Copy link
Author

ありがとうございます。
念のため、当環境をお伝えしておきます。
よろしくお願いいたします。
・Redmine:4.2.2
・Ruby:2.6.8
・Ruby on Rails:5.2.6
・MariaDB:10.2
・Mroonga:11.0.6

@kou kou closed this as completed in #109 Feb 1, 2023
kou added a commit that referenced this issue Feb 1, 2023
GitHub: fix GH-108

If a searchable `CustomField` is destroyed, corresponding
`FullTextSearch::Target` records are also destroyed.
We can't use existing mapper mechanism for it because `CustomField` uses
`has_many :custom_values, :dependent => :delete_all` relation. It
doesn't call `after_destroy` callback that is
needed to synchronize `CustomFieldValue` and `FullTextSearch::Target`.

We can remove orphaned `FullTextSearch::Target` for destroyed
`CustomFieldValue` by
`bin/rails full_text_search:synchronize`.

---------

Co-authored-by: Sutou Kouhei <[email protected]>
@kou
Copy link
Member

kou commented Feb 1, 2023

対応しました。
ゴミレコードはRAILS_ENV=production bin/rails full_text_search:synchronizeで消えるのでそれを実行すれば検索時のエラーもなくなるはずです。

@Stag0007
Copy link
Author

Stag0007 commented Feb 2, 2023

検索時にエラー発生しないことが確認できました。
対応ありがとうございます。

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

Successfully merging a pull request may close this issue.

4 participants