Patch #24939
openChanging plugin loading order
0%
Description
Hi,
I have one plugin that depends on another, and I needed to specify the order plugins are loaded so the classes and migrations are loaded in the proper order, but the dependent plugin is loaded first because of alphabetical order of their names.
I made this patch on lib/redmine/plugin.rb so I can determine plugins loading order by setting its priorities on a Hash in the file config/additional_environment.rb.
This sorting relies that plugin directory name is equals to its id.
Regards,
Files
Related issues
Updated by Lucas Arnaud almost 8 years ago
I forgot to mention, I am using Redmine 3.3 version.
Updated by Jaap de Haan over 7 years ago
The plugin load order is a headache, I fully agree.
Instead of making a kind of ad-hoc fix, I believe the best solution involves:
- an optional declarative statement "depends_on" that can be added to the init.rb of a plugin
- a topological sort based on these dependency relationships
This has the benefit to scale and be dynamic... Your solution is overriding by giving a hard coded list... which I consider being a workaround and not a clean solution. Of course the clean solution means more efforts :-)
I'll try to come with that solution...
Relates to #23131
Updated by Lucas Arnaud over 7 years ago
Hi Jaap de Haan,
I know that is not the ideal solution, but it is sufficient for most of cases, and the as you already said, the best solution would take a lot of additional effort.
Thanks for considering.
Best regards,
Updated by Toshi MARUYAMA over 7 years ago
- Related to Feature #23131: Plugin load order defined by inter-plugin dependencies added
Updated by Tiago Gonçalves about 7 years ago
We could try loading the plugin, have it check dependencies and, if they are not met, raise a specific exception to defer loading until the next plugin loading iteration. If at the end of a plugin loading iteration there isn't any progress, we know that the remaining plugins have unmet dependencies, like, missing plugins and/or circular dependencies.
Updated by Lucas Arnaud about 7 years ago
Hi Jaap,
I've met another use case when the topological order defined by plugin dependencies won't work.
As Redmine allows you to override views, model class methods among other things in code, the order the plugins are loaded are crucial to define the application behavior.
Sometimes one use two or more independent plugins and you need to define the order they are loaded to meet your requirements and you can't just declare one as dependent on the other.
Regards,
Jaap de Haan wrote:
The plugin load order is a headache, I fully agree.
Instead of making a kind of ad-hoc fix, I believe the best solution involves:
- an optional declarative statement "depends_on" that can be added to the init.rb of a plugin
- a topological sort based on these dependency relationships
This has the benefit to scale and be dynamic... Your solution is overriding by giving a hard coded list... which I consider being a workaround and not a clean solution. Of course the clean solution means more efforts :-)
I'll try to come with that solution...
Relates to #23131