Make node aware of the latest_version route.

Created on 12 May 2017, about 8 years ago
Updated 30 January 2023, over 2 years ago

Problem/Motivation

Content moderation overrides the node template to set 'page' => TRUE to indicate the latest-version route should be treated as a full page dedicated to displaying a node entity. The issues are:

  • node_is_page doesn't return TRUE here, so others trying to build assumptions around "node-full-pageness" wont work.
  • Heaps of code is required to do this in content_moderation.

Proposed resolution

Make node_is_page aware of the route content_moderation adds and clean up a huge chunk of tech debt in the process.

Remaining tasks

User interface changes

API changes

Data model changes

📌 Task
Status

Needs work

Version

10.1

Component
Node system 

Last updated about 6 hours ago

No maintainer
Created by

🇦🇺Australia Sam152

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.

  • 🇮🇳India vsujeetkumar Delhi

    Re-roll patch need to 11.x.

  • last update over 1 year ago
    Patch Failed to Apply
  • Status changed to Needs review over 1 year ago
  • last update over 1 year ago
    30,435 pass
  • 🇮🇳India _utsavsharma

    Rerolled for 11.x.

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States smustgrave

    This will need test coverage. Why is the one test being removed?

  • First commit to issue fork.
  • Pipeline finished with Failed
    3 months ago
    Total: 138s
    #456803
  • 🇦🇺Australia acbramley

    The test that was removed was specifically testing the CM preprocessor which was removed so the test was no longer needed. Instead I've repurposed it to test the node_is_page function.

    I was in 2 minds about doing this or 📌 Deprecate node_is_page and move into a service Active first but this might be easier to get in first.

  • 🇦🇺Australia acbramley

    Alternatively if we make it a service I guess CM could decorate it to add the condition to its own route 🤔

  • Pipeline finished with Success
    3 months ago
    Total: 1137s
    #456806
  • 🇺🇸United States smustgrave

    Can we update the issue summary to reflect the new scope and findings please.

    Hiding patches

  • 🇦🇺Australia acbramley

    @smustgrave what exactly is missing from the IS? It explains exactly what we're doing?

  • 🇺🇸United States smustgrave

    left some comments, still marking as the changes to the test didn't break.

  • 🇬🇧United Kingdom alexpott 🇪🇺🌍

    I don't think we should hardcode this. How about we add something to route so we have an API here that other modules could use.

    Something like
    if ($route_match->getRouteName() == 'entity.node.canonical' || $route_match->getRouteObject()->getOption('node.is_full_page_view')) {

    And then in \Drupal\content_moderation\Entity\Routing\EntityModerationRouteProvider::getLatestVersionRoute() do ->setOption($entity_type_id . '.is_full_page_view', TRUE) on the route it returns. This way any entity that has similar needs to node can do things in the same way.

    We should also update the docs in template_preprocess_node() as the following is not correct...

      // The 'page' variable is set to TRUE in two occasions:
      // - The view mode is 'full' and we are on the 'node.view' route.
      // - The node is in preview and view mode is either 'full' or 'default'.
    
  • First commit to issue fork.
  • 🇦🇺Australia acbramley

    We're actually trying to deprecate this variable entirely so I guess this should be postponed 📌 Deprecate $variables['page'] for node.html.twig Needs review

    I do like the idea in #35 though!

  • Pipeline finished with Success
    8 days ago
    Total: 982s
    #531693
Production build 0.71.5 2024