Problem/Motivation
Using the Menu UI page we can override some values of the menu links provided by modules, Those values are:
- menu_name
- parent
- weight
- expanded
- enabled
But one important value is missing, the "title" field, I don't know if there is a technical reason why the title isn't overridable but seems something which might be useful, for instance #2838106: Standard profile: make "Home" menu link to <front> editable/deletable giving the user the ability to just edit the title would fix that issue and the same happens for any menu link provided by a contrib module.
In my next comment a patch with the change.
(This will require tests which I can provide as well but I just want to know first if there is a reason why the title wasn't between these values in first place I just fixed the tests to include this new key, so not sure if we need more tests.)
Steps to reproduce
Proposed resolution
- Add the title to the schema of menu link overrides as a label data type.
- Add the title to the menu link form
- Add the title to the $overrideAllowed attribute on the menu link plugin
Remaining tasks
- Fix broken unit test
- Code review
User interface changes
N/A
API changes
Data model changes
N/A
Release notes snippet
TBD
| Comment | File | Size | Author |
|---|
Issue fork drupal-2916639
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
Comment #2
gnugetComment #3
gnugetComment #4
gnugetComment #5
gnugetComment #7
gnugetForgot to add the title in the schema.
I just added it in this patch.
Comment #9
gnugetI just fixed the two failing tests.
Comment #10
gnugetComment #11
mlncn commentedThis is simple, powerful, and has tests!
The only reason i can think this wasn't included to start with might be internationalization support? But if you don't override, you don't lose whatever support the module might or might not be providing anyway.
Comment #12
alexpottI think this needs to be translatable - so should be of type
labelas that will enable config translation.Also we need an upgrade path for existing configuration.
Comment #13
alexpottThis patch also breaks existing translations. If you:
But if you:
Comment #14
gnugetComment #15
gnugetHi!
Thanks for the reviews Alex!
I just added the upgrade path in this new patch and changed the type to label.
Also added as related the issue #2710469: Move contact module footer link to standard install profile once we fixed that one #13 won't be a problem anymore.
Right now is a problem because the standard profile adds the footer link in the core.menu.static_menu_link_overrides.yml file in the profile installation, once we added that link as a content this won't be a problem anymore.
is there another way to make this work without the need to fix #2710469: Move contact module footer link to standard install profile first? In theory using the type "label" should pick the translation even if the value is in the yml file, yes?
thanks for your review.
Patch and interdiff atached.
(I will mark this as needs review to make sure to all is working once all the test passed I will switch it back to needs work)
Comment #17
gnugetI tried to fix the broken test but not sure how to fix it.
The error is:
And it seems that my hook_update triggers the
BrokenInboundPathProcessor::processInboundwhich in this test it is supposed to be executed when visiting the homepage but not in the $this->runUpdates(), so not sure if I should avoid my hook_update to execute this event (rewriting it to make this change in a different manner) or if should I exclude my hook_update to run in this test.Comment #18
alexpottMove this to be a post update - see core/modules/system/system.post_update.php. You might be using API you can't rely on in a hook_update_N
We could do less looping by doing something like:
And no need for a continue too :)
Comment #19
gnugetHi!
Thanks again for your help Alex, I just added your suggestions to my patch.
Let's see what the testbot say.
Should I postpone this issue and work on #2710469: Move contact module footer link to standard install profile first? or is there a way where I can fix this one first?
- David.
Comment #21
gnugetoh, the same test failed again :-(
Comment #23
robbdavis commentedBump. I just spent 1/2 an hour trying to figure out why I couldn't delete the home link. Disabling it is OK but not clean. I'm all for making it deletable.
Comment #25
mlncn commentedWishfully hoping the testbot might have changed its mind...
Comment #29
chris matthews commentedComment #32
mlncn commentedComment #33
spokjeRe-roll of patch #19 against
9.2.x-devComment #34
spokjeComment #35
sagesolutions commentedCan you re-roll the patch for Drupal 8?
Thanks!
Comment #36
sagesolutions commentedFor now, I ended up using the hook_toolbar_alter() function
See https://www.drupal.org/project/toolbar_menu/issues/2949053#comment-13998889
Comment #37
rosk0Code looks good, update path is in place, tests are passing.
Manual testing went good. Tested on Drupal 9.1.4.
Comment #38
gauravvvv commentedPatch #33, Failed to apply. needs re-roll.
Comment #39
gauravvvv commentedComment #40
adityasingh commentedReroll the patch for 9.2.x.
Comment #42
anmolgoyal74 commentedFixed syntax error.
Comment #45
mlncn commentedThe re-rolled and fixed patch of #42 is RTBC as per #37 and my own and others testing and use in production.
Comment #46
alexpottThis needs to apply-able to 10.0.x and 9.4.x - as a task those are the only branches open where this can land but there are conflicts in core/lib/Drupal/Core/Menu/StaticMenuLinkOverridesInterface.php and core/tests/Drupal/Tests/Core/Menu/StaticMenuLinkOverridesTest.php
Comment #47
gauravvvv commentedI have updated the patch for D9.4, Please review.
Patch #42, is no longer applies to D9, so not able to generate interdiff for same.
Comment #48
gauravvvv commentedComment #49
gauravvvv commentedComment #50
gauravvvv commentedTo override the menu title of Taxonomy Menu #3261003: Allow override the taxonomy menu link titles in at core.menu.static_menu_link_overrides.yml
Comment #51
damienmckennaShould this be a bug report? It's a little silly that the title isn't editable.
Comment #53
joelpittetReturning to RTBC and triggered tests to see if any issues with 10.x and 9.5.x
Comment #54
quietone commentedThis needs a patch that applies to 10.0.x.
The issue summary should explain the resolution here, adding tag for an is update. A fail patch would be helpful as well.
Way back in #13 it was reported that the patch changed the contact link in the footer of a standard install. Perhaps I missed it but I don't see confirmation that that has been fixed.
Comment #57
jweowu commentedRe-roll of #49 against 10.1.x.
Comment #58
gauravvvv commentedI have attached patch for 11.x
Comment #59
mlncn commentedComment #60
smustgrave commented#54 mentions an issue summary update which is still needed.
Have not reviewed or tested.
Comment #61
generalredneckAdding a reroll for 10.3
Comment #62
tonibarbera commentedRerolled for 10.3.1
Comment #65
akalam commentedComment #66
akalam commentedI've created a MR against 11.x and updated the summary to explain the resolution
Comment #67
smustgrave commentedMR appears to have pipeline issues
With regards to the post_update hook this something may want to use a ConfigImporter class to run in batches?
Post update hook will need test coverage too
Thanks!
Comment #69
oily commentedFixed PHPSTAN and PHPCS. Pipeline has failing unit test(s).
Comment #70
oily commented