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.
Initially added this function with the intention of getting caching onto the core hook, however that train looks to have left, and instead it is suggested that modules directly add their own caching for this hook as necessary. #1032700: Add caching to hook_admin_paths()
Comment | File | Size | Author |
---|---|---|---|
#14 | page-manager-admin-paths-1120028-14.patch | 5.05 KB | zhangtaihao |
#4 | page-manager-admin-paths.patch | 3.56 KB | EclipseGc |
#3 | page-manager-admin-paths.patch | 2.32 KB | EclipseGc |
Comments
Comment #1
EclipseGc CreditAttribution: EclipseGc commentedPretty straight forward I think:
http://drupalcode.org/sandbox/eclipsegc/1073402.git/blobdiff/3dc77d7c44b...
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedI actually had to revert the hook_admin_paths stuff from earlier, because it was a performance nightmare. I'm not sure where everything on that issue stands right now.
Comment #3
EclipseGc CreditAttribution: EclipseGc commentedOK, hopefully this will take care of the performance issue and get us the admin paths back. :-D
Comment #4
EclipseGc CreditAttribution: EclipseGc commentedBetter patch. This time admin_path status is being checked and set for menu_rebuilding to clear the admin_paths cached items.
Comment #5
EclipseGc CreditAttribution: EclipseGc commentedAdding a check to only perform this stuff on custom pages since there's no reason to track it for pages with their own tasks and it only throws errors on that anyway.
Comment #6
EclipseGc CreditAttribution: EclipseGc commentedA better fix for 5
Comment #7
EclipseGc CreditAttribution: EclipseGc commentedok, last attempt failed, trying again
Comment #8
jhedstromRe-rolling for clean apply.
Comment #9
merlinofchaos CreditAttribution: merlinofchaos commentedWe need to not hardcode to a specific task id. We can perhaps do a callback that the page task implements, that way other tasks can share the glory if needed.
!empty() seems equivalent to the first two there. And empty() seems equivalent to the second two.
Comment #10
EclipseGc CreditAttribution: EclipseGc commentedHmmm, I hard coded to the page task_id because all other tasks are generally going to be using hook_admin_paths() of some module's existing definition. i.e. we're overriding other tasks in those cases and in this one we're creating new. If there's some use case I missed here though please let me know.
And yeah, I've only become comfortable with empty() in far too recent history. hehe :-)
Comment #11
merlinofchaos CreditAttribution: merlinofchaos commentedUse case or no, hardcoding like that is wrong.
Comment #12
Xomby CreditAttribution: Xomby commented@merlin, this IS working (#8), and although I understand your issue with the hardcoding (generally bad, just by rule of thumb!), if left as is, what are the ramifications?
Comment #13
zhangtaihao CreditAttribution: zhangtaihao commentedI thinkpage_manager_edit_page_finish()
is perhaps not the right place to check for this status. Granted, it works because the UI is the most common place to work out this issue. However, some piece of code could still try to save a page throughpage_manager_save_page_cache()
.Given that all the code inpage_manager_save_page_cache()
seems intended to react to page & handler changes, it would be a much more logical place to rebuild admin paths cache.I apologize for being stupid. I will avoid skipping bits and pieces in the future.
Comment #14
zhangtaihao CreditAttribution: zhangtaihao commentedActually
page_manager_page_form_basic_submit()
seems the perfect place for the check. Incidentally, this is also where$cache->path_changed = TRUE;
happens.I've taken a slightly different approach to clear the admin paths cache. Since admin paths seem limited to the page task, I decided that the best place to detect changes is in the page handler itself (i.e. in
page_manager_page_form_basic_submit()
). The admin paths cache are specifically cleared inpage_manager_page_save_subtask()
andpage_manager_page_delete()
(in page.inc). Also, since whether a page is an admin page is also dependent on whether it is made the home page, the check also includes change in that option.As such, the only changes to
page_manager.module
are a cached admin paths rebuild/retrieval function and a clear function.Comment #15
zhangtaihao CreditAttribution: zhangtaihao commented#14: page-manager-admin-paths-1120028-14.patch queued for re-testing.
Comment #16
darvanen#14 Works for me.
Comment #17
DamienMcKennaComment #19
dsnopekI just did some manual testing, and the patch in #14 works great! I created a page in Page Manager and checked the checkbox to use the admin overlay. Enabling and disabling this checkbox would invalidate the cache correctly!
However, I did find a case where it didn't invalidate the cache when it should: if the checkbox is already checked and the page saved, then you change the pages path, and save, it won't be in the admin overlay/theme on the new path. You have uncheck the checkbox, save, then check it again and save.
Also, it's not part of this patch, but the current checkbox label is: "Use this page in an admin overlay." However, this also affects if the admin theme is used, and if you don't have overlay enabled, that's all it affects. It would be awesome if this mentioned that it affected the admin theme and didn't say anything about the overlay if the overlay module was disabled. But that's probably out of scope for this issue...
Comment #21
joelpittetas per #19 this still needs work
Comment #22
darrenwh CreditAttribution: darrenwh as a volunteer and commented