diff --git a/api/v1/entries/bug.php b/api/v1/entries/bug.php index dbd41b1fa1..44c82e98e1 100644 --- a/api/v1/entries/bug.php +++ b/api/v1/entries/bug.php @@ -24,7 +24,11 @@ class bugEntry extends entry $control->view($bugID); $data = $this->getData(); - $bug = $data->data->bug; + + if(!$data or !isset($data->status)) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message); + + $bug = $data->data->bug; /* Set product name */ $bug->productName = $data->data->product->name; diff --git a/api/v1/entries/story.php b/api/v1/entries/story.php index 00d0eac8d7..be918e803b 100644 --- a/api/v1/entries/story.php +++ b/api/v1/entries/story.php @@ -23,7 +23,11 @@ class storyEntry extends Entry $control = $this->loadController('story', 'view'); $control->view($storyID); - $data = $this->getData(); + $data = $this->getData(); + + if(!$data or !isset($data->status)) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return isset($data->code) and $data->code == 404 ? $this->send404() : $this->sendError(400, $data->message); + $story = $data->data->story; if(!empty($story->children)) $story->children = array_values((array)$story->children); diff --git a/module/common/model.php b/module/common/model.php index 06ad9ee399..a752ccf8c8 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1865,9 +1865,10 @@ EOD; { $queryObjects = $this->dao->query($sql); $objectList = array(); + $key = 'id'; while($object = $queryObjects->fetch()) { - $key = (!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) ? 'case' : 'id'; + if(!$this->session->$typeOnlyCondition and $type == 'testcase' and isset($object->case)) $key = 'case'; $id = $object->$key; $objectList[$id] = $id; }