Skip to content
Snippets Groups Projects
Commit 60660d59 authored by Thibault Debatty's avatar Thibault Debatty
Browse files

handle the case of invlide evidence id (can happen if we restart the server)

parent 82a35337
No related branches found
No related tags found
No related merge requests found
......@@ -36,9 +36,23 @@ class Feedback extends Model
}
}
private $report = null;
public function report() : \Cylab\Mark\Evidence
{
return Mark::get()->findEvidenceById($this->report_id);
if ($this->report != null) {
return $this->report;
}
try {
$this->report = Mark::get()->findEvidenceById($this->report_id);
} catch (\JsonRPC\Exception\ServerErrorException $ex) {
// may happen if the saved id is invalid (old data)
// should be replace by a static call Evidence::getNullReport()
$this->report = new \Cylab\Mark\Evidence(["id" => "?", "label" => "?", "time" => 0, "subject" => [], "score" => 0, "report" => "", "references" => [], "requests" => [], "profile" => ["label" => ""]]);
}
return $this->report;
}
public static function findByReportId(string $id)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment