Problem/Motivation

Content moderation uses a preprocess hook on 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.

Once #3458589: Deprecate $variables['page'] for node.html.twig and node_is_page() is done, we don't need this any more.

Proposed resolution

Remove ContentPreprocess, the unit test, and the actual preprocess hook

Remaining tasks

Review
Commit

User interface changes

NA

API changes

NA

Data model changes

NA

Issue fork drupal-2877924

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Sam152 created an issue. See original summary.

sam152’s picture

Status: Active » Needs review
StatusFileSize
new3.64 KB
timmillwood’s picture

I think we should only do this if we update the Node entity annotation to include the 'latest-revision' link template. This is currently added to entity types in \Drupal\content_moderation\EntityTypeInfo::addModerationToEntityType.

sam152’s picture

Would that create a funky implicit dependency from node to content_moderation? It wouldn't be a link that actually existed unless it was enabled.

timmillwood’s picture

ok, I mean adding the whole shebang to core / node.

Seems a bit odd to add a check for a route in node.module which only exists if content moderation is enabled.

sam152’s picture

Yeah, I think adding the latest_version route to be a generic feature of entity API would be awesome, but I think as usual this is blocked by the fact we don't have the tracker table or EntityRevisionConverter in core. It would be another great entity API enhancement for forward revisions, but the issue to introduce that has thoroughly stalled.

Until then it would be a small hack in node, for a big clean up in CM, which I agree isn't ideal.

Status: Needs review » Needs work

The last submitted patch, 2: 2877924-node-latest-version-route-2.patch, failed testing.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

sam152’s picture

Status: Needs work » Needs review
StatusFileSize
new5.98 KB

Any chance of picking this back up? Now that CM is entering beta, I think for such a huge win in terms of reducing technical debt, I think it makes sense for node to integrate with CM here instead of the other way around.

sam152’s picture

Issue summary: View changes

Added some justifications in the IS.

timmillwood’s picture

Component: content_moderation.module » node system
Issue tags: +Workflow Initiative, +Need tests

Looks good to me but node_is_page() test needs adding or updating, and maybe deprecating in favour of a service if that makes it more testable?

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

jhedstrom’s picture

This has some overlap with #3005029: Make node_is_page() work on revisions and previews as well. That's also tagged as needing tests, but from what I can tell, none of the procedural code in node.module has any dedicated tests.

This function would be very easy to unit test, but I don't know if there's a standard for testing global functions via unit tests. Failing that, it would need to be a kernel test (a functional test seems like overkill for such a simple method.)

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new157 bytes

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.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

vsujeetkumar’s picture

Issue tags: +Needs reroll

Re-roll patch need to 11.x.

_utsavsharma’s picture

Status: Needs work » Needs review
StatusFileSize
new6.32 KB
new6.32 KB

Rerolled for 11.x.

smustgrave’s picture

Status: Needs review » Needs work

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

acbramley made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Needs review
Issue tags: -Need tests, -Needs reroll

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 #3515218: [Regression] Restore functionality of node_is_page, generalised to content entity types first but this might be easier to get in first.

acbramley’s picture

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

smustgrave’s picture

Status: Needs review » Needs work

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

Hiding patches

acbramley’s picture

Status: Needs work » Needs review

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

smustgrave’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community

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

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

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'.

oily made their first commit to this issue’s fork.

acbramley’s picture

Status: Needs work » Postponed

We're actually trying to deprecate this variable entirely so I guess this should be postponed #3458589: Deprecate $variables['page'] for node.html.twig and node_is_page()

I do like the idea in #35 though!

acbramley’s picture

Title: Make node aware of the latest_version route. » [PP-1] Remove ContentPreprocess and associated code
Component: node system » content_moderation.module
Issue summary: View changes

Confirming we can get rid of all of this code once #3458589: Deprecate $variables['page'] for node.html.twig and node_is_page() 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.

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

acbramley’s picture

Title: [PP-1] Remove ContentPreprocess and associated code » Remove ContentPreprocess and associated code
Status: Postponed » Needs review
berdir’s picture

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)

needs-review-queue-bot’s picture

Status: Needs review » Needs work
StatusFileSize
new91 bytes

The Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".

This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

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

acbramley changed the visibility of the branch 2877924-test-coverage-only to hidden.

acbramley’s picture

initially was going to repurpose this issue but I think it's cleaner if we open a separate one for the test coverage

#3567137: Add test coverage for duplicate node titles on content_moderation latest version page

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

acbramley’s picture

Status: Needs work » Needs review
acbramley’s picture

Issue summary: View changes
berdir’s picture

Status: Needs review » Reviewed & tested by the community

Beautiful. Note that the functional test coverage that we added in #3567137: Add test coverage for duplicate node titles on content_moderation latest version page remains and ensures that the result is unchanged.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

Committed 8f36150 and pushed to main. Thanks!
Committed 46deaa3 and pushed to 11.x. Thanks!

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • alexpott committed 46deaa34 on 11.x
    task: #2877924 Remove ContentPreprocess and associated code
    
    By: sam152...

  • alexpott committed 8f361502 on main
    task: #2877924 Remove ContentPreprocess and associated code
    
    By: sam152...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.