Patch #24939

Changing plugin loading order

Added by Lucas Arnaud over 2 years ago. Updated over 1 year ago.

Status:NewStart date:
Priority:NormalDue date:
Assignee:-% Done:

0%

Category:Plugin API
Target version:-

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,

0001-Making-possible-to-change-plugins-loading-order.patch Magnifier (2.43 KB) Lucas Arnaud, 2017-01-27 20:00


Related issues

Related to Redmine - Feature #23131: Plugin load order defined by inter-plugin dependencies Reopened

History

#1 Updated by Lucas Arnaud over 2 years ago

I forgot to mention, I am using Redmine 3.3 version.

#2 Updated by Go MAEDA over 2 years ago

  • Category set to Plugin API

#4 Updated by Jaap de Haan about 2 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

#5 Updated by Lucas Arnaud about 2 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,

#6 Updated by Toshi MARUYAMA almost 2 years ago

  • Related to Feature #23131: Plugin load order defined by inter-plugin dependencies added

#7 Updated by Tiago Gonçalves almost 2 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.

#8 Updated by Lucas Arnaud over 1 year 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

Also available in: Atom PDF