I have installed token 5.x-1.10, pathauto 5.x-2.1, taxonomy_menu 5.x-1.03 with this patch and page_title 5.x-2.x-dev (or 5.x-2.0-alpha5) and have some problems.
Very often I got a message "Access denied" when browsing admin pages. When I turn off page_title module, all goes to work good, but with enabled page_title I got this error again.
And I found regularity with it: when I opening page like admin/build/menu every first loads gots the "Access denied" error, but when I refresh page - all show good without errors. And this repeats every 2 times.
I found that the error is shows only where Drupal loads menu from cache, if I disable menu caching - all works good.
And I found a function, that leads to this problems - calling function token_get_list('taxonomy',$term) in hook_menu() function. When I comments this function, all works good.
Does anybody have problems like this or ideas how to solve this problems?
Comments
Comment #1
murzI have found a problematic function:
If I replacing drupal_get_title() to something like 'Test page title' in this string, all works good but [page-title] token value sets to 'Test page title'.
Comment #2
nicholasthompsonThis is VERY odd!
I'll have to investigate this. I cant even begin to think why this would happen!
Comment #3
murzI try a fresh install of Drupal 5.7 and detect this bug on it too.
You can see this bug when install to a fresh Drupal modules page_title and token.
And wrote a hook_menu function in some module with calling token_get_list() in it.
After that try to refresh in browser, for example, 'admin/build/menu' page many times. Each second time I see an 'access denied' error :(
Comment #4
murzI try to add a counter in function page_title_get_title() that counts the number of function launches in one page load.
And when I skip calling drupal_get_title() on first function start when it calls more than 1 times, all works good.
My modifications for this:
But I can't found a method to detect times where I mustn't call drupal_get_title() function. Because when I see first run, I don't know how many times this function must run after that.
I think, we needs to look on something like drupal bootstrap phase or menu generation state.
I try to compare global $_menu in each run, but it is same every call :(
Comment #5
nicholasthompsoncan you show me you code in template.php for the _phptemplate_variables function please?
Comment #6
murzI try it in fresh Drupal install with standart 'garland' template, _phptemplate_variables function is:
Comment #7
murzI found where executes first page_title_get_title(), thats leads to the error - in
includes/menu.incfunctionimenu_execute_active_handler():First call executes in this place and other, that executes without errors, calls in later code. I trying to search a method for distinguish this and another calls in function
page_title_get_title().Comment #8
nicholasthompsonI assume you've read the readme.txt which tells you to add some code to template.php (hence me asking to see it)?
You shouldn't need to worry about the menu callbacks at all.
Are you using Page Title 2 DEV or Alpha5? DEV is not the same as Alpha5... Dev has test code in it for integration with Views.
Comment #9
murzI try both (Page Title 2 DEV and Alpha5). The code of function
page_title_get_title()is same on all versions.Modifications in template.php influence only on showing titles and don't influence the problem function
page_title_get_title().And I try with template.php modifications and without it.
The problem is that drupal can't get current title with function
drupal_get_title()in states when menu isn't already been builded. But page_title module use 'global' token hook that calls in all states. And when it calls before first call ofmenu_get_menu(), it breaks the correct menu building system.I think you need to find another method to get drupal page title or check the state of menu before calling
drupal_get_title().Comment #10
nicholasthompsonI'll investigate this.... Thanks.
Comment #11
nicholasthompsonMurz - is this still happening?
Comment #12
murzYes, I can't find a normal method to solve this issue.
But I have found an exit on my site - I have do a quick hack for token and pathauto modules on my site for disabling calling page_title_get_title() in states when menu isn't already builded.
But any other modules, as I think, can call drupal_get_title() in boot state and will see problems like in my issue. In my site this modules was combination of token and pathauto. Other sites may have another problematic module combination.
Maybe better is to ignore this issue at now time (for release a stable or beta version of this module) and add in INSTALL.txt or README.txt information about this issue for easier searching bug source for other developers?
If I have found or get some ideas about this issue, I put they here, but at now I have no time to search a fix and use hacked modules on my site.
Comment #13
nicholasthompsonI really cant understand why this error happens... It appears that its only you that is having the problem. I'm running this module on dozens of sites with many combinations of modules and versions of modules and I have never had this. Nobody else has reported it - it appears to be very specific to you. Maybe you have a bad module or a funky server config?! I honestly dont know!
Postponing for now unless anyone else can help out or reproduce.
Comment #14
murzYou and other on any server and any Drupal 5.x can reproduce this bug when it try to call
page_title_get_title()inhook_menu()function.For example, in my situation, I have taxonomy_menu module, that must rebuild menu items every time on menu rebuild. And it do this with this steps.
taxonomy_menu_menu(), that gets terms that must be buildedpathauto_get_placeholders(), that calls functiontoken_get_values()with $type='taxonomy' and getting token values for building path.token_get_values()builds for default not only taxonomy tokens, but all global tokens! But global tokens have$tokens['global']['page-title'];token frompage_title_token_list()function that calls functionpage_title_token_values().page_title_token_values()calls functionpage_title_get_title()that use functiondrupal_get_title().drupal_get_title()calls functionmenu_get_active_title()that try to get menu item and build the menu. But menu is empty because hook_menu() process doesn't finished already! And functionmenu_get_active_title()calls functionmenu_get_menu()that write to cache (to global $_menu variable and cache) empty menu list and return empty active menu item.hook_menu()process ends and all other calls to get menu items return empty results! For this reason, we see the problems with empty pages and "Access denied" errors.We can easy solve this issue if we move page_title token hook from 'global' to another place, for example - to node. Because in 'global' place we must not calling functions that works with menu items such as
drupal_get_title()function.Or another variant is to add for function
token_get_values()new option to ignore global calls frompage_title_get_title()function.At now you can write in readme.txt that developers must not use token module in
hook_menu()functions withpage_titlemodule.Comment #15
murzI have create a feature request for token module: http://drupal.org/node/263110
When it have been implemented, we can modify
token_get_values()calls and solve this issue.Comment #16
nicholasthompsonOhhh Thanks for the explanation - I see the problem now!
I wonder if there is anything in $_POST we can look at to see if the menu is being rebuilt?!
We cant move the page title to node because page title's apply 'globally' throughout the site, not just to nodes.
Comment #17
gregglesI'm moving this to token so that we can keep the history and get nicholasThompson's ideas on the patch you provided there.
@nicholasThompson - the solution that Murz has provided would excluded global tokens from use by Page Title. Does that seem reasonable to you? My feeling is that if we exclude global tokens then people would be disappointed that some of the most important tokens are gone, right?
Comment #18
greggles@nicholasThompson...ping - the proposed patch is http://drupal.org/files/issues/token_add_ignore_global_0.patch
Comment #19
murzSeems that this bug is fixed, closing.