You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Islandora code can break drupal site when a new content type has an entity reference field.
The offending code is here and can be fixed in a couple different ways:
protected function evaluateEntity(EntityInterface $entity) {
foreach ($entity->referencedEntities() as $referenced_entity) {
if ($entity->getEntityTypeID() == 'node' && $referenced_entity->getEntityTypeId() == 'node') {
$parent_reference_field = $this->configuration['parent_reference_field'];
$field = $entity->get($parent_reference_field);
The easiest way to fix this is to check that the referenced nodes are bundle() = islandora_object. Another approach would be to check $entity hasField($parent_reference_field) before trying to get it. This change does the trick nicely.
if ($entity->getEntityTypeID() == 'node' && $entity->bundle() == 'islandora_object' && $referenced_entity->getEntityTypeId() == 'node') {
What steps does it take to reproduce the issue?
log in and create a new content type
add a field called "nodes" which is Entity Reference type & save new content type
make sure there is a context rule which has a "Node has parent" condition. If there isn't one, just add a basic rule (I believe that Islandora comes with such a context rule already configured)
now, create a node of this type -- add at least one entity to the "nodes" field and save. The error occurs when this new node is now edited.
When does this issue occur?
When Islandora code runs through possible context rules and any rule has the "Node has parent" condition.
Which page does it occur on?
The error occurs on the node/{nid}/edit route for the new content type.
What happens?
Because the new content type "nodes" does not have the field which is checked inside this logic (only "islandora_object" has this), there is a fatal error when trying to edit these.
To whom does it occur (anonymous visitor, editor, administrator)?
User who attempts to edit the new "nodes" node.
What did you expect to happen?
There should be no error.
Which version of Islandora are you using?
latest 2.x
Which method did you use to install your Islandora instance? (manually, ISLE, playbook, etc.)
ISLE
Any related open or closed issues to this bug report?
not yet
The text was updated successfully, but these errors were encountered:
To properly address this, I should use the "hasField" method to check that the entity has the field before trying to get it. The other method is potentially bad only because the name of "islandora_object" is not guaranteed to be the same or if an organization copies that content type to extend functionality, the "hasField" would work on each of those and would never throw this error.
Islandora code can break drupal site when a new content type has an entity reference field.
The offending code is here and can be fixed in a couple different ways:
The easiest way to fix this is to check that the referenced nodes are
bundle() = islandora_object
. Another approach would be to check$entity hasField($parent_reference_field)
before trying to get it. This change does the trick nicely.if ($entity->getEntityTypeID() == 'node' && $entity->bundle() == 'islandora_object' && $referenced_entity->getEntityTypeId() == 'node') {
What steps does it take to reproduce the issue?
When does this issue occur?
When Islandora code runs through possible context rules and any rule has the "Node has parent" condition.
Which page does it occur on?
The error occurs on the node/{nid}/edit route for the new content type.
What happens?
Because the new content type "nodes" does not have the field which is checked inside this logic (only "islandora_object" has this), there is a fatal error when trying to edit these.
To whom does it occur (anonymous visitor, editor, administrator)?
User who attempts to edit the new "nodes" node.
What did you expect to happen?
There should be no error.
Which version of Islandora are you using?
latest 2.x
Which method did you use to install your Islandora instance? (manually, ISLE, playbook, etc.)
ISLE
Any related open or closed issues to this bug report?
not yet
The text was updated successfully, but these errors were encountered: