diff --git a/web/modules/custom/usa_orphaned_entities/usa_orphaned_entities.module b/web/modules/custom/usa_orphaned_entities/usa_orphaned_entities.module
index a3c11fdfce..41def7a28f 100644
--- a/web/modules/custom/usa_orphaned_entities/usa_orphaned_entities.module
+++ b/web/modules/custom/usa_orphaned_entities/usa_orphaned_entities.module
@@ -75,7 +75,6 @@ function usa_orphaned_entities_form_alter(&$form, &$form_state, $form_id) {
$additional .= "
" . PHP_EOL;
foreach ($reference_data['skip']['references'] as $reference_skip) {
- $url = $reference_skip->toUrl();
$id = $reference_skip->id();
$type = $reference_skip->getEntityTypeId();
$title = $reference_skip->label();
@@ -89,10 +88,21 @@ function usa_orphaned_entities_form_alter(&$form, &$form_state, $form_id) {
$type = $reference_skip->getEntityTypeId() . ' / ' . $reference_skip->bundle();
break;
}
- $additional .= sprintf(
- '- %s: %s (%d)
' . PHP_EOL,
- $url->toString(), $type, Html::escape($title), $id
- );
+
+ // Some entities, like paragraphs, don't have a link template
+ // which makes call to toUrl() fail.
+ if ($reference_skip->hasLinkTemplate('canonical')) {
+ $additional .= sprintf(
+ '- %s: %s (%d)
' . PHP_EOL,
+ $reference_skip->toUrl()->toString(), $type, Html::escape($title), $id
+ );
+ }
+ else {
+ $additional .= sprintf(
+ '- %s: %s (%d)
' . PHP_EOL,
+ $type, Html::escape($title), $id
+ );
+ }
}
$additional .= "
" . PHP_EOL;