Error: Call to undefined method Drupal\Core\Field\InternalViolation::getConstraint() in Drupal\entityqueue\Plugin\Field\FieldWidget\EntityqueueDragtableWidget->errorElement()

Created on 18 January 2023, over 1 year ago

Problem/Motivation

Error: Call to undefined method Drupal\Core\Field\InternalViolation::getConstraint() in Drupal\entityqueue\Plugin\Field\FieldWidget\EntityqueueDragtableWidget->errorElement() (line 167 of /<redacted>/web/modules/contrib/entityqueue/src/Plugin/Field/FieldWidget/EntityqueueDragtableWidget.php) 

Steps to reproduce

The error is triggered when trying to edit/save an entity queue that was previously filled by an admin, but is now being edited by a user with less privileges. This is the error that should display if the code didn't fail:

This entity (%type: %id) cannot be referenced.

The class that causes the code to fail is Drupal\Core\Field\InternalViolation, which was introduced in Drupal 9.5.0-beta1, so you should use at least that version to test.

Proposed resolution

The new Drupal\Core\Field\InternalViolation class doesn't have a way to get the constraint, so I suggest checking the message template instead. The getMessageTemplate method is part of ConstraintViolationInterface, while the getConstraint method isn't.

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡§πŸ‡ͺBelgium DieterHolvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.69.0 2024