If a referenced media item goes missing for any reason, a PHP fatal error is encountered when rendering the page.

This happens in \Drupal\entity_browser_block\Plugin\Block\EntityBrowserBlock::build when looping over $entities.

An easy fix will be to check for emptiness first thing in that loop. A very helpful addition would be to prevent the deleting of referenced entities.

Comments

nadavoid created an issue. See original summary.

nadavoid’s picture

This patch checks at the beginning of the loop whether the entity is empty. If it is, it continues, skipping that iteration of the loop.

nadavoid’s picture

Assigned: nadavoid » Unassigned
Status: Active » Needs review
karens’s picture

Status: Needs review » Reviewed & tested by the community

I ran into this problem as well and the patch fixes it.

Without the patch, if a referenced item is deleted, the page won't build and fails with a fatal error. With the patch it builds and just doesn't display the broken item.

chris matthews’s picture

  • nadavoid authored 9e128e0 on 8.x-1.x
    Issue #3006352 by nadavoid, KarenS: Broken references cause fatal errors...
samuel.mortenson’s picture

Status: Reviewed & tested by the community » Fixed

Thanks all!

Status: Fixed » Closed (fixed)

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