Opened 16 years ago
Last modified 11 years ago
#3318 review New Feature
There should be some guarantee at plugin loading order
Reported by: | Martin Kou | Owned by: | Garry Yao |
---|---|---|---|
Priority: | Normal | Milestone: | |
Component: | General | Version: | 3.0 |
Keywords: | Oracle | Cc: | Senthil |
Description
The iframedialog plugin is now having to use onLoad to load its code because the plugin system is always loading iframedialog first, running iframedialog's init() first, and even running iframedialog's onLoad() first.
So far we've been able to get iframedialog plugin to load correctly with the onLoad() hack. But if someone else's plugin needs the iframedialog plugin to be loaded before loading theirs, they'll have to find some even dirtier ways to do it. The requires array in plugin definition doesn't help here.
This situation is clearly not sustainable. We'll need to find some way of guaranteeing the loading order of plugins based on their dependencies. If that's not possible, we should at least guarantee the calling order of some of their initialization functions.
Attachments (3)
Change History (16)
comment:1 Changed 16 years ago by
comment:2 Changed 16 years ago by
Type: | Bug → New Feature |
---|
That's ok, and we could even consider implementing something that executes "init" in the dependency order. But, this is not a bug. The requires property is there to indicate that other plugins are to be loaded, not to be executed in a specific order.
Currently, to avoid execution order issues, we don't need hacks. It's possible to use the "beforeInit" and "afterInit" properties. When plugins are loaded, "beforeInit" is called for all plugins, then "init" and finally "afterInit". Plugins that are known to be used by others, like "iframedialog", should use "beforeInit" for its initialization stuff.
Changed 16 years ago by
Attachment: | 3318.patch added |
---|
comment:3 Changed 16 years ago by
Keywords: | Review? added |
---|
comment:4 Changed 16 years ago by
I would avoid having adding code that we don't really need right now, and we're not talking about a couple of lines here.
Can the "iframedialog" issue be fixed by other means, as explained in my previous comment?
comment:5 Changed 16 years ago by
Keywords: | Review- added; Review? removed |
---|
There are also a few other problems here:
- I'm not sure we can rely on object properties to guarantee the order. It looks like a buggy point.
- A much simpler solution can definitely be found.
comment:6 Changed 16 years ago by
Proposing a simplified way to guarantee plugins methods been executed in dependency order, it should have almost same result as topology sorted algorithm.
comment:7 Changed 16 years ago by
Milestone: | CKEditor 3.0 → CKEditor 3.x |
---|
comment:8 Changed 15 years ago by
Keywords: | HasPatch added |
---|
comment:9 Changed 15 years ago by
Owner: | Martin Kou deleted |
---|
comment:11 Changed 14 years ago by
Keywords: | HasPatch removed |
---|---|
Owner: | set to Garry Yao |
Status: | review_failed → review |
Version: | SVN (CKEditor) - OLD → 3.0 |
Changed 14 years ago by
Attachment: | 3318_2.patch added |
---|
comment:12 follow-up: 13 Changed 11 years ago by
Noting that I encountered this issue: I didn't see any note that dependencies had no impact on loading order (only on plugins being loaded at all) and thus expected them to be (I believe this to be a reasonable expectation when dependencies have to be specified).
My context was having a plugin B alter/extend a plugin A (actually extending two different plugins but that's not a big issue), plus said plugin already uses afterInit
so that's no help.
(bypassed the problem by reimplementing the behavior I needed from the old "base" plugins in the new one after tracking down the disappearance of topological sorting somewhere deep in the bowels of ckeditor's resources loading)
comment:13 Changed 11 years ago by
@xmo, for now, you may give a try to the pluginsLoaded event. Not a solution I know, but a good workaround.
With [topological sorting http://en.wikipedia.org/wiki/Topological_sorting], it should be possible to guarantee the init() or onLoad() functions of plugins being required are called before the corresponding functions at the current plugin. i.e. if I have a plugin like this...
and then the iframedialog subsequently requires the dialog plugin, then it should be guaranteed that the dialog plugin is initialized first, then iframedialog, and finally myPlugin - no matter how they're ordered in the config.plugins string.
Currently, plugins the appear in the config.plugins string are first loaded according to the order they appear; then, the first level of required plugins that didn't appear in the config.plugins list are loaded; after that, the second level of required plugins (i.e. those required by the first level) are loaded; the process repeats itself until there's no more required plugin that hasn't been loaded.