Remove unused preprocess

Created on 21 December 2022, about 2 years ago
Updated 17 April 2024, 8 months ago

The module uses hook_preprocess_node, to load revision state information, for use in the templates.

The operation is pretty heavy, as it doesnt check for view_mode - something which i've reported and patched here:

https://www.drupal.org/project/workflow_buttons/issues/3328538 🐛 workflow_buttons should only be loaded/load edit form when relevant Fixed

However, it appears that the resulting variable 'latest_revision_state' is not actually used for anything - so this code is completely redundant.
I propose we just remove it - unless you can tell me why i'm wrong? :)

🐛 Bug report
Status

Needs work

Version

1.0

Component

Code

Created by

🇩🇰Denmark ras-ben Copenhagen

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

Comments & Activities

Not all content is available!

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

  • 🇺🇸United States beunerd Providence, Rhode Island

    @ras-ben @mlncn

    First, this function -- workflow_buttons_preprocess_node(&$variables) -- creates two (not one) optional variables for use in node templates: $current_revision_state and $latest_revision_state.

    Second, why is this "completely redundant"?

    Third, as I explained here 🐛 workflow_buttons should only be loaded/load edit form when relevant Fixed in more detail, checking for view display mode by name is arbitrary and may differ between installations.

  • 🇩🇰Denmark ras-ben Copenhagen

    @beunerd apologies for the slow reply on the other ticket. I dont know why it's flown over my head.

    It's quite many months since i created this patch, so i'm trying to remember - but, from reading my comment, it appears that I've missed that there's a second variable being set.

    The variable i did notice - latest_revision_state - was not being used for anything, when I searched in the code.
    That's why I called it fully redundant.

    However, when I look in the code, it appears that "current_revision_state" is the same - it's being set, but not being used anywhere. Am i wrong?

    Let's continue the discussion on full/viewmode in the other ticket :) https://www.drupal.org/project/workflow_buttons/issues/3328538 🐛 workflow_buttons should only be loaded/load edit form when relevant Fixed

  • Status changed to Active over 1 year ago
  • 🇩🇰Denmark ras-ben Copenhagen
  • Status changed to Closed: won't fix over 1 year ago
  • 🇺🇸United States beunerd Providence, Rhode Island

    Thanks, @ras-ben, for the follow up.

    but not being used anywhere.

    That's correct. This module does not include any twig/template files where the values set in workflow_buttons_preprocess_node() would be rendered. The point is to provide those variables to any Drupal theme that wants to use them in their own node-related template.

  • 🇩🇰Denmark ras-ben Copenhagen

    Right, but what would the use case for that be in a template?
    It seems overkill to send the data along for no reason, and using a hook in the process

  • 🇺🇸United States beunerd Providence, Rhode Island

    Hmm, so maybe we just move it to the README as an example in case themers want to know?

  • Status changed to Needs work over 1 year ago
  • 🇺🇸United States beunerd Providence, Rhode Island

    Actually, I'm realizing this doesn't have any place in workflow_buttons module -- at most it should be added to the core issue queue as a proposal for the workflows core module. It's not related to workflow buttons.

    @mlncn What do you think? Is it worth creating a ticket in core for adding the code in this hook? And do you agree we should remove it entirely from this module? And if we do, how do you propose we make sure sites using this module are informed?

  • 🇮🇹Italy kopeboy Milan

    Up! I like efficient modules 🙃

Production build 0.71.5 2024