menu_link_attributes_update_8002 adds container_class attribute if disabled

Created on 4 September 2024, 4 months ago
Updated 6 September 2024, 4 months ago

Problem/Motivation

After upgrading to 1.5 I now have the container classes attribute added when I had previously removed it. This is due to a bug with the conditionals in the update path.

Steps to reproduce

Install 1.4, remove container_class attribute
Upgrade to 1.5 and run updb
Notice container_class attribute added back

Proposed resolution

Only add label/description if attribute exists.

🐛 Bug report
Status

Closed: works as designed

Version

1.0

Component

Code

Created by

🇦🇺Australia acbramley

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

Merge Requests

Comments & Activities

  • Issue created by @acbramley
  • Status changed to Needs review 4 months ago
  • Pipeline finished with Success
    4 months ago
    Total: 134s
    #274122
  • Status changed to Postponed: needs info 4 months ago
  • 🇩🇪Germany Anybody Porta Westfalica

    @acbramley thanks for the report! menu_link_attributes now comes with container_class attribute by default. The update hook ensures that it is also provided for existing (older) installations.

    Versions before 8.x-1.5 didn't have that attribute, see: https://git.drupalcode.org/search?search=container_class&nav_source=navb...

    So did you maybe use the dev version before, which didn't have the update hook for some time? Or did you run the update hook after deleting the container_class attribute perhaps?

    Just for my understanding: For what reasons are you removing it? I guess you don't need it and it fills up the UI?

    I'm curious if perhaps dedicated permissions per attribute might be a good feature request to control who can see which...

  • Status changed to Needs review 4 months ago
  • 🇦🇺Australia acbramley

    @anybody nope, I upgraded from 1.4. But that's exactly my point, I don't want the attribute so why is it being added to existing installs when menu_link_attributes_update_8002 is just about correcting labels and descriptions? Perhaps there should've been 2 upgrade hooks.

    Just for my understanding: For what reasons are you removing it? I guess you don't need it and it fills up the UI?

    I don't need it, it has no purpose in my site.

    I don't think we need dedicated permissions.

  • Merge request !26Split update hooks → (Open) created by Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    so why is it being added to existing installs when menu_link_attributes_update_8002 is just about correcting labels and descriptions? Perhaps there should've been 2 upgrade hooks.

    Indeed it should not only update labels and descriptions but also add the container attribute to have the same attributes as with a fresh installation.

    You're totally right that this should better have been split into two update hooks to be clearer. I created a MR to do that.
    The additional attribute is expected to match the status like with fresh installations and it's backend-focused, so I hadn't seen that as BC.

    The split update hook should not do any harm now? Or should we just close this won't fix?

  • Status changed to Closed: works as designed 4 months ago
  • 🇦🇺Australia acbramley

    Happy to close, I think splitting the update hooks now may be more disruptive. It's easy enough to remove the new attribute manually.

  • 🇩🇪Germany Anybody Porta Westfalica

    Thank you for the discussion @acbramley and sorry once again. I understand that the decision made doesn't fit for everyone.

Production build 0.71.5 2024