Permalink
Browse files

Tasks : fix empty nodes

  • Loading branch information...
1 parent 6f2c32f commit 2116922ee478d0b69ebee5c5079b3f09e5c1ea8b @cdujeu cdujeu committed May 26, 2016
Showing with 7 additions and 2 deletions.
  1. +7 −2 core/src/plugins/core.tasks/src/Providers/SqlTasksProvider.php
@@ -48,8 +48,11 @@ protected function taskToDBValues(Task $task, $removeId = false){
"schedule" => json_encode($task->getSchedule()),
"action" => $task->getAction(),
"parameters"=> json_encode($task->getParameters()),
- "nodes" => "|||".implode("|||", $task->nodes)."|||"
+ "nodes" => ""
];
+ if(count($task->nodes)){
+ $values["nodes"] = "|||".implode("|||", $task->nodes)."|||";
+ }
if(!$removeId){
$values = array_merge(["uid" => $task->getId()], $values);
}
@@ -74,7 +77,9 @@ protected function taskFromDBValues(\DibiRow $values){
$task->setAction($values["action"]);
$task->setParameters(json_decode($values["parameters"], true));
$nodes = explode("|||", trim($values["nodes"], "|||"));
- foreach ($nodes as $node) $task->attachToNode($node);
+ foreach ($nodes as $node) {
+ if(!empty($node)) $task->attachToNode($node);
+ }
return $task;
}

0 comments on commit 2116922

Please sign in to comment.