プロジェクト

全般

プロフィール

Vote #81861

未完了

Rails Autoload Paths contain plugin libs twice

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

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

0%

予定工数:
category_id:
20
version_id:
0
issue_org_id:
36801
author_id:
355817
assigned_to_id:
0
comments:
2
status_id:
1
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
172
ステータス-->[New]

説明

Due to the way plugins are loaded by Redmine the variable


ActiveSupport::Dependencies.autoload_paths

contains the path to the 'lib' directory of each plugin twice, which should not happen.

When Redmine loads the plugins from @config/initializers/30-redmine.rb@ it calls


Redmine::Plugin.load

@Redmine::Plugin.load@ (defined in @lib/redmine/plugin.rb@) adds the 'lib' directory of each plugin to


ActiveSupport::Dependencies.autoload_paths

and to


$LOAD_PATH #alias $:

When each plugin calls


Redmine::Plugin.register

from init.rb (which they ought to do), then in @Redmine::Plugin.register@ all Rails paths in the plugin directory are created by calling


engine_cfg.paths

implicitly by calling


engine_cfg.paths.add 'lib', eager_load: true

Then in @Redmine::Plugin.register@ the following call causes the second addition of the autoload_paths


ActiveSupport::Dependencies.autoload_paths +=
engine_cfg.eager_load_paths + engine_cfg.autoload_once_paths + engine_cfg.autoload_paths

In some environments this may cause trouble.


journals

A fix could be adding

<pre><code class="ruby">
ActiveSupport::Dependencies.autoload_paths.uniq
</pre></code>

as the last line in @Redmine::Plugin.load
--------------------------------------------------------------------------------
Can you test on current trunk where we switched the autoloading from classic to zeitwerk (#29914)?
--------------------------------------------------------------------------------

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

  • カテゴリPlugin API_20 にセット

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

いいね!0
いいね!0