localgovdrupal / localgov_subsites

Replaces LocalGov Campaigns with a new name and extended functionality to support subsites within LocalGov Drupal installations.
GNU General Public License v2.0
4 stars 2 forks source link

Create a subsite page using front end theme causes WSOD #154

Closed andybroomfield closed 3 months ago

andybroomfield commented 3 months ago

Eg. Using Mercury Editor which uses the front end theme for layout paragraphs.

TypeError: PNX\NestedSet\NodeKey::__construct(): Argument 1 ($id) must be of type string|int, null given, called in /Users/Andy/Sites/bhcclocalgov/docroot/modules/contrib/entity_hierarchy/src/Storage/NestedSetNodeKeyFactory.php on line 29 in PNX\NestedSet\NodeKey->__construct() (line 21 of /Users/Andy/Sites/bhcclocalgov/vendor/previousnext/nested-set/src/NodeKey.php).

Traced this to the get subsite method

Drupal\entity_hierarchy\Storage\NestedSetNodeKeyFactory->fromEntity(Object) (Line: 118) Drupal\localgov_subsites\Plugin\Block\SubsitesAbstractBlockBase->getRootId(Object) (Line: 80) Drupal\localgov_subsites\Plugin\Block\SubsitesAbstractBlockBase->getSubsite() (Line: 155) Drupal\localgov_subsites\Plugin\Block\SubsitesNavigationBlock->blockAccess(Object) (Line: 127)

The subsite is trying to get the rootID for the navigation block, but since no parent is yet set as it's being created, it can't.

We should short circuit it if we are trying to create a new node.