diff --git a/api/v1/entries/productissues.php b/api/v1/entries/productissues.php index 2769896bd3..294cbe18ee 100644 --- a/api/v1/entries/productissues.php +++ b/api/v1/entries/productissues.php @@ -92,8 +92,13 @@ class productIssuesEntry extends entry $taskTypeMap = array_flip($this->app->lang->task->typeList); $bugTypeMap = array_flip($this->app->lang->bug->typeList); + $labelExistStatus = array(); /* Set this value to judge if label is not exist. Exist => true, not Exist => false. */ + $objectTypeMap = array_merge(array_keys(array_merge($storyTypeMap, $taskTypeMap, $bugTypeMap)), array($this->app->lang->story->common, $this->app->lang->task->common, $this->app->lang->bug->common)); foreach($labels as $label) { + /* Set label exist status. */ + $labelExistStatus[$label] = in_array($label, $objectTypeMap) ? true : false; + if($label == $this->app->lang->story->common) $storyFilter[] = 'all'; if(isset($storyTypeMap[$label])) $storyFilter[] = $storyTypeMap[$label]; @@ -103,6 +108,9 @@ class productIssuesEntry extends entry if($label == $this->app->lang->bug->common) $bugFilter[] = 'all'; if(isset($bugTypeMap[$label])) $bugFilter[] = $bugTypeMap[$label]; } + + /* Return empty result if one label is not exists. We assume user usually input one label to search by labels. */ + if(in_array(false, $labelExistStatus) and empty($storyFilter) and empty($taskFilter) and empty($bugFilter)) $this->send(200, array('page' => $page, 'total' => 0, 'limit' => $limit, 'issues' => array())); } if(!empty($storyFilter)) $labelTypes[] = 'story';