Make node aware of the latest_version route.

Created on 12 May 2017, over 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 almost 2 years ago
    Patch Failed to Apply
  • Status changed to Needs review almost 2 years ago
  • last update almost 2 years ago
    30,435 pass
  • 🇮🇳India _utsavsharma

    Rerolled for 11.x.

  • Status changed to Needs work almost 2 years 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
    5 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
    5 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 Active

    I do like the idea in #35 though!

  • Pipeline finished with Success
    2 months ago
    Total: 982s
    #531693
  • Merge request !12979Issue #2877924: Remove page variable preprocess → (Open) created by acbramley
  • Pipeline finished with Failed
    12 days ago
    Total: 142s
    #571604
  • 🇦🇺Australia acbramley

    Confirming we can get rid of all of this code once 📌 Deprecate $variables['page'] for node.html.twig Active is done, however CM doesn't seem to have any functional test coverage of what this was doing (i.e hiding the duplicate h2 heading on the latest version page).

    I think in this issue we should add that test coverage. I've opened an MR to remove the associated code and will add the test coverage which will fail until 3458589 is merged and this is rebased.

  • 🇦🇺Australia acbramley

    acbramley changed the visibility of the branch 2877924-make-node-aware to hidden.

  • Pipeline finished with Success
    12 days ago
    Total: 659s
    #571609
  • Pipeline finished with Failed
    12 days ago
    Total: 568s
    #571635
  • Pipeline finished with Success
    4 days ago
    Total: 979s
    #578739
  • 🇨🇭Switzerland berdir Switzerland

    This looks good, but as I commented as in the parent issue, we can only do this in D13 when the page variable actually gets removed, otherwise templates relying on the BC behavior would be broken with content moderation?

    Should we split this up? Get the test coverage in now and then the removal later? We could do one postponed page variable cleanup issue and write down all the parts that can go then, because there's a lot and we might miss some bits otherwise (node itself + views/content moderation special cases + tests)

Production build 0.71.5 2024