Jump to:
| Project: | Custom breadcrumbs |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Everything works great except for one issue:
When setting a custom breadcrumb by path, for a views page at www.xx.com/from-the-editor:
Specific Path: from-the-editor
Titles: *
About Us
From the Editor
Paths: *
about-us
from-the-editor
If that path doesn't have a menu item, then the page title of the views page doesn't work. strange, i know. especially since i don't understand what do breadcrumbs have in common with page titles.... I am using the Page Title module as well, so:
- I have a view setup showing the page title of "From the Editor | Sitename".
- I set a breadcrumb for the path - and no page title is set so the title shows "| Sitename".
- once i add a menu item, for that path, it's title gets displayed correctly: "From the Editor | Sitename".
Settings are:
YES - Set the Home breadcrumb text on all pages
NO - Use the menu structure to set the breadcrumb trail
YES - Use wildcard pattern matching in paths
YES - Force the active trail
Using Custom Breadcrumbs 6.x-2.x-dev v 1.6.2.5.2.18 2009/07/29 13:00:23
Page Titles 6.x-2.2 page_title.info,v 1.5 2008/05/02 16:29:11
Drupal 6.13
I wish i could give this some more testing but i spent so much time trying to figure out what's going on i must continue... I'm assuming more people will encounter this issue for it's not such a special use case.. If not i'll return and do some more testing.
Comments
#1
Thanks. I can confirm the problem. This is similar to #454356: [page-title] tokens do not work in custom_breadcrumb_paths breadcrumbs on views pages. The problem comes from two modules doing token_replace_multiple on the same page request, but with different objects. The first call caches the token values. Then when the second module calls token_replace_multiple, the wrong tokens are retrieved.
In this case, the [page-title] token isn't available because of custom_breadcrumbs_paths_init() first attempts to set the breadcrumb. If you comment out that code, everything will work fine - but you won't be able to use custom_bredcrumbs_paths to provide breadcrumbs for pages supplied by some modules (like user/uid etc). Personally, I think the use of hook_init isn't the best here, but it does work for many module pages and I don't want to take that feature away until I have a better solution.
My preferred way to solve the problem is to flush the token cache using a new feature request that is still being evaluated in the token issue queue - #262360: Expose control of token caching to functions that call token_replace. If that feature was available and committed, then I could solve this problem immediately, but its not, so I can't. I plan to pursue this on the tokens issue queue, because I think its a worthwhile solution. But its also an issue that's over a year old (even though its been marked RTBC for several months now), so I don't expect quick resolution.
So I am trying to figure out the best way to handle this problem. Marking this postponed in the meantime.
#2
subscribing
that means that custom_breadcrumb_* are candidate to conflict with many other modules using token_replace until a new release of token module, right?
#3
More generally, that any two modules using token_replace_multiple on the same page request are likely to show this problem. The good news is that the fix is already in the dev version of token. When it becomes a stable release, its easy to fix.
#4
@#1 flushing the token cache might help as a workaround, nevertheless it doesn't seem (to me) the root of the problem
at issue #262360 the reported bug is about a token holding an old value (working, but cached value is undesired)
some modules provide tokens (hook
token_values&token_list) in a separate include file (to keep some code organization) and these files are included on hookinit(example of such modules: flag, comment_subject, and others I don't recall right now)
however, a
module_implements('token_values', ...)should be avoided in early stages (hookboot&init) since otherwise the cached values won't register those modules as providing any token's hook (the cached flaw is not about old token values but rather about actual hooks found)stepping through a debugger:
--
custom_breadcrumbs_paths_initline 75--
_custom_breadcrumbs_paths_set_breadcrumbline 138--
custom_breadcrumbs_set_breadcrumbline 293--
token_replace_multipleline 228--
token_get_valuesline 296-- which invokes
module_invoke_all('token_values', $type, $object, $options);-- resulting in a cached
$implementations[$hook]inside functionmodule_implementswhen at this early stage every module loading after custom_breadcrumbs_paths will miss itsmodule_load_include('inc', 'mymodule', 'mymodule.token');performed at hookinitwhether this lazy load is correct or not might be debatable:
#557542: Cache module_implements()
#588766: Standardize lazy-loading of optional include files
#578044: move module_invoke_all() out of the reach of hook_boot()
but it seems to be already adopted to separate token related code to a
mymodule.token.incfileforgive me if the above is a wrong call, I'll ask to the token module to elucidate this fact in its documentation
#5
follow up #681938: document proper practice for mymodule.token.inc files
#6
BTW, a quick way to test if the cause is what #4 describes is changing the weight of
custom_breadcrumbs_pathsto the greatest possible valueUPDATE `system` SET `weight` = '100' WHERE `filename` LIKE '%/custom_breadcrumbs/custom_breadcrumbs_paths/custom_breadcrumbs_paths.module';if the tokens start working then that was the issue
#7
Ok. Please see (and test) the patch at #627792: Custom Breadcrumb option causes Access Denied in OG Forums which removes the hook_init functions in favor of implementing hook_preprocess. It would be great if this patch solved this problem as well.
#8
#9
I can confirm that patch at #627792-8: Custom Breadcrumb option causes Access Denied in OG Forums cleanly applies and also solves #680444: Tokens not expanded when using custom_breadcrumbs (AKA hook_init might be to late to declare token hooks)
but I'm not a cb user, and therefore can't exhaustive test if every cb functionally remains working
#10
Thanks for testing. I expect that patch will eventually get committed once its RTBC for the original issue with OG Forums. I will mark this issue as fixed once this happens.
#11
I am marking this as fixed since the fix for #627792: Custom Breadcrumb option causes Access Denied in OG Forums has now been committed to 6.x-2.x-dev
#12
Automatically closed -- issue fixed for 2 weeks with no activity.