Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Goal
- Convert {menu_custom} table data into Menu (extends ConfigEntity).
Part of #1802750: [Meta] Convert configurable data to ConfigEntity system
Details
- $menu_name becomes a classed object,
Drupal\menu\Menu
. - Wherever the code refers to the menu_name, use
$menu->id()
. - Wherever the code intends to output a name for the menu, use
$menu->label()
.
Notes
- This should be relatively straightforward to do, so tentatively tagging with Config novice.
- Probably menus could be rendered with render controller http://drupal.org/node/1819308
Follow ups
- #1882218: Remove static menu link creation for menus in menu_enable() and elsewhere
- #1882552: Deprecate menu_list_system_menus() and menu_ui_get_menus()
Related issues
- Example conversion: #1588422: Convert contact categories to configuration system & #1552396: Convert vocabularies into configuration & #1782244: Convert image styles $style array into ImageStyle (extends ConfigEntity) & #1497380: Convert shortcut sets to ConfigEntity
- #1668820: Concept, base class, and interface for Configurables (e.g., node types, image styles, vocabularies, views, etc)
- #916388: Convert menu links into entities
- #1869476: Convert global menus (primary links, secondary links) into blocks
- #1798732: Convert install_task, install_time and install_current_batch to use the state system
- #1824184: Remove and replace entity type specific API hook documentation with generic entity API hook documentation
- #1945226-62: Add language selector on menus
- #2019647: Use EntityListController for menus
Comment | File | Size | Author |
---|---|---|---|
#85 | menus-1814916-85.patch | 48.86 KB | tim.plunkett |
#85 | interdiff.txt | 707 bytes | tim.plunkett |
#82 | menu.config.82.patch | 49.56 KB | sun |
#82 | interdiff.txt | 686 bytes | sun |
#80 | 1814916-interdiff-79.txt | 799 bytes | andypost |
Comments
Comment #0.0
andypostUpdated issue summary.
Comment #1
andypostInitial patch:
- added entity
- fixed most of tests
needs clean-up
- hook execution
- edit form
- remove procedural wrappers
- list controller
- form controller
Comment #2
swentel CreditAttribution: swentel commentedI'm not sure whether field_ui_bundle_load is good as the function returns a field instance object, not a bundle.
So it would make more sense to do field_ui_instance_load in a way.
Comment #3
aspilicious CreditAttribution: aspilicious commentedWhats the reasoning behind the rename?
What do you mean by test object?
Comment #4
Fabianx CreditAttribution: Fabianx commented+1 for custom menu being configuration:
* I normally like to deploy menu items via code.
* I like to version control them as while the content might change, the structure usually is fixed.
Comment #5
andypost@aspilicious the reason is because having menu as entity field_ui_menu_load() assumed as hook_ENTITY_TYPE_load()
New patch introduces List controller and changed suggested field_ui_instance_load()
Comment #7
andypostWrongly touched changes reverted
Comment #9
andypostMy bad, suppose now tests should pass
Comment #10
xjm#9: 1814916-menu-9.patch queued for re-testing.
Comment #12
tim.plunkettRerolled.
Comment #14
tim.plunkettFixed the use statements.
Comment #15
andypost@tim.plunkett thanx a lot for re-roll
patch removes menu_load_all() used only once in core
Comment #17
andypost#15: 1814916-menu-15.patch queued for re-testing.
EDIT passed locally
Comment #19
andypost#15: 1814916-menu-15.patch queued for re-testing.
Comment #20
aspilicious CreditAttribution: aspilicious commentedHmm what caused the testbot failures before?
Because this "looks" like a random failure. And you're using a lot of random names in your tests.
Comment #21
andypost@aspilicious fails was fixed with follow-up for EntityTypePlugins, suppose I hit re-test when head was broken because all failures was different and unrelated to menu
Comment #22
andypost#15: 1814916-menu-15.patch queued for re-testing.
Comment #24
tim.plunkettRerolled, no changes.
Comment #25
Fabianx CreditAttribution: Fabianx commentedThis needs a re-roll.
Comment #26
Fabianx CreditAttribution: Fabianx commentedxpost :-D
Comment #27
andypostSuppose we have to move this files to system module. Menu module could be uninstalled but this system menus are needed.
System menus are hard-coded so probably we should not allow to change their machine names
Comment #28
andypostJust a re-roll to follow head changes
Comment #29
andypost#28: 1814916-menu-28.patch queued for re-testing.
Comment #31
andypostChasing head
Comment #32.0
(not verified) CreditAttribution: commentedUpdated issue summary.
Comment #33
andypostUpdate functions numbers are changed
Comment #34
aspilicious CreditAttribution: aspilicious commentedI'm not sure what the status of this patch is but this version contains commented code. Should that could be removed or what has to happen with it?
These schemas should be removed?
Do we need the install function?
And should we remove the menu_custom table? I saw other conversions where we postpone the removal to D9.
Comment #35
andypostSuppose {menu_custom} table should be there according #1860986: Drop left-over tables from 8.x
schema definition should be removed.
The status of the issue - needs review #27
The Menu.module is optional but system menus and entity needs new place
Comment #36
tim.plunkettQuoting catch from IRC:
If we wanted it somewhere else, we'd have to deal with #1847002: Move entity type classes from Drupal\$provider\Plugin\Core\Entity to Drupal\$provider\Entity and #1821846: Consider better naming conventions for plugin types owned by includes first.
This patch moves everything to system (I hope) and fixes menu.install.
Comment #37
andypostIt works! Patch with small fixes for comments
EDIT
system/config
tooOtherwise patch RTBC
Comment #38
aspilicious CreditAttribution: aspilicious commentedWe should use entity_info_alter in that case. But I still see potential problems with the current patch. If you don't enable menu module you still registered the uri callback.
So when you call $menu->uri() it goes kaboom?
Comment #39
tim.plunkettThe custom menu links that are now in YAML were in menu_install originally anyway, they should only be added if the menu.module is installed.
I moved the list controller, the config_import hooks, and the uri callback.
Comment #40
tim.plunkett@aspilicious pointed out that the url of 'admin/structure/menu/manage/' won't exist without menu.module, so we need to move that to the alter too.
Comment #41
tim.plunkettAnnndddd we have another problem.
The config_import "hooks" are called based on the config_prefix. See #1806178: Remove code duplication for hook_config_import_*() implementations of config entities for other issues with that.
This means that menu_config_import_* will be called unless we rename them system.menu.$foo.yml...
Or, nothing will get imported properly unless menu is enabled.
Comment #42
tim.plunkett:(
Comment #44
parasite#42: menus-1814916-42.patch queued for re-testing.
Comment #46
tim.plunkettNot sure why that was retested, it's a legitimate failure. It seems that config_install_default_config() is being called for system.module before any plugin classes are loaded. Is that even possible?
Comment #47
tim.plunkett#1806178: Remove code duplication for hook_config_import_*() implementations of config entities will allow us to switch back to menu.menu. I'd postpone it, but those exceptions look like they are a separate issue, so we might as well fix that in the mean time.
Comment #48
tim.plunkett@berdir helped me track this down, is_subclass_of() was changed in PHP 5.3.9
Comment #49
tim.plunkettI'm starting to think that the "fix" above is a coincidence?
Berdir found https://bugs.php.net/bug.php?id=55475 and https://bugs.php.net/bug.php?id=53727, possibly related.
The bots are on 5.3.5, I can reproduce locally with 5.3.6, but Berdir had it pass with 5.3.10 and 5.4.6.
Comment #50
tim.plunkett#1806178: Remove code duplication for hook_config_import_*() implementations of config entities went in, so rerolling to re-rename the config files back and removing the config_import_ hooks
Comment #51
aspilicious CreditAttribution: aspilicious commentedWe should upgrade our php requirements...
Comment #52
aspilicious CreditAttribution: aspilicious commentedBesides of that this feels rtbc
Comment #53
tim.plunkettForgot the manifest file update.
Comment #54
sunHm. I do not really understand why and how priming of
module_list()
would change the introspection of a class (and the code comment does not really clarify that either).I almost suspect that this code is running into some larger environment issues within the installer, which #1798732: Convert install_task, install_time and install_current_batch to use the state system is supposed to fix — essentially: System module is not installed like any other module, which means that its services are not readily available upon installation in the installer. Fixing that requires some larger changes to the installer, as contained over there.
Hm. That's an unfortunate consequence/problem. Field UI is certainly not the only module that uses such menu argument loading helper functions.
OTOH, the problem seems to be limited to
%[module]_menu
and thusMODULE_menu_load()
, which is rather rare, as you'd normally useMODULE_ENTITY_menu_load()
, so this change is probably fine to ignore.1) It would be good to provide more room between these additional operations; e.g., just use steps of 10 instead of 5.
2) It looks like we're missing $uri['options']. Entity URIs are pluggable, so just because the default implementation only uses a path does not mean that there cannot be custom options.
Can we keep the less obscure and more nicely formatted output generation code? ;)
An entity form controller is left to a follow-up issue?
We're missing a default config file for the footer menu.
Missing UUID.
We should create an issue to remove this code. It essentially expands all available config entities into (static) menu links.
I think we can do this for now, since the overall patch seems to be a very positive improvement.
However, in thinking through this issue over the past days, I wondered whether we need the Menu entity at all, and whether we cannot simply move the entire code for menus into Menu module. As a result of doing so, you would no longer see any menu blocks when Menu module is disabled. (Why would anyone expect any menu to appear without it anyway?) — The router/menu link building should not be affected by that; it can still operate on the 'menu_name' property of menu links. Essentially, we'd turn the 'menu_name' property of menu links into a simple "container"/realm that has no further business logic and also no UI attached to it by default. Only by enabling Menu module, those containers/realms are actually turned into something that has business logic behind it.
But as mentioned, we should discuss that in a separate follow-up issue. The proposed changes here look worth to commit on their own and are a step forward.
Bogus property summary.
Comment #55
tim.plunkettI'll update the patch and/or open follow-ups, probably tomorrow.
Comment #56
tim.plunkettThis is a reroll for the blocks patch, no changes made from #54 yet.
Comment #58
tim.plunkettOne more try
Comment #59
andypost#58: menus-1814916-58.patch queued for re-testing.
Comment #60
andypostFixed most of #54 and unused css
patch still needs upgrade tests, form controller and proper fix for module_list()
PS: Suppose we should just remove theme_menu_admin_overview()
EDIT: menu_install() was removed without fixes, seems this needs some testing.
Logic with menu_enable() needs some refactoring
menu_save and menu_delete() should be removed
Comment #61
andypostPatch introduces form controller.
menu_save() and menu_delete() are removed - suppose better to move 'em into storage controller.
Changes menu.api.php - probably we need to delete this file in follow-up.
Comment #62
sunWow, thanks :) I didn't really mean to ask for a conversion to EntityFormController right within this issue though. ;)
However, the converted code looks really great and I can only guess that it will come back green. Only have a few picks on it:
isNew() needs to be FALSE, not TRUE, in order for delete to make sense. :)
I actually wanted to propose to take over the
theme_menu_admin_overview()
style of outputting config entities in a listing as the default for all config entity listings. ;)However, I'm also fine with discussing and doing that in a separate follow-up issue, so standardizing this admin listing for now looks fine to me. Usability folks will argue that this is a regression though, so let's be clear about that it's only meant to be temporary.
Removal of menu.api.php is more or less bound to #1824184: Remove and replace entity type specific API hook documentation with generic entity API hook documentation
I think we actually did remove API documentation in some of the conversion issues already, but let's not get into that can of worms in this issue. ;)
In a separate follow-up issue, we should consider to move these hook implementations into a MenuStorageController. Let's not do that here. Let's make progress instead. :)
Comment #63
andypostFixed isNew() for delete button.
MenuStorageController is ok to separate issue, same for menu.api.php and probably for upgrade tests.
Except this I think this issue is RTBC.
Let's get usability review of removal
theme_menu_admin_overview()
, suppose in case of menu it looks more same to have description as separate column in overview table@tim.plunkett has assigned this issue, sorry I missed this...
Comment #64
tim.plunkettTo be clear, here's the before and after:
Before:
After:
Comment #65
Bojhan CreditAttribution: Bojhan commentedThe only thing I would suggest - I dont think this change is necessarily bad, is to make the left column titles bold.
Comment #66
yoroy CreditAttribution: yoroy commentedHere's an adapted mockup of the views listing which already uses bold titles to demonstrate how that would look: http://dl.dropbox.com/u/538835/stuff/Views%20%7C%20d8.png
Lets do the bold thingie and rtbc after that?
Comment #67
andypostAdded class menu-label with bold style
... and marked description column hidden for mobile screens
Comment #68
tim.plunkettMade two small tweaks, but that looks great!
Thanks!
Comment #69
sunThanks!
I still think that this comment + data priming is not clear enough - or in other words, I don't really have an idea which exact problem the @todo is referring to and what exactly needs to be architecturally refactored to eliminate the @todo.
I think we want and need to clean this up prior to commit.
I don't know why we have these restrictions, but they do not make much sense to me. Ideally, we should create a follow-up issue to remove them.
Let's also not forget about the follow-up issue I mentioned in #54 about moving the Menu entity type into Menu module and thus, detaching the entire Menu UI business logic from the low-level {menu_links}.menu_name container concept.
Isn't this helper function identical to
menu_load()
and thus obsolete now?Bogus watchdog category 'contact'.
FYI: #736564: Add #redirect property for form #type 'submit' to eliminate various submit handlers might allow us to remove these entity form controller methods in the long run. Feedback is welcome over there. :)
Why is there no Delete operation? In general, shouldn't we call into parent:: here and just add the additional operations?
Created a follow-up issue to remove this code:
#1882218: Remove static menu link creation for menus in menu_enable() and elsewhere
Comment #70
andypostYes, this kind of attach looks better :)
Comment #71
sunComment #71.0
andypostUpdated issue summary.
Comment #72
andypostFixed watchdog category and getOperations() - added delete operation with restriction for system menus
module_list() - needs Tim's attention
menu_edit_menu_name_exists() - is not obsolete because
id()
is generated with prefix of menu owner "menu-", "shortcut-" etcFiled follow-up for #54 #1882552: Deprecate menu_list_system_menus() and menu_ui_get_menus()
EDIT issue summary updated with follow-ups
Comment #74
andypostMerged HEAD
Added this assert for new message
Patch also fixes the bug in menu_save() when config is not saved...
Comment #76
andypostAnother re-roll
Comment #77
tim.plunkettYes, this @todo is completely bogus, but I'm not sure what's going on here, other than it fails on PHP 5.3.5 without this :(
Comment #78
sunCan you try to replace the added code in
drupal_install_system()
with the attached interdiff?(Extracted from #1798732: Convert install_task, install_time and install_current_batch to use the state system)
Comment #79
tim.plunkettOoh, that looks promising.
Comment #80
andypostPatch with #78 applied
Comment #82
sunI extensively debugged this some more. We need to do #1798732: Convert install_task, install_time and install_current_batch to use the state system first. This patch runs into the exact problem space as over there and which the existing patch fixes.
We don't want to get blocked on that issue, so attached patch applies a stop-gap fix. This patch is expected to come back green, and that's the only piece I've authored here, so I feel eligible to RTBC.
Comment #84
aspilicious CreditAttribution: aspilicious commentedIf we need to stopgap fix this why don't we go with 76 for the time being. We are removing one line of code with a couple of lines to get things back to green. Are there technical reasons why 76 is that bad for now? (except for the fact we don't know whats happening :p)
Comment #85
tim.plunkettHere's #76 rerolled with a better comment.
Comment #86
sunOK, thanks, let's stop-gap-fix it that way then. It's totally broken either way. ;)
Comment #87
webchickAwesome! :D :D Really happy to see this at RTBC! It certainly cleans up a lot of stuff.
Channeling catch, I'm pretty sure he'd want to see benchmarks on this, to know how much of a performance loss (or gain? ;)) this patch buys us. Since this only converts menus themselves, and not menu links, it's probably not too shabby.
I looked through the patch thoroughly, and could really only find minor concerns around naming of things (menu_menu_add/edit is weirdly named for a page call-back, I'm not sure "field_ui_instance" is more clear than "menu) and some coding standards stuff (there's at least once instance of "thing. thing" instead of "thing . thing") but they are not really worth holding up the patch, I don't think.
Comment #88
webchickIncidentally, I also did a thorough UI review and apart from the light table styling in #64 and the fact that the edit page now has a delete button on it (yay!) the custom/system menu admin experience in D7 and D8 is identical.
Comment #89
msonnabaum CreditAttribution: msonnabaum commentedI did some quick profiling and discovered no difference in function calls with the patch for anonymous users. Talking with Tim about it, we only saw a difference with admin or on cache clears.
I'd argue that this issue should not be held up on profiling results, although I'm happy to defer to catch if he feels otherwise.
Comment #90
Gábor HojtsyYesss! This also makes menu labels and descriptions translatable (once those relevant CMI issues land). Superb! Tagging for that.
Comment #91
webchickOk, great. Thanks for double-checking!
Committed and pushed to 8.x. Woohoo!
This'll needs a change notice.
Comment #92
andypostFiled a change notice http://drupal.org/node/1888504
Needs help to check grammar
Comment #93
BerdirMade a few minor changes but looks good to me. The part that I didn't quite get (haven't reviewed the code) is the second half of "All hook_menu_*() hooks now receive \Drupal\system\Plugin\Core\Entity\Menu $menu as parameter and just a hook_ENTITY_TYPE_*() hooks".
A lot of information in there applies to entities in general (use of id(), which is more or less also already mentioned in http://drupal.org/node/1400186, not sure how much should be duplicated. And a documentation page along the lines of "Working with Entities in 8.x" or Best Practices... wouldn't hurt I guess. We can do that once we're through with the conversions...
Comment #94
Anonymous (not verified) CreditAttribution: Anonymous commentedComment #96
YesCT CreditAttribution: YesCT commentedthis was causing me problems when adding language select to menus... so I changed it to #field_prefix instead.
#1945226-62: Add language selector on menus
Comment #97
YesCT CreditAttribution: YesCT commentedfollow-up-like #2019647: Use EntityListController for menus
Comment #97.0
YesCT CreditAttribution: YesCT commentedAdded follow-ups
Comment #98
xjmUntagging. Please remove the "Needs change notification" tag when the change notice task is complete.
Comment #98.0
xjmadded to related