Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
Should be \Drupal\Core\Entity\ContentEntityInterface instead of \Drupal\Core\Entity\ContentEntityTypeInterface IMHO.
Comment | File | Size | Author |
---|---|---|---|
ContentEntityFormInterface.patch | 733 bytes | Patrick R. | |
Comments
Comment #2
kevinvhengst CreditAttribution: kevinvhengst as a volunteer commentedHi Patrick,
I believe you are right.
Drupal/Core/Entity/ContentEntityForm.php
is the only class implementingContentEntityFormInterface
and when inspecting that implementation of thevalidateForm()
method inDrupal/Core/Entity/ContentEntityForm.php
you will notice this piece of code:It clearly states
$entity
is of type\Drupal\Core\Entity\ContentEntityInterface
. In my opinion it does return the correct type and the return type ofvalidateForm()
method inContentEntityFormInterface
is incorrect.Your patch solves this error.
This issue is also applicable on Drupal
9.0.x
.Comment #3
kevinvhengst CreditAttribution: kevinvhengst as a volunteer commentedComment #4
alexpottSo I think what's really odd here is that the return is never used. We do return an entity in \Drupal\Core\Entity\ContentEntityConfirmFormBase::validateForm() and \Drupal\contact\MessageForm::validateForm() and \Drupal\Core\Entity\ContentEntityForm::validateForm() but nearly every contrib implementation I have locally does not do this. They are all more like \Drupal\taxonomy\TermForm::validateForm() which ignores the return value.
This is a bit of a twisted web because now we're in a world where people are relying on \Drupal\Core\Entity\ContentEntityForm::validateForm to return an entity but the form system definitely doesn't require or use this return value. I guess given that some forms that extend ContentEntityForm are relying on the return value we have to fix this and then when strict return types come along we'll have to fix the broken implementations.
Committed and pushed 74d51c95ee to 9.1.x and 8ecae1e36d to 9.0.x and 96ec6856b8 to 8.9.x. Thanks!