4

How to do civicrm cron in BackdropCMS?

when I do in the browser: https://<domain.com>/modules/civicrm/bin/cron.php with the proper parameters it gets redirected to: https://<domain.com>/modules/civicrm/bin/core/cron.php and then gives a 404

https://docs.civicrm.org/sysadmin/en/latest/setup/jobs/ does not show Backdrop yet.

2 Answers 2

3

Ok,

The CLI version works out of the box: /usr/local/bin/php /home/#dir#/public_html/modules/civicrm/bin/cli.php -s #domain# -u #cronuser# -p #cronpwd# -e Job -a execute

The HTTP version needs a change in BackdropCMS .htaccess

.htaccess has this:

# Redirect common PHP files to their new locations.
RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(cron.php)
RewriteCond %{REQUEST_URI} !core
RewriteRule ^ %1/core/%2 [L,QSA,R=301]

If you make it this it works:

# Redirect common PHP files to their new locations.
RewriteCond %{REQUEST_URI} ^(.*)?/(update.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(install.php) [OR]
RewriteCond %{REQUEST_URI} ^(.*)?/(cron.php)
RewriteCond %{REQUEST_URI} !core
RewriteCond %{REQUEST_URI} !civicrm
RewriteRule ^ %1/core/%2 [L,QSA,R=301]

Going to ask for a change of default .htaccess in BackdropCMS

--

update: This is now part of BackdropCMS core, although made slightly more generic:

RewriteCond %{REQUEST_URI} !modules

is added to .htaccess

2

I wrote https://www.drupal.org/project/civicrm_cron a decade ago to make it easier to run CiviCRM on Pantheon. Pantheon already ran Drupal's cron -> by getting Drupal to run CiviCRM's cron, Pantheon ran CiviCRM's cron too.

The way the D7 module worked was convoluted. It declared a new menu path within Drupal and then wrap[ed a call to that URL with the sitekey value in the querystring using drupal_http_request.

Basically, Drupal became a proxy for the same URL someone could have added to a crontab or Easycron type service.

In Backdrop, because the path would be within the paths already managed by Backdrop there would be no need to alter the .htaccess file (or how this is managed in NGINX).

New Menu Path is defined at https://git.drupalcode.org/project/civicrm_cron/-/blob/7.x-2.x/civicrm_cron.module#L22

Call to that path wrapped in hook_cron at https://git.drupalcode.org/project/civicrm_cron/-/blob/7.x-2.x/civicrm_cron.module#L49

The part that has likely changes in the last 10 years is https://git.drupalcode.org/project/civicrm_cron/-/blob/7.x-2.x/civicrm_cron.module#L143

David Snopek simplified this for D8 with just a hook_cron, but I don't think Backdrop has the equivalent of \Drupal::service('civicrm_cron.cron_runner')

https://git.drupalcode.org/project/civicrm_cron/-/blob/8.x-1.x/civicrm_cron.module#L143

It doesn't seem too difficult for someone familiar with Backdrop and CiviCRM to find an approach that would work without needed to modify Backdrop's .htaccess files.

2
  • 1
    oh, nice. I think your module is forked already for backdrop: backdropcms.org/project/civicrm_cron. Thanks for the tip (although I still think it should be possible to use without)
    – Catorghans
    Feb 20, 2022 at 17:04
  • 1
    Ha! I should have checked that first. I think it's safe to say that at this point the Backdrop community has ported or found a different way to achieve almost anything anyone using D7 would need. Really AMAZING work!
    – kreynen
    Feb 22, 2022 at 15:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.