I’ve set up a CRON to call a URL in Kohana 3.
php /home/user/public_html/index.php my/route/in/bootstrap.php
It seems to access the URL fine.
However, I have received this error (send back in an email that my host sends per CRON)
Undefined index: HTTP_HOST
SYSPATH/classes/kohana/url.php [ 40 ]
Which is in a Kohana system file. Is this because the CRON job is not sending HTTP headers?
How would I fix this and get it to work (hopefully without hacking the core files).
Or am I doing the CRON wrong?
Update
Pekka provided a good answer, however I’d like to avoid changing the core files (though I will as a last resort).
It would seem Kohana 3 does have support for CLI, as there is a static property $is_cli.
http://github.com/kohana/core/blob/master/classes/kohana/core.php#L54
It seems like you have
E_STRICTnotification turned on, and Kohana’s error handling catches that.E_STRICTwill complain about undefined indexes. The index is indeed undefined because there is no HTTP_HOST in a PHP script when called through the CLI.Chances are your script is running fine despite this. You would have to turn down
error_reportingat some point to prevent the message from showing up – I don’t know Kohana well enough to know whether you can use a different config file when called from the CLI.Maybe just turning down the
error_reporting()in your specific controller does the trick, although it’s a bit hacky.