From 6907334768767eb5773a2505125f458b648bc94e Mon Sep 17 00:00:00 2001 From: dbenkert Date: Wed, 15 May 2019 12:16:10 +0200 Subject: [PATCH] added collection/table to InvalidFieldException --- .../Directus/Database/Exception/InvalidFieldException.php | 4 ++-- .../Database/TableGateway/RelationalTableGateway.php | 6 +++--- src/core/Directus/Services/TablesService.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/Directus/Database/Exception/InvalidFieldException.php b/src/core/Directus/Database/Exception/InvalidFieldException.php index 5c0ee229bf..189b008956 100644 --- a/src/core/Directus/Database/Exception/InvalidFieldException.php +++ b/src/core/Directus/Database/Exception/InvalidFieldException.php @@ -8,9 +8,9 @@ class InvalidFieldException extends UnprocessableEntityException { const ERROR_CODE = 202; - public function __construct($field) + public function __construct($field, $collection) { - $message = sprintf('Invalid field "%s"', $field); + $message = sprintf('Invalid field "%s" in "%s"', $field, $collection); parent::__construct($message); } diff --git a/src/core/Directus/Database/TableGateway/RelationalTableGateway.php b/src/core/Directus/Database/TableGateway/RelationalTableGateway.php index a177336285..baadf254c2 100644 --- a/src/core/Directus/Database/TableGateway/RelationalTableGateway.php +++ b/src/core/Directus/Database/TableGateway/RelationalTableGateway.php @@ -1318,7 +1318,7 @@ protected function doFilter(Builder $query, $column, $condition, $table) ); if (!$field) { - throw new Exception\InvalidFieldException($fieldName); + throw new Exception\InvalidFieldException($fieldName, $table); } $condition = $this->parseCondition($condition); @@ -1587,7 +1587,7 @@ protected function processSort(Builder $query, array $columns) $field = SchemaService::getField($this->table, $orderBy, false, $this->acl === null); if ($orderBy !== '?' && !$field) { - throw new Exception\InvalidFieldException($column); + throw new Exception\InvalidFieldException($column, $this->table); } if ($field && $field->isAlias()) { @@ -2048,7 +2048,7 @@ public function validateFields(array $fields) foreach ($selectedFields as $field) { if (!$collection->hasField($field)) { - throw new Exception\InvalidFieldException($field); + throw new Exception\InvalidFieldException($field, $collection->getName()); } } } diff --git a/src/core/Directus/Services/TablesService.php b/src/core/Directus/Services/TablesService.php index 62b4845b42..1d5395ab6c 100644 --- a/src/core/Directus/Services/TablesService.php +++ b/src/core/Directus/Services/TablesService.php @@ -1683,7 +1683,7 @@ protected function getAllFieldsParams(array $params) foreach ($sort as $field) { $field = (string)$field; if (!$collection->hasField($field)) { - throw new InvalidFieldException($field); + throw new InvalidFieldException($field, $collection->getName()); } } }