Fixed Cron classes cannot be extended

Due to the way they are called by the XF framework, cron classes use static functions.

Those static functions are generally very short and call other functions such as repositories or service classes.

You would generally extend one of those rather than the static cron function to add functionality to an existing cron.

But why not just create your own cron task instead - it's pretty trivial to do?
 
But why not just create your own cron task instead - it's pretty trivial to do?
I have more than 150+ add-ons installed on my development board and more than 20+ add-ons have "<addon name>: Update view counters" and few other similar entries. The amount of cron tasks keeps on increasing.

To keep the list short, I would rather extend the existing classes.

You would generally extend one of those rather than the static cron function to add functionality to an existing cron.
For cron entries, yes. But not for other places like BB code media site matching callbacks or admin control panel option rendering or validation. Maybe I should've mentioned those too in the first post.

Those static functions are generally very short and call other functions such as repositories or service classes.
That logic should be applied to the \XF\MemberStat\* classes as well but they are not even though they contain but they are extendable.
 
I have more than 150+ add-ons installed on my development board and more than 20+ add-ons have "<addon name>: Update view counters" and few other similar entries. The amount of cron tasks keeps on increasing.

To keep the list short, I would rather extend the existing classes.

Fair enough - but I think you're just trying to hide the problem under the rug to a degree?

Instead of 20+ additional cron entries which are simple and easy to identify as an entry point, you're going to end up with 20+ class extensions which are far more opaque and not as intuitive when it comes to identifying the entry points into your addon code.

There's nothing really wrong with what you're trying to do - I just don't think you're actually solving anything by taking that approach?

I'd rather have more fine-grained control over the cron tasks than lose that control for the sake of limiting the number of cron tasks in the list.

A user may choose to disable or modify one of the cron tasks that ends up being critical to your addon (because they didn't realise they were connected) and then you'll have additional support issues to manage?

Anyway - that's just my thoughts on the matter - my objections are largely philosophical rather than technical.
 
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XF release (2.3.0 Beta 6).

Change log:
Allow cron classes to be extendable.
There may be a delay before changes are rolled out to the XenForo Community.
 
For cron entries, yes. But not for other places like BB code media site matching callbacks or admin control panel option rendering or validation. Maybe I should've mentioned those too in the first post.
@Chris D Please allow \XF\Entity\BbCodeMediaSite::match_callback_class, \XF\Entity\HelpPage::$callback_class and maybe \XF\Entity\Page::$callback_class to be extended as well.
 
  • BB Code Callbacks
  • BB Code Media Site Callbacks
would be nice as well :)

(Basically every kind of callback unless there is a compelling reason not to allow extension)
 
Last edited:
Back
Top Bottom