-
Notifications
You must be signed in to change notification settings - Fork 1
Conversation
andybroomfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we should change the check to load the node if it is an int first, and then run this lest.
eg.
if (is_int($node) {
$node = Node::load($node);
}See inline comment for rationale.
localgov_theme.theme
Outdated
| // Allow page template to be overridden by content type. | ||
| if ($hook == 'page' && $node = \Drupal::routeMatch()->getParameter('node')) { | ||
| $node = \Drupal::routeMatch()->getParameter('node'); | ||
| if ($hook == 'page' && $node instanceof NodeInterface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to add the right hook when viewing a revision, else we don't get an accurate preview. So I suggest loading the node if it is an int.
<!-- FILE NAME SUGGESTIONS:
x page--localgov-campaigns-page.html.twig
* page--node--29.html.twig
* page--node--%.html.twig
* page--node.html.twig
* page.html.twig
-->
And on a revision
<!-- FILE NAME SUGGESTIONS:
* page--node--revisions--view.html.twig
* page--node--revisions--96.html.twig
* page--node--revisions--%.html.twig
* page--node--revisions.html.twig
* page--node--29.html.twig
* page--node--%.html.twig
* page--node.html.twig
x page.html.twig
-->
(Assume same issue will be for subsites)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@paulpopus does this make sense to you? If not, give me a shout and we can discuss it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!$node instanceof NodeInterface) {
$node = Node::load((int) $node);
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@andybroomfield I've updated it, is this what you meant? Thanks a lot by the way
andybroomfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @paulpopus with these changes revisions are now working and using the correct template suggestions.
|
Can we hold on merging though until we know why the test fails. |
andybroomfield
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your efforts @paulpopus
See inline comments, I think below should get the tests to pass.
So oddly, by fixing the revisions, we crash the tests when they are not loading a node.
This should also fix a scenario where someone does not use a node for the front page.
|
I've added a new commit with the above fix to get the tests to pass. Of course I can't review it now, so if someone else wants to @finnlewis @Adnan-cds @cjstevens78 ? |
Adnan-cds
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am getting WSOD for the entire site with this change. The error message is about memory exhaustion. That doesn't surprise me given that the check for if ($hook == 'page' && $node = \Drupal::routeMatch()->getParameter('node')) { has been dropped.
Adnan-cds
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks.
Closes #132