-
-
Notifications
You must be signed in to change notification settings - Fork 852
dev/joomla#54 New menu-based URL for HTTP method of calling cron #34185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
dev/joomla#54 New menu-based URL for HTTP method of calling cron #34185
Conversation
|
🤖 Thank you for contributing to CiviCRM! ❤️ We will need to test and review this PR. 👷 Introduction for new contributors...
Quick links for reviewers...
|
|
The issue associated with the Pull Request can be viewed at https://lab.civicrm.org/dev/joomla/-/issues/54 |
b41396f to
18975b8
Compare
|
@webmaster-cses-org-uk I like your thinking here but I'm also wondering could you just use the civicrm/api3 route with url parameters of job.execute and appropriate keys that way? |
I think it's interesting to consider whether these parameters are part of the ideal setup process. In my mind, I think the "System Status" would show you an alert and lead to some concrete suggestion for setup, e.g. (pseudo-text)
This kind of notification is an improved experience because the admin doesn't need to guess at details or cross-reference docs or manually configure users/passwords/roles/permissions. Of course, you do need some identity for And for HTTP, you do need some protection (so that random bots don't create a DoS through your cron endpoint). It's ideal to have a single-purpose key. I suspect that something along these lines would work:
|
|
Aside: it may not have come through quite right, but I should -- I think adding a route for the cron handler is a really good idea. 😄 |
Overview
As part of work on Joomla 5 compatibility (dev/joomla#54), one key problem identified is that using
cli.phporcron.phpboots CiviCRM first, before the CMS (Joomla). This is the opposite way round to when the web app (site) is accessed. Consequently, the order of precedence when autoloading classes and dependencies is wrong / different, and this causes the cron job to fail on J5+.This PR is a proposed method to fix the problem for
cron.php, by providing a route to design it out.Note that #33825 provides a fix for
cli.php.Before
If you wish to execute your cron jobs via the HTTP method, you call a URL as follows:
https://example.org/administrator/components/com_civicrm/civicrm/bin/cron.phpThis is an external script that has to manually bootstrap CiviCRM and then the CMS. It does not currently work on J4+.
After
Inspired by what has been done for the PayPal IPN notify URL, you can now call the following URL to execute cron jobs:
https://example.org/?option=com_civicrm&task=civicrm/cron/runjobsThis is now just a normal CiviCRM menu action / page access that therefore follows the usual boot sequence.
Longer-term, this brings the HTTP cron action into line with the rest of CiviCRM and allows us to design out
cron.phpif so desired.Technical Details
Parameters passed to the call are the same (
name,pass,keyetc). Only the URL changes.Tested and working on CiviCRM 6.6.1 (+ various J5 compatibility mods covered by other PRs) and Joomla 5.4.1.
The proposed solution adds a new method,
CRM_Utils_System::executeScheduledJobsAsCron(), which largely copies the code fromcron.php, updated as necessary.For absolute clarity, it is also proposed to rename the existing method
executeScheduledJobs()toexecuteScheduledJobsAsAdmin()(and update menu XML accordingly).Comments
Although this PR presents a solution for Joomla, in principle this would work on any CMS (although may require other changes - not sure how well
cron.phpis supported on other platforms).This PR is presented as a proof-of-concept. If it is agreed to adopt, the documentation will need updating (I can do this in due course).
Possibly an alternative solution is to use the REST API interface? (Link in documentation broken, think it should go to this page: https://docs.civicrm.org/dev/en/latest/api/v4/rest/)