Closed (fixed)
Project:
JSON:API Menu Items
Version:
1.2.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
13 Jan 2021 at 15:42 UTC
Updated:
16 Jun 2025 at 16:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
blazey commentedDepends on #2997790: Set MenuLinkContent getEntity to public visibility
Comment #3
decipheredPatch needs a re-roll, and tests are currently failing, likely due to the dependency on #2997790.
Comment #4
suresh prabhu parkala commentedRe-rolled patch. Please review.
Comment #6
Pooja Ganjage commentedHi,
Creating a patch for solving issue that got raised in #4 comment patch.
Please review the patch.
Thanks.
Comment #7
Pooja Ganjage commentedComment #9
Pooja Ganjage commentedComment #10
larowlanComment #11
cola commentedAnyone who has a new patch for it?
Error: Call to protected method Drupal\menu_link_content\Plugin\Menu\MenuLinkContent::getEntity() from scope Drupal\jsonapi_menu_items\Resource\MenuItemsResource in Drupal\jsonapi_menu_items\Resource\MenuItemsResource->getMenuItems() (Zeile 205 in /modules/contrib/jsonapi_menu_items/src/Resource/MenuItemsResource.php)
Comment #12
decipheredA re-rolled patch of PR would be greatly appreciated if anyone has the capacity, otherwise I will aim to re-roll and test this in the coming weeks.
Comment #13
cola commentedWould be good if we can remove the dependency on Set MenuLinkContent getEntity to public visibility
Comment #14
decipheredComment #16
decipheredI've created a feature branch and merge request with the latest patch against 1.2.x. The patch can be found @ https://git.drupalcode.org/project/jsonapi_menu_items/-/merge_requests/7...
Comment #17
vermario commentedHere's a revised patch against the latest version of the module
Comment #18
u_tiwari commentedHere is a better version which actually seems to work correctly and is compatible with latest version.
Comment #19
jb044Rerolled against latest dev
Comment #20
andrewbelcher commentedThis feature actually paves way to fix a bug, which is that there are a couple broken bits of cache when using menu item content:
ResourceObjectas part of it's cache key, resulting in normalisation getting cached incorrectly for language specific requests including translated menu item content.As such, have updated the patch and updated the category/priority of this issue!
Comment #21
larowlanLooks good to me, but would be great to add tests for this because I don't want it to break again in the future, and as someone with the luxury of only working on single language sites, i18n can sometimes be an afterthought.
Comment #22
andrewbelcher commentedSwitched to needs work pending tests.
Have also added a new patch that fixes some indentation and an error when a menu item is not translatable.
In terms of items we need to test this with:
MenuLinkContentTest should validate:
langcodeonly included on output forMenuLinkContenton translatable menusComment #23
jérôme dehorterHello,
With this addition of "langcode" would it be possible to add the possibility of filtering in the API with ?filter[langcode] for example.
Comment #24
larowlanI think that's worth adding for sure, as multi-lingual sites would want that right?
Comment #25
jérôme dehorterHello larowlan,
That's right, we have several multilingual projects and this would be to display language-specific menu items.
Comment #26
mglamanI'm assuming patch from #22 is the latest work and https://git.drupalcode.org/project/jsonapi_menu_items/-/merge_requests/7 is outdated?
Comment #27
andrewbelcher commentedYes, i think so. We're running that patch in prod and it is working nicely.
Comment #28
mglaman#3276561: Add support for the Menu Item Extras module has logic for fetching the entity for menu_link_content, which is what this MR and patch are also adding. It's also using `getTranslationFromContext`. The only difference is that this adds
langcodeSo I think the fix in will fix this, causing this issue to just add the langcode property.
Comment #31
mglamanI've opened https://git.drupalcode.org/project/jsonapi_menu_items/-/merge_requests/16 which is the essence of #22. The base field for the langcode field is allowed and the link's language is passed to the resource object.
Comment #33
budalokko commentedI've fixed the tests with the new "langcode" attribute. It only appears when "provider" is "menu_link_content". Is this the desired behaviour or a bug?
Still "Needs work" because new tests in a multi-language setup should be added, right?
- Tests pass for
phpunit (previous minor)!!!- Test failures in
phpunitare unrelated to this issue (token added to logout links in https://www.drupal.org/node/2822514).- Test failures in
phpunit (previous major)seem related to php 7.4 . An up to date project pipeline could be triggered to be certain if the same failures happen on the current 1.2.x or just on this branch.Comment #34
naim belkaied commentedUpdate the patch with version 1.2.6
Comment #35
naim belkaied commentedComment #36
tbadaczewski commentedHope this gets solved, using this module with a ReactJS frontend really would be helpful.
Comment #38
mglamanMarking needs review, thanks for fixing the tests @budalokko. https://git.drupalcode.org/project/jsonapi_menu_items/-/merge_requests/16 seems good, but extra test coverage would be great
Comment #40
alexpottBeen using this on a production site for a while. Used AI (Claude) to add a test around menu link content translations so we've got some more explicit functionality testing in place.
Comment #41
alexpottMarking this as RTBC - we've got test coverage - I've not made any functional changes to this patch and it has been running on a production site I'm involved with a for a year - since #22.
Comment #43
mglaman