Details
Description
The example for creating addhoc tasks in the 2.7 docs uses an array for custom data:
$domination = new take_over_the_world();
|
$domination->set_custom_data(array(
|
'plansfortomorrownight' => 'The same thing we do every night, Pinky!'
|
));
|
\core\task\manager::queue_adhoc_task($domination);
|
Actually doing this fails, because the custom data column is an object and so cannot be inserted into the DB.
See public static function record_from_adhoc_task($task):
$record->customdata = $task->get_custom_data();
|
And see adhoc_task::get_custom_data():
return json_decode($this->customdata);
|
json_decode will return an object, when what we want is the raw (encoded) string.