Details
-
Improvement
-
Resolution: Unresolved
-
Medium
-
None
-
1.13.3, 5.4.12, 1.7.8, 2.2.2
-
None
Description
See https://jira.ez.no/browse/EZP-28258 for background information and steps to reproduce.
When using the API to save/publish a Content Object that has ezselection Field Type with the selected option that no longer exists (because it was deleted from the Content Type definition) the following error is returned:
[eZ\Publish\Core\Base\Exceptions\ContentFieldValidationException]
Content fields did not validate
This doesn't tell you which field failed, and why. It can be done by hardcoding in ContentFieldValidationException, but this is obviously not a viable solution for the product:
diff --git a/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php b/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php index 913462637..f01bc370a 100644 --- a/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php +++ b/eZ/Publish/Core/Base/Exceptions/ContentFieldValidationException.php @@ -38,7 +38,13 @@ class ContentFieldValidationException extends APIContentFieldValidationException public function __construct(array $errors) { $this->errors = $errors; - parent::__construct('Content fields did not validate'); +$str = ''; +foreach($this->getFieldErrors() as $fieldError) { + $str .= "\n" . str_replace('%index%', + $fieldError['eng-GB'][0]->getTranslatableMessage()->values['index'], + $fieldError['eng-GB'][0]->getTranslatableMessage()->message); +} + parent::__construct('Content fields did not validate' . $str); } /**
https://gist.github.com/glye/5cefe0e3036ebc09210262be123b5f31
It seems a proper solution will require a BC break.
Attachments
Issue Links
- relates to
-
EZP-28258 Can't publish/save content with missing Selection option
- Closed