I upgraded my Drupal from 6.7 to 6.8. After upgrading, Cron does not run properly. I tried to run from shell: "php cron.php" and got the following error:

Status: 400 Bad Request
X-Powered-By: PHP/5.2.6
Content-type: text/html

My PHP version:
PHP 5.2.6 (cgi-fcgi) (built: Nov 29 2008 22:35:16)
Copyright (c) 1997-2008 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies

Please help me to solve this error.

Comments

nhchau’s picture

The Drupal's cron run well if I clicked to this link: .../admin/reports/status/run-cron but cannot run from command line as "php cron.php"

se’s picture

Same situation here. After upgrade 6.6->6.7->6.8 cron stopped work. Cron log at webhosting looks ok, if I "run" /cron.php from my browser it is proccessed successfuly..

nhchau’s picture

Please go to this URL http://drupal.org/node/346285 and apply patch described there. I patched, and it works for both Drupal 6.8 and Drupal 5.14. Hope this helps.

The patch code is here: http://drupal.org/files/issues/drupal-5-empty_http_host_support-1.patch

Bob4613’s picture

How is this patch applied? Is this code copied into the "cron.php" file or somewhere else?

nhchau’s picture

In Drupal 6.8, edit file /includes/bootstrap.inc, go to line 279 or search for drupal_valid_http_host() function, change the function's original code:

$_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
return preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $_SERVER['HTTP_HOST']);

to

if (empty($_SERVER['HTTP_HOST'])) return true; // Add this line
$_SERVER['HTTP_HOST'] = strtolower($_SERVER['HTTP_HOST']);
return preg_match('/^\[?(?:[a-z0-9-:\]_]+\.?)+$/', $_SERVER['HTTP_HOST']);

This patch also applies well to Drupal 5.8: edit the same file, go to line 242 or search for drupal_valid_http_host() function repeat the above action.

Good luck.

Bob4613’s picture

nhchau

That worked & the cron is working again.. It was a little confusing at first, I didn't know if I was supposed to leave // in the code or not. All is good.

Thanks for the help.

AndyW’s picture

And now it's giving me "HTTP request status" every single time the Cron is run while previously it was only doing it now and again

Press Release 001 | Do Follow 001

jdefay’s picture

Thanks nhchau, your suggested change to bootstrap.inc worked for me with my web hosting provider (Logicweb).

ludodrupal’s picture

Thank you very much. This helped me a lot.

holgerhubbs’s picture

My hosting provider sends me some canned support: "Please note that you will need to update the "$HOME" object in your Cron Job to your hosting account's full path."

datahazard’s picture

It stopped working on all of my installations when I upgraded on day 0. I just changed my cron job to instead of running "php cron.php" it now does:
cd/tmp ;
wget http://mysite/cron.php ;
rm cron.php

throk’s picture

I'm running 6.8 and it works.

you can put it all in one line in CPanel like:

cd/tmp; wget http://mysite/cron.php; rm cron.php
-Anti-’s picture

Thanks for the info and patch.
Sites running again now.

Pity that I didn't suspect drupal was to blame and spent two hours trying to troubleshoot the cpanel crontab. I was just about to fire off an email to webhost support asking them reset my account. Luckily I did a quick search here before doing that.

Cheers.

socialnicheguru’s picture

I am having problems with a updating to D6 too
--
Creating an activelyOUT community of LGBT professionals

http://SocialNicheGuru.com
Delivering inSITE(TM), we empower you to deliver the right product and the right message to the right NICHE at the right time across all product, marketing, and sales channels.