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).
CommentFileSizeAuthor
#2 eck-compatability-3013157-2.patch878 bytesmpriscella

Comments

demonde created an issue. See original summary.

mpriscella’s picture

Assigned: Unassigned » mpriscella
Status: Active » Needs review
StatusFileSize
new878 bytes

Looks 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!

demonde’s picture

Yes, thanks, this works for me. No more error message.

mpriscella’s picture

Status: Needs review » Reviewed & tested by the community

Great! I'll merge this in when I get a chance.

demonde’s picture

Thanks. :-)

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.

mpriscella’s picture

I'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\EntityPublishedTrait trait) before making any modifications on it, such as adding the custom validation. I'll check though!

  • mpriscella committed 91c9db7 on 8.x-1.x
    Issue #3013157 by mpriscella, demonde: Required on publish is not...
mpriscella’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.