Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Conversation

@paulpopus
Copy link
Collaborator

Closes #132

Copy link
Contributor

@andybroomfield andybroomfield left a 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.

// 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) {
Copy link
Contributor

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)

Copy link
Member

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.

Copy link
Contributor

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);
}

Copy link
Collaborator Author

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

Copy link
Contributor

@andybroomfield andybroomfield left a 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.

@andybroomfield
Copy link
Contributor

Can we hold on merging though until we know why the test fails.

Copy link
Contributor

@andybroomfield andybroomfield left a 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.

@andybroomfield
Copy link
Contributor

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 ?

@andybroomfield andybroomfield requested review from andybroomfield and removed request for andybroomfield March 31, 2021 08:33
@ekes ekes mentioned this pull request Apr 28, 2021
Copy link
Contributor

@Adnan-cds Adnan-cds left a 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.

Copy link
Contributor

@Adnan-cds Adnan-cds left a comment

Choose a reason for hiding this comment

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

Thanks.

@andybroomfield andybroomfield merged commit ce5377e into master Apr 30, 2021
@ekes ekes mentioned this pull request May 5, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WSOD when viewing revisions

5 participants