diff --git a/app/Feedback.php b/app/Feedback.php index 09eb4c0e7c8574e1a40ac6094d3ebf8eb2d6783c..84713ed827e9ebfefa1055107990322cb6345a67 100644 --- a/app/Feedback.php +++ b/app/Feedback.php @@ -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)