Follow-up to #2406749: Use a link field for custom menu link
Problem/Motivation
Postponed on #2416955: Convert MenuLinkContent to use a link widget
In the prior issue we are storing the user input by using a link field. The link field itself just has a URI, title and options stored.
However, for menu links referencing a node or other entity we should use a entity: URI. We don't need to do discovery and re-resolve those paths.
For links using a user-path: scheme we need to resolve the path every time we do menu rebuild - probably via plugin discovery as a way to re-process them
Steps to manual test the patch
Apply patch on local instance
Create a page views
Create menu link pointing to page views
check menu_tree table for route_name
Delete page views
Recreate page view - with different views name and same path
check menu_tree table again and look for route_name (It should have different route_name in the menu_tree table then before deleting views)
Proposed resolution
make these plugins participate in discovery and resolve the route then.
Remaining tasks
Decide on implementation, do it.
User interface changes
N/A
API changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #42 | increment.txt | 4.66 KB | pwolanin |
| #42 | 2417423-42.patch | 13.6 KB | pwolanin |
| #40 | rediscover-it-2417423.40.patch | 13.63 KB | larowlan |
| #40 | interdiff.txt | 4.21 KB | larowlan |
| #37 | interdiff.txt | 10.47 KB | kgoel |
Comments
Comment #1
pwolanin commentedComment #2
pwolanin commentedComment #3
yesct commentedsmall nit to clarify.
Comment #4
yesct commentedComment #5
tim.plunkettComment #6
tim.plunkettComment #7
dawehnerNote, without #2416955: Convert MenuLinkContent to use a link widget we can't distinct between entity URIs and user-path URIs.
Comment #8
yesct commentedComment #9
yesct commented#2416955: Convert MenuLinkContent to use a link widget landed.
Comment #10
dawehnerI'll try to tackle it now.
Comment #11
pwolanin commentedDiscussing with dawehner, let's use a deriver class so we stay fully within the plugin framework.
Comment #12
dawehnerWIP
Comment #13
dawehnerAlright, there we go.
Comment #15
pwolanin commentedRe-roll for 2 conflicts including #2417877: Make getDefinition method on menu link content entity public so we can rebuild user paths
Comment #17
dawehnerThis could be it, as always, this is also part of some of the other patches.
Comment #18
almaudoh commented@dawehner looks like you uploaded the interdiff twice :)
Comment #19
dawehnerHa, good catch! Here is the actual patch.
Comment #20
pwolanin commentedI think this could use
getDerivativeId()This isn't triggered by the rebuild?
Comment #21
dawehnerFair!
Comment #22
larowlanCan we add methods to MenuLinkContentInterface for this - and use that instead - makes the code more readable.
::setRequiresRediscovery()
::requiresRediscovery()?
#2389335: Deprecate entity.query service and replace with using the entity storage's getQuery() method is trying to remove the entity.query service, can we use EntityManger->getStorage($entity_type_id)->getQuery() instead - we already have the entity manager for storage sake.
Not needed?
Comment #23
berdirThis apparently re-introduced incorrect default value settings, I think YesCT already openend an issue for the existing ones. there is no such setting, use is setDefaultValue() instead.
Comment #24
dawehnerRealized that we can also just adapt the entity query.
Good point.
Fixed
Fixed my no longer using it.
Comment #25
dawehner.
Comment #26
yched commentedAbout 'default_value' : found a couple more in current MenuLinkContent::baseFieldDefinitions()
Patch in #2418117: MenuLinkContent::baseFieldDefinitions() wrongly passes default values as a field setting
Comment #27
kgoel commentedComment #28
dawehnerThank you kalpana to manual test it AND add the manual instructions.
Comment #29
kgoel commentedI have manually tested the patch and menu_tree table does store different route_name after deleting the views. Reviewing the code and working on patch.
Comment #30
kgoel commentedThere is no API changes so it doesn't need change records.
Comment #31
wim leersThe patch is looking wonderfully simple :)
s/compare/compared/
The class name is wrong; copy/paste remnant.
"are caught up" sounds a bit strange.
Comment #32
larowlanAlso should we be adding an index for the new field for performance sake?
Comment #33
dawehnerI would like to do that, but I could not figure out how to add an index to a base field ... given that the indexes seemed to live on the field type instead.
Comment #34
kgoel commentedworking on this.
Comment #35
berdirThere is no API right now to add indexes for base fields or indexes that span multiple fields. The best you can do right now is visible in FileStorageSchema.
Comment #36
pwolanin commentedI think the boolean field is really the right solution since it's more extensible by contrib or if we add other schemes later that need to be rediscovered.
@Bardir - can we index the boolean field?
Comment #37
kgoel commentedComment #38
larowlanWould still like to see a method for this added to MenuLinkContentInterface, with a setter too
Comment #39
larowlanworking on #38 and #32
Comment #40
larowlanFixes #38 and #32
Hope I don't break anything
Comment #41
effulgentsia commentedSuch a nice, clean, and direct way of solving this!
This class has nothing directly to do with user paths. It uses the rediscover field, which contrib can repurpose to cover other use cases too without needing to change the deriver, which is awesome. So, let's name it more generically, like simply
MenuLinkContentDeriver. I don't think we even need to prefix with Rediscoverable or anything like that, since that's implicit to what a deriver is.What if a path changes from user-path to not (e.g., link is edited and changed from custom path to an entity that was autocompleted)? Should we add a setRequiresRediscovery(FALSE) for that? I think that's only needed when the scheme changes, not every time there's a save.
Capitalize Views and Panels?
I haven't followed all the comments here. Is there any other unaddressed feedback? If not, I think this is ready once at least item 1 from this comment is done. The other items could be followups if needed.
Comment #42
pwolanin commentedok, I think this addresses effulgentsia's feedback
Comment #43
larowlanI think we're ready here - thanks all
Comment #45
webchickOk great. This looks like what we talked about. Thanks for all the great testing in this issue! Bummer about the index thing, but that's a pre-existing condition.
Committed and pushed to 8.0.x. Thanks so much!!!
Comment #47
yched commentedThis re-reintroduced the wrong syntax for default values :-p
See #23 and #26
Comment #48
yched commentedAdded it to the fixes in #2418117: MenuLinkContent::baseFieldDefinitions() wrongly passes default values as a field setting...