Robin S Posted May 1, 2017 Share Posted May 1, 2017 I have a PHP file that bootstraps PW and I'm calling it from a cron job. When the cron fires the script does run but I also get the following error notice: [01-May-2017 13:07:01 Pacific/Auckland] PHP Notice: Undefined index: argc in /home/myaccount/public_html/wire/core/ProcessWire.php on line 260 I've seen this reply to a similar problem... ...but I'm not sure that applies in my case. My site is on a shared host and I get the error when I call my cron job like this... php -q /home/myaccount/public_html/tm_import.php ...which is the recommended format according to my host's documentation. I tried this... /usr/bin/php -q /home/myaccount/public_html/tm_import.php ...and I get the same notice. Whereas based on @BitPoet's suggestion when I try... /usr/bin/php-cli -q /home/myaccount/public_html/tm_import.php ...my script doesn't run. Incidentally, line 260 of ProcessWire.php checks if php_sapi_name() == 'cli' and in my case php_sapi_name() is 'cgi-fcgi'. So I'm wondering if PW should be checking for some other variants of php_sapi_name() and I should file a GitHub issue for this, or if I'm just doing something wrong in my cron job. PHP 7.0, PW 3.0.55 2 Link to comment Share on other sites More sharing options...
kixe Posted May 1, 2017 Share Posted May 1, 2017 3 hours ago, Robin S said: So I'm wondering if PW should be checking for some other variants of php_sapi_name() and I should file a GitHub issue for this I would say yes since php_sapi_name() will return 'cgi' or 'cgi-fcgi' even if cgi is called from the command line. Some other remarks: The content of $_SERVER differs depending on the call of php-cgi (server or command line) If register_argc_argv is disabled (php.ini) $_SERVER[argc] is not set. Could be checked with ini_get('register_argc_arg'); As far I can see the setting of $config->cli has not an effect inside PW. 2 Link to comment Share on other sites More sharing options...
Robin S Posted May 1, 2017 Author Share Posted May 1, 2017 GitHub issue opened: https://github.com/processwire/processwire-issues/issues/255 Apparently it's quite easy to unknowingly call the php-cgi binary from a cron job on cPanel servers because the paths changed starting in EasyApache 4 (previously the /usr/bin/php path pointed to php-cli). 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now