-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Is your feature request related to a problem? Please describe.
When AutoTTL runs, it assumes the feed has been updated in the event feed_before_actualize
This could not be true when any other extension runs a hook in the same event and prevents a feed from being updated after AutoTTL has already processed the feed.
In my set up it's RateLimiter.
This is really bad on feeds which go into AutoTTL's max TTL since they don't get updated until that next max (which I have set for a day) and then once they can update again they most probably will be blocked again by the RateLimit while AutoTTL again thinks they got properly updated and won't let them be updated for another day.
This could also be used by other hooks which want to preprocess the entities before other extensions.
Maybe two extensions want to modify an entry with entry_before_insert or entry_before_display, but the changes of the extension X need to be present for extension Y to actually have an effect, if they run in reverse order Y's changes won't be applied.
Describe the solution you’d like
Add an optional parameter to the Minz_Extension::registerHook and Minz_ExtensionManager::addHook functions to give a numbered priority by the extension.
This way the extension would call something like $this->registerHook('feed_before_actualize', [$this,'feedBeforeActualizeHook'], 999);, any any existing extension can just ignore the new parameter.
Describe alternatives you’ve considered
Check how FreshRSS loads extensions and manipulate them to be loaded in certain order (this has the drawback of all hooks the extension uses having the same "priority)
Additional context
Currently hooks are stored like this
FreshRSS/lib/Minz/ExtensionManager.php
Line 332 in 6b14a74
| self::$hook_list[$hook_name]['list'][] = $hook_function; |
I'm thinking this could be changed to self::$hook_list[$hook_name]['list'][$priority][] = $hook_function;, ensuring the order of the array is correct to be called by foreach.
Then each call function would require to have a double foreach
foreach (self::$hook_list[$hook_name]['list'] as $prioBucket) {
foreach ($prioBuckets as $function) {
// Code to call the hooks
}
}