プロジェクト

全般

プロフィール

Vote #77610

完了

Fix for Error: Unable to autoload constant Redmine::Version when accessing the time report in first request

Admin Redmine さんが約4年前に追加. 約4年前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Rails support_44
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
44
version_id:
121
issue_org_id:
23269
author_id:
2784
assigned_to_id:
1
comments:
2
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

When starting up Redmine in development mode and accessing the /time_entries/report page on the first request, Redmine in at least versions 3.3 and trunk fails to properly autoload the @Version@ class.

The full error is:

Unable to autoload constant Redmine::Version, expected lib/redmine/version.rb to define it

activesupport (4.2.6) lib/active_support/dependencies.rb:495:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.2.6) lib/active_support/dependencies.rb:526:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
activesupport (4.2.6) lib/active_support/dependencies.rb:526:in `load_missing_constant'
activesupport (4.2.6) lib/active_support/dependencies.rb:184:in `const_missing'
lib/redmine/helpers/time_report.rb:111:in `load_available_criteria'
lib/redmine/helpers/time_report.rb:39:in `available_criteria'
app/views/timelog/report.html.erb:23:in `block in _app_views_timelog_report_html_erb___3330057872428091759_70181945143200'

The reason for this is that the lookup happens inside the class @Redmine::Helpers::TimeReport@ and the @Version@ model class is not loaded yet. Thus, the Rails autoloader tries to load the class and navigates up the module chain. It finds a file matching the naming conventions in @lib/redmine/version.rb@ which would match the expected module/class @Redmine::Version@ which in turn would have precedence before @::Version@ in the lookup chain.

Since @lib/redmine/version.rb@ does not define @Redmine::Version@, the error occurs. A fix to this is to fully qualify the class on lookup to give the autoloader a hint where to look at. The attached patch fixes this.

Note that this issue doesn't seem to occur in production mode.


journals

Committed, thanks.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

Admin Redmine さんが約4年前に更新

  • カテゴリRails support_44 にセット
  • 対象バージョン3.2.4_121 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0