2

Since upgrading our Magento 1.8.0.0 to 1.9.2.1 I have noticed that we're getting hundreds of errors in the log file:

2015-11-11T16:20:01+00:00 ERR (3): Warning: strpos(): Empty needle in home/directory/public_html/lib/Zend/Controller/Request/Http.php on line 508

Having had a look at the file, I can see:

if (0 === strpos($requestUri, $baseUrl)) {
  // full $baseUrl matches
  $this->_baseUrl = $baseUrl;
  return $this;
}

if (0 === strpos($requestUri, dirname($baseUrl))) {
  // directory portion of $baseUrl matches
  $this->_baseUrl = rtrim(dirname($baseUrl), '/');
  return $this;
}

The last thing I want to do is edit this core file to make a cheap fix. Does anybody know what could be the cause of this problem? My base URL is obviously set do I don't understand what could be causing the issue!

2
  • The given code snippet has not changed between Zend Framework 1.11.1 and Zend Framework 1.12.10 so it is not the library causing trouble. You need to have a look at (and provide) the full stack trace.
    – mam08ixo
    Commented Nov 11, 2015 at 17:23
  • I know it can't be a problem with the framework because we have another website running the same version of Magento that isn't receiving such errors. The full error is 2015-11-12T15:40:01+00:00 ERR (3): Warning: strpos(): Empty needle in /home/directory/public_html/lib/Zend/Controller/Request/Http.php on line 508 2015-11-12T15:40:01+00:00. Commented Nov 12, 2015 at 16:56

4 Answers 4

2

In my case the exact same error occurs every minute, on the minute. It seems the problem lies with core_email_queue_send_all, as this is the only job that is called every minute.

Somehow, but I am yet unsure why, the error message is caused by the way the cron job in Magento is called. I tested this in version 1.9.2.2

Starting cron by a call to cron.sh reproduces the error:

sh public_html/cron.sh > /dev/null

while calling cron.php directly does not cause the problem, using the following call:

wget -O /dev/null -q http://www.myserver.nl/cron.php > /dev/null

2
  • I'm just ignoring the errors for now and occasionally deleting my system.log file when it gets too big. I would change my cron to point to the .php file instead, but the .sh file is there to make sure that a cron isn't already running. Commented Jan 7, 2016 at 14:47
  • I have also tried using aoe_schedulers scheduler_cron.sh, but without success. You mentioned you have two servers, one with and the other without the issue. Are you using different calls to cron there also?
    – Bob
    Commented Jan 8, 2016 at 10:52
1

I had the same issue, I search on web and I found a potential solution. It seems correct

I modified /magento_root/cron.sh at line 39

PHP_BIN=which php => PHP_BIN=which php-cli

Source: https://github.com/AOEpeople/Aoe_Scheduler/issues/233

EDIT : I made the change yesterday, and today I had 3 new orders, but no mail was sent. So I edit back and I received my mails. So my solution seems NOT correct !

3
  • I did see that link on GitHub a while ago, but implementing the change didn't fix the problem for me at the time. I've just realised that I was trying to implement this change into scheduler_cron.sh rather than cron.sh - so that's why it wasn't working! Commented Sep 12, 2017 at 13:38
  • it stops my cron from working.
    – fja3omega
    Commented Apr 13, 2018 at 3:44
  • Yeah it still stops my cron working as well because php-cli isn't even a command. Commented Jun 5, 2018 at 15:06
1

I had the same issue for a while didn't pay too much attention to it although i knew it was related to cron as it appeared every 5 minutes, same as my cron was configured to run. Today i decided to have it resolved and i fixed it by going to CLI of my server and typing: whereis php. It came back with a bunch of php possibilities so i took the most generic one: /usr/bin/php and in cron.sh i changed PHP_BIN=which php to PHP_BIN='/usr/bin/php'. Notice the quotations. Error wet away. I had some other errors in there and surprisingly they seem to have gone away as well.

0
Error:
2017-12-29T04:20:02+00:00 ERR (3): Warning: strpos(): Empty needle in /home/hillcountry/public_html/lib/Zend/Controller/Request/Http.php on line 508
2017-12-29T04:20:02+00:00 ERR (3): Warning: strpos(): Empty needle in /home/hillcountry/public_html/lib/Zend/Controller/Request/Http.php on line 514

Comment: This problem is in defintion of base URL, because is running on cron script.

Possible solution: I think the possible solution is add the environment variable what set $baseUrl in lib/Zend/Controller/Request/Http.php on setBaseUrl function.

I am new to the forum. We do not want to modify the core. Is this where I should report the bug? If not, please help.

1

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.