Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting a collection with children causes error with islandora_breadcrumbs module #1559

Closed
ainsofs opened this issue Jul 6, 2020 · 2 comments

Comments

@ainsofs
Copy link

ainsofs commented Jul 6, 2020

Steps to re-create:

  1. Install default Islandora from Ansible
  2. Create a collection
  3. Add children
  4. Delete collection
  5. View child object

Work-around

Disabling islandora_breadcrumbs module or commenting out line 111 (as below) makes it work

/var/www/html/drupal/web/modules/contrib/islandora/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php

108    // Find the next in the chain, if there are any.
109    if ($entity->hasField($this->config->get('referenceField')) &&
110      !$entity->get($this->config->get('referenceField'))->isEmpty()) {
111      // $this->walkMembership($entity->get($this->config->get('referenceField'))->entity, $crumbs);
112    }

Error

The website encountered an unexpected error. Please try again later.
TypeError: Argument 1 passed to Drupal\islandora_breadcrumbs\IslandoraBreadcrumbBuilder::walkMembership() must implement interface Drupal\Core\Entity\EntityInterface, null given, called in /var/www/html/drupal/web/modules/contrib/islandora/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php on line 111 in Drupal\islandora_breadcrumbs\IslandoraBreadcrumbBuilder->walkMembership() (line 93 of modules/contrib/islandora/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php).
Drupal\islandora_breadcrumbs\IslandoraBreadcrumbBuilder->walkMembership(NULL, Array) (Line: 111)
Drupal\islandora_breadcrumbs\IslandoraBreadcrumbBuilder->walkMembership(Object, Array) (Line: 72)
Drupal\islandora_breadcrumbs\IslandoraBreadcrumbBuilder->build(Object) (Line: 83)
Drupal\Core\Breadcrumb\BreadcrumbManager->build(Object) (Line: 72)
Drupal\system\Plugin\Block\SystemBreadcrumbBlock->build() (Line: 171)
Drupal\block\BlockViewBuilder::preRender(Array)
@ainsofs
Copy link
Author

ainsofs commented Jul 6, 2020

Patch

Not tested but below seems to get rid of the error

diff --git a/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php b/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php
index c58e700..86090ff 100644
--- a/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php
+++ b/modules/islandora_breadcrumbs/src/IslandoraBreadcrumbBuilder.php
@@ -107,7 +107,8 @@ class IslandoraBreadcrumbBuilder implements BreadcrumbBuilderInterface {
 
     // Find the next in the chain, if there are any.
     if ($entity->hasField($this->config->get('referenceField')) &&
-      !$entity->get($this->config->get('referenceField'))->isEmpty()) {
+      !$entity->get($this->config->get('referenceField'))->isEmpty() &&
+      $entity->get($this->config->get('referenceField'))->entity instanceof EntityInterface) {
       $this->walkMembership($entity->get($this->config->get('referenceField'))->entity, $crumbs);
     }
   }

@dannylamb
Copy link
Contributor

Resolved via Islandora/islandora@bfab343

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants