Closed andybroomfield closed 1 year ago
Additional, wrapping this in an empty block will also cause this error on the twig
The website encountered an unexpected error. Please try again later. AssertionError: $url must be a string or object of type \Drupal\Core\Url in assert() (line 246 of core/lib/Drupal/Core/Template/TwigExtension.php). Becuase the subsite overview link will have no url. so subsite-navigation.html.twig needs to be updated with
{% if item.url is not empty %} {{ link(item.title, item.url) }} {% endif %}
Would there be an objection to me applying the first fix?
Wrapping an empty check around this and setting subsite_id ?? NULL if blank does seem to resolve this issue,
When a comms officer was trying to share a preview link to a subsite page that wasn't public yet, they encountered a problem for those clicking the link, as they where getting the WSOD technicalk difficulties message.
On closer inspection, the following PHP error was being triggered.
This occurs as the subsitenavigationblock is building all menu links using
$entities = $mapper->loadAndAccessCheckEntitysForTreeNodes('node', $tree, $cache);
and then tries to get the subsite id using$subsite_id = $entities[$ancestors[0]]->id();
. But since the overview is unpublished, this will fail as its blank. Wrapping an empty check around this and setting subsite_id ?? NULL if blank does seem to resolve this issue, though it's not an ideal fix.Steps to replicate
Expected result Subsite page is shown, albeit with only the page in the navigation menu
Actual resule WSOD, PHP error or technical difficulities message depending on setup.