Normalize action return value recorded in database
While working on #424, I discovered that actions that were run were unable to record their run state into the database because the return code value being passed to m_action::finish was a string and not an integer. I added a shim to try to normalize the data passed onwards to m_action::finish, although in the long term I think a proper cleanup of the cases should be done.
This commit is contained in:
parent
6dc3b0d5a3
commit
7957deccba
|
@ -323,17 +323,32 @@ while ($rr=$action->get_action()){
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default :
|
default :
|
||||||
$output=array("Fail: Sorry dude, i do not know this type of action");
|
$returned = array(
|
||||||
|
'return_val' => -1,
|
||||||
|
'output' => array("Fail: Sorry dude, i do not know this type of action"),
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Get the error (if exists).
|
// Some of the above cases set $returned when executed_cmd is run, which provides
|
||||||
if(isset($output[0])){
|
// us with detailed information; however, or cases will leave the value of
|
||||||
$return=$output[0];
|
// $return unchanged and simply append to the error list.
|
||||||
|
// @CLEANUP Fix the consistency problems in the case statement itself instead of
|
||||||
|
// trying to do it here.
|
||||||
|
if (!isset($returned)) {
|
||||||
|
$returned = array(
|
||||||
|
'return_val' => $errorsList ? -1 : 0,
|
||||||
|
'output' => $errorsList,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$output = $returned['output'];
|
||||||
|
$return_value = $returned['return_val'];
|
||||||
|
if ($return_value != 0) {
|
||||||
$errorsList[]="\nAction n°".$r["id"]." '".$r["type"]."' failed! With user: ".$r["user"]."\nHere is the complete output:\n".print_r($output);
|
$errorsList[]="\nAction n°".$r["id"]." '".$r["type"]."' failed! With user: ".$r["user"]."\nHere is the complete output:\n".print_r($output);
|
||||||
}
|
}
|
||||||
// We finished the action, notify the DB.
|
// We finished the action, notify the DB.
|
||||||
d("Finishing... return value is : $return\n");
|
d("Finishing... return value is : $return_value\n");
|
||||||
if(!$action->finish($r["id"],addslashes($return))){
|
if(!$action->finish($r["id"], $return_value)){
|
||||||
$errorsList[]="Cannot finish the action! Error while inserting the error value in the DB for action n°".$r["id"]." : action '".$r["type"]."'\nReturn value: ".addslashes($return)."\n";
|
$errorsList[]="Cannot finish the action! Error while inserting the error value in the DB for action n°".$r["id"]." : action '".$r["type"]."'\nReturn value: ".addslashes($return)."\n";
|
||||||
break; // Else we go into an infinite loop... AAAAHHHHHH
|
break; // Else we go into an infinite loop... AAAAHHHHHH
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue