Skip to content

Fix WSOD on subsites when creating subsite page in front end theme #155

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 6, 2024

Conversation

andybroomfield
Copy link
Contributor

@andybroomfield andybroomfield commented Aug 1, 2024

Fix #154

What does this change?

Checks the entity ID is numeric (is not null) when trying to find subsite.
Adds a test to verify status code is 200 (500 without this fix).

How to test

  1. Set appearance to use the front end theme as the admin theme, or use an editor like mercury editor.
  2. Create a new Subsite page at /node/add/localgov_subsite_page
  3. Should be able to add a page without errors.

How can we measure success?

Creating a subsite page no longer crashes.

Have we considered potential risks?

Need to check side effects on the blocks not finding their subsite.
I noticed that using is_int does fail as $entity->id() brings back a string, might fail strict types.

Images

N/A - Using front end theme is optional for sites that want to do so.

Accessibility

N/A

Fix #154

Checks the entity ID is numeric (is not null) when trying to find subsite.
Adds a test to verify status code is 200 (500 without this fix).
@andybroomfield andybroomfield marked this pull request as ready for review August 1, 2024 14:12
@@ -114,6 +114,7 @@ protected function getRootId(EntityInterface $entity): ?int {
'localgov_subsites_overview',
'localgov_subsites_page',
], TRUE)
&& is_numeric($entity->id())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would changing to is_null work if it could be a string?

Suggested change
&& is_numeric($entity->id())
&& !is_null($entity->id())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can try that, if that would be more correct.

Copy link
Member

@stephen-cox stephen-cox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't checked this fixes creating a node through the a frontend editor, but the change fixes what the test checks and it doesn't look to have any other side-effects.

@ekes ekes merged commit 4392ae7 into 2.x Aug 6, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a subsite page using front end theme causes WSOD
4 participants