cancel
Showing results for 
Search instead for 
Did you mean: 

Cron causing errors in Magento 1.9.2.2

Cron causing errors in Magento 1.9.2.2

I'm having a hard time finding out what is causing these errors, but they only started once I was able to get my CronJobs working, so I believe they are tied to that. I am calling the Magento Crons by Cpanel command: */5 * * * * /usr/php/54/usr/bin/php /MyServerInfo/public_html/cron.php >/dev/null &2>1

(I wanted to call Cron using cron.sh but was unable to get that to work, if interested in that struggle see post: https://community.magento.com/t5/Technical-Issues/CronJobs-Magento-1-9-2-2/m-p/26090#U26090)

 

I am getting these in my system.log file every 5 minutes, which matches the CronJob timeline: 2016-01-14T01:55:01+00:00 ERR (3): Warning: strpos(): Empty needle in /MyServerInfo/public_html/lib/Zend/Controller/Request/Http.php on line 508 2016-01-14T01:55:01+00:00 ERR (3): Warning: strpos(): Empty needle in /MyServerInfo/public_html/lib/Zend/Controller/Request/Http.php on line 514

 

And this in my error_log every 5 minutes as well: [13-Jan-2016 23:40:01 UTC] PHP Notice: Undefined index: SCRIPT_NAME in /MyServerInfo/public_html/cron.php on line 41

[14-Jan-2016 18:55:02 UTC] PHP Notice:  Undefined index: SCRIPT_NAME in /MyServerInfo/public_html/cron.php on line 40

 

I have been doing research and the best I have been able to find is a "temporary solution" that involves altering the Core files, which I would prefer not to do. I would rather fix the underlying problem if possible: See a temporary solution to this problem:

 

Edit file: lib/Zend/Controller/Request/Http.php

Line 504: if (0 === strpos($requestUri, $baseUrl)) {

Replace with: if (!empty($baseUrl) && 0 === strpos($requestUri, $baseUrl)) {

Line 510: if (0 === strpos($requestUri, dirname($baseUrl))) {

Replace with: if (!empty($baseUrl) && 0 === strpos($requestUri, dirname($baseUrl))) {

 

I also found this related post: Cron.php undefined index 'SCRIPT_FILENAME'

But it seems like they are talking about doing something with command line access, which I do not have. Only Cpanel.

 

Any help or direction would be appreciated.

2 REPLIES 2

Re: Cron causing errors in Magento 1.9.2.2

getting the same errors:

 

[16-Jan-2016 13:50:02 UTC] PHP Notice: Undefined index: SCRIPT_NAME in /home//public_html/cron.php on line 40

[16-Jan-2016 13:50:02 UTC] PHP Notice: Undefined index: SCRIPT_FILENAME in /home//public_html/cron.php on line 41

 

 

Please help URGENTLY Smiley Sad

Re: Cron causing errors in Magento 1.9.2.2

For me at least, both the EMPTY NEEDLE issue and the SCRIPT_FILENAME issue, seems to be resolved. Turns out the answer was linked in my original post for this problem, but either it was updated when I went back to research it again, or I didn't get it the first time. If you go in to your Cron Jobs at your Host or wherever you are originally calling them from, and just change the PHP to PHP-CLI it fixes the issue.  For example in my case I just changed /usr/php/54/usr/bin/php /YourHostInfo/public_html/cron.php >/dev/null 2>&1   to /usr/php/54/usr/bin/php-cli /YourHostInfo/public_html/cron.php >/dev/null 2>&1

My Cron Jobs are still running and no more Script_Filename or Empty Needle errors.