Code Monkey home page Code Monkey logo

Comments (8)

rmccue avatar rmccue commented on August 23, 2024 1

Specifically, Cavalcade hooks in at pre_option_cron and pre_update_option_cron, which are the low-level option hooks in WordPress. This means that any higher level functions (including wp_get_schedule() etc) will use this data automatically. You can check out how this works in the connector namespace.

A tell-tale sign that Cavalcade is enabled is that entries in the cron array will have 'schedule' => '__fake_schedule'. (This is because Cavalcade only stores the interval, not the full schedule ID.) If you're spotting those in the data, then Cavalcade is actually enabled. If not, then Cavalcade isn't enabled.

My guess here is that maybe jobs are being scheduled before Cavalcade is actually loaded. Unless Themosis also has hooks in pre_option_cron etc then it shouldn't be possible for it to be affecting Cavalcade directly, and it's very unlikely that it would be doing that. The most likely explanation is that Cavalcade isn't loaded when your jobs are being scheduled.

I'd also advise double-checking the database directly (specifically the cavalcade_jobs table) just to make sure the wp-cli command is actually returning the right thing.

from cavalcade.

rmccue avatar rmccue commented on August 23, 2024

Keep in mind that what you're scheduling is the hook name, not the callback. There's no restrictions on the hook name in WP that are relevant here, so my guess would be that you're not hooking into this correctly. The relevant code for WP is in connector/namespace.php, which is called via wp_schedule_event's update_option call. It's possible that wp_schedule_event is returning false for some reason (invalid timestamp, invalid recurrence, or something hooked into schedule_event)

I'd check the database table (wp_cavalcade_jobs) directly and see if your job has been scheduled there.

Happy to look further if you want to share your full code for the event hooking, but I don't think this is a core Cavalcade issue. :)

from cavalcade.

lougreenwood avatar lougreenwood commented on August 23, 2024

Sorry for the delayed reply, been super busy with a deadline.

I've just done some more investigation and it seems that I'm not able to register any cron jobs with Cavalcade enabled. The only jobs that cavalcade jobs reports are:

+----+------+---------------------------+---------------------+---------------------+---------+
| id | site | hook                      | start               | nextrun             | status  |
+----+------+---------------------------+---------------------+---------------------+---------+
| 15 | 1    | wp_version_check          | 2018-03-04 16:17:12 | 2018-03-05 04:17:12 | waiting |
| 16 | 1    | wp_update_plugins         | 2018-03-04 16:17:12 | 2018-03-05 04:17:12 | waiting |
| 17 | 1    | wp_update_themes          | 2018-03-04 16:17:12 | 2018-03-05 04:17:12 | waiting |
| 18 | 1    | pj_transient_cleaner      | 2018-03-04 16:17:12 | 2018-03-05 16:17:12 | waiting |
| 19 | 1    | wp_scheduled_delete       | 2018-03-04 16:17:12 | 2018-03-05 16:17:12 | waiting |
| 20 | 1    | delete_expired_transients | 2018-03-04 16:17:12 | 2018-03-05 16:17:12 | waiting |
+----+------+---------------------------+---------------------+---------------------+---------+

cavalcade log has no info about the missing cron jobs, neither do the cavalcade db tables.

I have a suspicion that this is a problem related to my setup. I'm using the "Themosis" framework. It seems that when Cavalcade is enabled, the Cavalcade schedule_event() function isn't called. However, I added some var_dumps to wp-includes/cron.php and I see that my expected jobs are at least received by WP.

So I suppose that Cavalcade isn't properly hooking into when WP is setup as a Themosis project.

I think my code will be too complex to share here, but I'm happy to grant you access to our repo and help you spin up a docker container for our project - assuming you're happy to help debug further?

Edit:
Themosis framework: https://framework.themosis.com

from cavalcade.

rmccue avatar rmccue commented on August 23, 2024

Cavalcade hooks in at a deep level in WordPress, so themes shouldn't be able to affect it. I think it's more likely that Cavalcade isn't actually being loaded properly. Are you sure the Cavalcade plugin is enabled?

I can try and find time to look at the repo if you want to give me access, but I can't guarantee any timeframe for doing so. You're best off digging into debugging it further yourself if you can.

from cavalcade.

lougreenwood avatar lougreenwood commented on August 23, 2024

from cavalcade.

lougreenwood avatar lougreenwood commented on August 23, 2024

Another thing to mention. When I do wp_get_schedule() or wp_next_scheduled(), the jobs which I'm registering, but Cavalcade is missing are returned by WP, so they're getting registered, it seems they just aren't getting 'synced' to Cavalcade.

It's also curious that the pj_transient_cleaner job (in my earlier post) which Cavalcade does pick up isn't a core WP job, (the rest of the jobs are WP native ones) - so maybe there's a hint for me in there too...

And yep, Cavalcade plugin is enabled in mu-plugins. I've debugged in there to to verify it. Bootstrap creates/populates the tables etc

from cavalcade.

lougreenwood avatar lougreenwood commented on August 23, 2024

@rmccue Good news, I was able to get the jobs loading by registering them using the 'init' action hook. The jobs are now properly scheduled.

Thanks for your help, much appreciated!

Cheers

from cavalcade.

rmccue avatar rmccue commented on August 23, 2024

Fantastic news, thanks for the update!

from cavalcade.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.