[feature/system-cron] Fixed instantiate_task to work correctly.

PHPBB3-9596
This commit is contained in:
Oleg Pudeyev 2010-05-09 16:47:52 -04:00
parent 071472a6fd
commit ccf5902c50

View file

@ -168,13 +168,23 @@ class cron_manager
return null; return null;
} }
/**
* Creates an instance of parametrized cron task $name with args $args.
*
* $name is the task name, which is the same as cron task class name.
* $args will be passed to the task class's constructor.
* The constructed task is wrapped with cron task wrapper before being returned.
*/
function instantiate_task($name, $args) function instantiate_task($name, $args)
{ {
$task = $this->find_task($name); $task = $this->find_task($name);
if ($task) if ($task)
{ {
$class = get_class($task); // task here is actually an instance of cron task wrapper
$class = $task->get_name();
$task = new $class($args); $task = new $class($args);
// need to wrap the new task too
$task = new cron_task_wrapper($task);
} }
return $task; return $task;
} }