Required on publish is not compatible with Entity Construction Kit (ECK) project.
I get the following error message on saving a field that is required on publish within an ECK entity bundle:
The website encountered an unexpected error. Please try again later.
Error: Call to undefined method Drupal\eck\Entity\EckEntity::isPublished() in Drupal\require_on_publish\Plugin\Validation\Constraint\RequireOnPublishValidator->validate() (line 53 of modules/require_on_publish/src/Plugin/Validation/Constraint/RequireOnPublishValidator.php).| Comment | File | Size | Author |
|---|---|---|---|
| #2 | eck-compatability-3013157-2.patch | 878 bytes | mpriscella |
Comments
Comment #2
mpriscella commentedLooks like the issue is that the validator assumes that any entity that is the parent of a paragraph is publishable. Here's a patch which removes that assumption. I'll attempt testing later tonight, but if you could test it out and let me know if it works for you that'd be great!
Comment #3
demonde commentedYes, thanks, this works for me. No more error message.
Comment #4
mpriscella commentedGreat! I'll merge this in when I get a chance.
Comment #5
demonde commentedThanks. :-)
Maybe it is worth checking if the module is calling other methods that are only node entity related and would cause error messages in case of an entity that does not have these entity properties. I have not checked this yet.
The steps to reproduce is to create a ECK entity without any properties with a field with require on publish.
Comment #6
mpriscella commentedI'll take another look through the code, but I'm fairly confident that there aren't any other instances where this could happen. All of the other functionality in the module checks to ensure that an entity is publishable (uses the
Drupal\Core\Entity\EntityPublishedTraittrait) before making any modifications on it, such as adding the custom validation. I'll check though!Comment #8
mpriscella commented