Harden XB content dependency calculation infrastructure to not cause a PHP fatal error when content entities have disappeared whose deletion should have been prevented
>>> [!note] Migrated issue
<!-- Drupal.org comment -->
<!-- Migrated from issue #3544213. -->
Reported by: [penyaskito](https://www.drupal.org/user/959536)
>>>
<h3 id="overview">Overview</h3>
<p>Error when calculating dependencies if I delete a referenced media file in a page.</p>
<h4>Steps to Reproduce:</h4>
<ol>
<li>Enable xb_sdc_test</li>
<li>Create a xb_page</li>
<li>Add a card</li>
<li>Reference some media.</li>
<li>Publish.</li>
<li>Delete the media in the media library.</li>
<li>Run <code>ddev php core/scripts/drupal content:export xb_page 1 -W</code></li>
</ol>
<p><strong>Note:</strong></p>
<p>I found this while working on <span class="drupalorg-gitlab-issue-link drupalorg-gitlab-link-wrapper"><a href="https://git.drupalcode.org/project/canvas/-/work_items/3534561" class="drupalorg-gitlab-link">https://git.drupalcode.org/project/canvas/-/work_items/3534561</a></span>, but I think this underlaying bug could be triggered in some other way with HEAD and it's out of scope there.</p>
<pre>TypeError: Drupal\experience_builder\PropExpressions\StructuredData\ReferenceFieldTypePropExpression::Drupal\experience_builder\PropExpressions\StructuredData\{closure}(): Argument #1 ($entity) must be of type Drupal\Core\Entity\FieldableEntityInterface, null given in /var/www/html/modules/experience_builder/src/PropExpressions/StructuredData/ReferenceFieldTypePropExpression.php on line 54 #0 [internal function]: Drupal\experience_builder\PropExpressions\StructuredData\ReferenceFieldTypePropExpression->Drupal\experience_builder\PropExpressions\StructuredData\{closure}()<br>#1 /var/www/html/modules/experience_builder/src/PropExpressions/StructuredData/ReferenceFieldTypePropExpression.php(53): array_map()<br>#2 /var/www/html/modules/experience_builder/src/PropExpressions/StructuredData/FieldTypeObjectPropsExpression.php(66): Drupal\experience_builder\PropExpressions\StructuredData\ReferenceFieldTypePropExpression->calculateDependencies()<br>#3 /var/www/html/modules/experience_builder/src/PropSource/StaticPropSource.php(536): Drupal\experience_builder\PropExpressions\StructuredData\FieldTypeObjectPropsExpression->calculateDependencies()<br>#4 /var/www/html/modules/experience_builder/src/Plugin/DataType/ComponentInputs.php(55): Drupal\experience_builder\PropSource\StaticPropSource->calculateDependencies()<br>#5 /var/www/html/modules/experience_builder/src/Plugin/Field/FieldType/ComponentTreeItem.php(153): Drupal\experience_builder\Plugin\DataType\ComponentInputs->calculateDependencies()<br>#6 /var/www/html/modules/experience_builder/src/EventSubscriber/DefaultContentSubscriber.php(40): Drupal\experience_builder\Plugin\Field\FieldType\ComponentTreeItem->calculateFieldItemValueDependencies()<br>#7 /var/www/html/core/lib/Drupal/Core/DefaultContent/Exporter.php(234): Drupal\experience_builder\EventSubscriber\DefaultContentSubscriber->Drupal\experience_builder\EventSubscriber\{closure}()</pre><h3 id="proposed-resolution">Proposed resolution</h3>
<h3 id="ui-changes">User interface changes</h3>
> Related issue: [Issue #3532615](https://www.drupal.org/node/3532615)
issue