Closed (fixed)
Project:
Drupal core
Version:
11.x-dev
Component:
shortcut.module
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
27 Mar 2026 at 01:54 UTC
Updated:
23 Apr 2026 at 21:50 UTC
Jump to comment: Most recent
Comments
Comment #2
sourav_paulWorking on this...
Comment #4
sourav_paulHi,
Posted an update that moves the shortcut-specific JSON:API filter access logic into shortcut: jsonapi_shortcut_filter_access() now lives in ShortcutHooks, and a new jsonapi_shortcut_filter_query_access_alter() implementation enforces the current user’s displayed shortcut_set. On the jsonapi side, I added a small prefix-aware filter query alter hook and updated TemporaryQueryGuard to invoke it, which allowed removing the hard-coded shortcut special case and the old shortcut hook from JsonapiHooks.
Comment #5
quietone commented@sourav_paul, thanks.
There is a test using the ShortcutSet.
Comment #6
sourav_paulComment #7
smustgrave commentedThis one will really need an IS update. I'm not sure we should be adding a new api and static method for json to remove a module.
Comment #9
smustgrave commentedLate here but pushed a potential alternative though it is failing but doesn't require an API change. @catch should receive credit too.
Am wondering if an alter hook would be cleaner though.
Comment #10
smustgrave commentedWorking on getting an answer about preferred approach.
Comment #11
smustgrave commentedComment #12
sourav_paulThanks @smustgrave, that makes sense.
My reason for adding the new hook/static helper was that the shortcut restriction is path-aware in JSON:API filtered queries, and I was trying to let shortcut own both the permission check and the query restriction without leaving shortcut-specific logic in jsonapi.
That said, I agree that adding a new jsonapi API just to move module-owned code is probably too heavy if an existing alter/query-access hook can cover it cleanly. If the approach in !15264 or a similar alter-hook-based solution works, I’m happy to rework toward that instead of introducing new API surface.
Comment #13
smustgrave commentedNot sure 2 APIs are needed but having one at the end of that switch statement does seem to make sense. Still working to get an answer. Will keep you updated.
Comment #14
sourav_paulThanks,
looking forward, how we'll end up with this.
Comment #17
longwaveDiscussed with @smustgrave on Slack, then pointed Claude Code in the right direction from what I learned from the discussion. MR!15329 seems to make sense in terms of moving the filtering entirely to shortcut module;
hook_jsonapi_shortcut_filter_accessmoves directly, and theTemporaryQueryGuardcode becomeshook_query_shortcut_access_alteras per the documentation inTemporaryQueryGuard. ShortcutTest passes locally.Comment #20
smustgrave commentedThanks so much @longwave you're a rockstar for figuring that out!
I pushed 1 small tweak to a comment in the test that was flagged in another MR.
Comment #21
sourav_paulThanks @longwave & @smustgrave for digging into this and for sharing the alternative approach.
After comparing the two MRs, !15329 looks like the better fit for core. It moves the shortcut-specific logic out of jsonapi without adding new JSON:API API surface, and it follows the existing TemporaryQueryGuard/jsonapi.api.php guidance by using hook_jsonapi_shortcut_filter_access() plus hook_query_shortcut_access_alter() for the query narrowing.
I understand, earlier approach in !15234 worked, but it introduced a new API and helper method just to move one module’s logic, which is a bigger change than this issue likely needs. The narrower approach in !15329 seems more maintainable and easier to review.
Comment #24
amateescu commentedCommitted and pushed b4c833bf0fd to main and 9172c7e3157 to 11.x. Thanks!