MyBB Community Forums

Full Version: [F] Task System out of a cronjob
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
When I run a task out of the command-line with the follow commando:
php /www/develop12_mybb140/task.php 4

I get the follow error:
Warning: require_once(./inc/init.php): failed to open stream: No such file or directory in /www/develop12_mybb140/task.php on line 20

Fatal error: require_once(): Failed opening required './inc/init.php' (include_path='.:/usr/share/php:/usr/share/pear') in /www/develop12_mybb140/task.php on line 20

It seems that PHP doesn't like relative requires out of the commandline when you aren't in that directory. And, that's difficult when you run it out of the commandline.

When you go to the directory and run the command, you don't get an error, and the process succeed.

So, the relative require has to be changed. Open task.php and find:
require_once "./inc/init.php";

Replace with:
require_once dirname(__FILE__)."/inc/init.php";

Now it will work:
[attachment=10657]
Thank you for your bug report.

This bug has been fixed in our internal code repository. Please note that the problem will not be fixed here until these forums are updated.