Unusual Cron (Scheduled Tasks) Change Between 3.59 and 3.62

2 posts by 2 authors in: Forums > CMS Builder
Last Post: October 25, 2023   (RSS)

By Dave - October 25, 2023

Hi Mark, 

Thanks for the report! 

I made a patch for this for the next release.  Here's the technical details if you're curious.

How it works is that cron.php can be run from the web or ssh/cron.  For security, if it thinks it's being accessed from the web it requires an admin login.  

We have a function in /lib/common.php called inCLI() that tries to determine if the script is being run from ssh/cron (e.g.; inCLI = in Command Line Interface).  

It checks a PHP constant PHP_SAPI which is often set to 'cli' when run from the shell, but it can sometimes vary based on server configuration, likely that's why switching to php8.1-cli made it work, it likely reported a different value to cron.php for PHP_SAPI .

Web servers also usually set the script path in $_SERVER['SCRIPT_NAME'] so we're checking that as well.  But previously we were checking if it had a value, and when updating the code it was switched to check if anything (even a blank value) was set.  I've switched it back to the previous method. 

What I suspect is that your PHP binary wasn't setting PHP_SAPI to 'cli' when being run from the shell and was setting SCRIPT_NAME but leaving it blank which is why it worked before.  

If you run into this issue again and want us to have a look to confirm just let us know.

Thanks!

Dave Edis - Senior Developer
interactivetools.com