- 🇨🇦Canada liquidcms
This would be excellent as the button on the cron admin page to "discover jobs" does nothing. Although, wouldnt we expect that it just runs the same command this patch is adding to cache rebuild? So possibly the question is what are these discovering?
OP mentions hook_cron but this is Core's hook for running cron tasks; nothing related to UC i wouldn't think. And there is nothing mentioned about hook_cron in ultimate_cron.api.php only a bunch of hooks which some other issues here have suggested are no longer supported. I do see a mention of hook_cron in the README; but no details.
So when i say neither this patch, nor the button on the admin page do anything i am referring to the only thing i have found suggesting how to add new cron tasks to a custom module:
- add exported config (chicken/egg issue) to custom_module/config/install/optionalof course this doesnt work well for modules which have already been enabled (as i think this patch is trying to address).
so i feel some documentation missing somewhere re-purposing core's hook_cron?
- 🇪🇸Spain guiu.rocafort.ferrer Barcelona
As far as i know, it goes as follows for hook_cron ( without the provided patch ):
1. When installing ultimate_cron, it will find all hook_cron implementations and create configuration objects for each one.
2. When installing a module which implements hook_cron, ultimate_cron will pick it up and create the configuration automatically.
3. When adding a new hook_cron to an already installed module, then the configuration will not be created automatically, not even cleaning caches. The "Discover jobs" button needs to be pressed.When it comes to configuration objects, if you added a some cron configuration objects in config/install, and you want to add another one after the module is installed, then you have to write a hook_update to do that. This is not a ultimate_cron issue, but rather an issue with the module implementing the functionality, and it is also the case with other configurations that the module might add after it has been installed.
I tested the patch, and it discovers new hook_cron implementations when rebuilding the caches, so i would say it works as expected, and the issue can be closed. We might want to create a new issue on creating/updating the documentation about how the module works, but i would do it in a separate issue.
- Status changed to RTBC
about 1 year ago 12:44pm 24 August 2023 - last update
about 1 year ago 18 pass, 8 fail - 🇨🇭Switzerland berdir Switzerland
I'm not certain this is a good idea. This changes config, it's not just cached data, and could be unexpected. And it does exactly the same as the button in the UI.
- 🇪🇸Spain guiu.rocafort.ferrer Barcelona
The way i see it, external events, such as the install of a different module, are already triggering config changes in the ultimate_cron module, so i don't see why that would be different in the case of cache rebuilds. Without this functionality, a module that wants to start implementing a hook_cron would need to do one of the following:
- Implement a hook_update that triggers the discoverability of the new hook. I could not find any documentation at all about how to do this. The hook_update should be dependant on the fact that ultimate_cron is installed in the site too, if they don't list it explicitly as a dependency.
- ask the user to press the "discover jobs" button. not ideal in my opinion.
If we dedide on not implementing this, i believe that at least this should be documented, so module developers can implement a hook update to make ultimate_cron pick up the new hook, and create the corresponding configuration object.
- Status changed to Fixed
3 months ago 8:53pm 15 August 2024 - 🇨🇭Switzerland berdir Switzerland
> The way i see it, external events, such as the install of a different module, are already triggering config changes in the ultimate_cron module, so i don't see why that would be different in the case of cache rebuilds.
installing a module implies configuration changes. a cache rebuild less so. But it should only do anything if code also changed, so fair enough. Merged.
Automatically closed - issue fixed for 2 weeks with no activity.