Skip to content
This repository has been archived by the owner on Jan 6, 2023. It is now read-only.

Commit

Permalink
throw item not found on no read permission on single id
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Jul 17, 2018
1 parent 65207be commit 6480f33
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/core/Directus/Services/ItemsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Directus\Database\RowGateway\BaseRowGateway;
use Directus\Database\Schema\SchemaManager;
use Directus\Exception\ForbiddenException;
use Directus\Permissions\Exception\ForbiddenCollectionReadException;
use Directus\Util\StringUtils;
use Directus\Validator\Exception\InvalidRequestException;
use Zend\Db\TableGateway\TableGateway;

Expand Down Expand Up @@ -74,13 +76,27 @@ public function find($collection, $id, array $params = [])
* @param array $params
*
* @return array
*
* @throws ItemNotFoundException
* @throws ForbiddenCollectionReadException
*/
public function findByIds($collection, $ids, array $params = [])
{
$statusValue = $this->getStatusValue($collection, $ids);
$tableGateway = $this->createTableGateway($collection);
if (is_string($ids) && StringUtils::has($ids, ',')) {
$ids = StringUtils::csv((string)$ids, false);
}

$this->getAcl()->enforceRead($collection, $statusValue);
try {
$this->getAcl()->enforceRead($collection, $statusValue);
} catch (ForbiddenCollectionReadException $e) {
if (is_array($ids) && count($ids) > 1) {
throw new $e;
} else {
throw new ItemNotFoundException();
}
}

return $this->getItemsByIdsAndSetResponseCacheTags($tableGateway, $ids, array_merge($params, [
'status' => null
Expand Down

0 comments on commit 6480f33

Please sign in to comment.