--- entity_violations_1.patch 2015-02-28 04:01:56.000000000 +1100 +++ 2395831-entity-violations-40.patch 2015-03-07 13:34:19.000000000 +1100 @@ -1,8 +1,8 @@ diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php -index f6122cf..f041461 100644 +index a11d560..dac5645 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php -@@ -278,7 +278,8 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco +@@ -269,7 +269,8 @@ public function preSaveRevision(EntityStorageInterface $storage, \stdClass $reco * {@inheritdoc} */ public function validate() { @@ -13,7 +13,7 @@ /** diff --git a/core/lib/Drupal/Core/Entity/ContentEntityForm.php b/core/lib/Drupal/Core/Entity/ContentEntityForm.php -index 97f4c51..3b91a48 100644 +index 35834ab..130a8e0 100644 --- a/core/lib/Drupal/Core/Entity/ContentEntityForm.php +++ b/core/lib/Drupal/Core/Entity/ContentEntityForm.php @@ -69,8 +69,11 @@ public function form(array $form, FormStateInterface $form_state) { @@ -29,7 +29,7 @@ // @todo Remove this. // Execute legacy global validation handlers. -@@ -79,6 +82,33 @@ public function validate(array $form, FormStateInterface $form_state) { +@@ -80,6 +83,33 @@ public function validate(array $form, FormStateInterface $form_state) { } /** @@ -465,24 +465,23 @@ * succeeded. */ diff --git a/core/modules/comment/src/CommentForm.php b/core/modules/comment/src/CommentForm.php -index a9d742b..219780f 100644 +index c38cf5e..d7783a4 100644 --- a/core/modules/comment/src/CommentForm.php +++ b/core/modules/comment/src/CommentForm.php -@@ -12,6 +12,7 @@ - use Drupal\Component\Utility\Unicode; +@@ -14,6 +14,7 @@ + use Drupal\Core\Cache\Cache; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\ContentEntityForm; +use Drupal\Core\Entity\EntityConstraintViolationListInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Language\LanguageInterface; -@@ -286,20 +287,14 @@ public function buildEntity(array $form, FormStateInterface $form_state) { +@@ -291,21 +292,14 @@ public function buildEntity(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function validate(array $form, FormStateInterface $form_state) { -- parent::validate($form, $form_state); -- $comment = $this->buildEntity($form, $form_state); +- $comment = parent::validate($form, $form_state); - - // Customly trigger validation of manually added fields and add in - // violations. @@ -497,12 +496,14 @@ + foreach ($violations->filterByField('name') as $violation) { $form_state->setErrorByName('name', $violation->getMessage()); } +- +- return $comment; + parent::flagViolations($violations, $form, $form_state); } /** diff --git a/core/modules/node/src/NodeForm.php b/core/modules/node/src/NodeForm.php -index 17066ab..f36ac4e 100644 +index 92e7c0c..f36ac4e 100644 --- a/core/modules/node/src/NodeForm.php +++ b/core/modules/node/src/NodeForm.php @@ -290,19 +290,6 @@ protected function actions(array $form, FormStateInterface $form_state) { @@ -511,13 +512,13 @@ * {@inheritdoc} - */ - public function validate(array $form, FormStateInterface $form_state) { -- $node = $this->buildEntity($form, $form_state); +- $node = parent::validate($form, $form_state); - - if ($node->id() && (node_last_changed($node->id(), $this->getFormLangcode($form_state)) > $node->getChangedTime())) { - $form_state->setErrorByName('changed', $this->t('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.')); - } - -- parent::validate($form, $form_state); +- return $node; - } - - /** @@ -542,7 +543,7 @@ $message = "Unprocessable Entity: validation failed.\n"; foreach ($violations as $violation) { diff --git a/core/modules/user/src/AccountForm.php b/core/modules/user/src/AccountForm.php -index 033731f..fd68ebe 100644 +index 73055ef..83f18a9 100644 --- a/core/modules/user/src/AccountForm.php +++ b/core/modules/user/src/AccountForm.php @@ -9,6 +9,7 @@ @@ -553,15 +554,14 @@ use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormStateInterface; -@@ -382,14 +383,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { +@@ -383,13 +384,7 @@ public function buildEntity(array $form, FormStateInterface $form_state) { /** * {@inheritdoc} */ - public function validate(array $form, FormStateInterface $form_state) { -- parent::validate($form, $form_state); -- - /** @var \Drupal\user\UserInterface $account */ -- $account = $this->buildEntity($form, $form_state); +- $account = parent::validate($form, $form_state); +- - // Customly trigger validation of manually added fields and add in - // violations. This is necessary as entity form displays only invoke entity - // validation for fields contained in the display. @@ -569,7 +569,7 @@ $field_names = array( 'name', 'mail', -@@ -400,12 +394,11 @@ public function validate(array $form, FormStateInterface $form_state) { +@@ -400,14 +395,11 @@ public function validate(array $form, FormStateInterface $form_state) { 'preferred_langcode', 'preferred_admin_langcode' ); @@ -582,6 +582,8 @@ + list($field_name) = explode('.', $violation->getPropertyPath(), 2); + $form_state->setErrorByName($field_name, $violation->getMessage()); } +- +- return $account; + parent::flagViolations($violations, $form, $form_state); }