Very strange behaviour if the user is not logged on
| Project: | Tinytax taxonomy block |
| Version: | 6.x-1.11 |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | postponed (maintainer needs more info) |
Jump to:
I think I have a similar problem to #280205: Term links behave diffrently when logged in or not logged in, although that report was about the Drupal 5 version.
- If I am logged in (User 1), then it works fine
- If I log out, then it works for the first time. i.e. I click on the "+" button next to the first item in the block and it expands. However, as soon as I click on the text of an item in the list to view the page for the term, it then stops working. The symptoms are:
- Clicking the "+" button does not expand the list, it goes to the term's page
- The various .png files that draw the tree structure are no longer visible (so root.gif isn't displayed infront of my root term)
- Having clicked on the "+" infront of my root term (and got its page displayed), if I now logon, the list in the block immediately expands to show the child terms of root - as if the action was still pending!
My initial thoughts were that it must be a permissions issue, but I do not see how because it works the first time when the user is not logged on, it only stops working when the user is not logged on and after it has displayed a term's page.
When I am not logged on and click on "+" infront of my root term, if I trace the Java execution, I find that the problem is in:
function onclick(event) {
2 tinytaxalterroot("/drupal/tinytax/get/4117");
3 return false;
4 }and the error message is on line 2 and says "tinytaxalterroot is not defined".
If I check the page source, I find that neither tinytax.js or tinytax.css are included in the list of links and scripts at the start of the file. If I log in and check the page source, then these files are listed amongst the links and scripts.
So the lines
// Load the Javascript and CSS
drupal_add_js(drupal_get_path('module','tinytax').'/tinytax.js');
drupal_add_css(drupal_get_path('module','tinytax').'/tinytax.css','module','screen',FALSE);in the .module file are either not getting executed or are failing. I have tried moving these lines around in the module code, but even putting them right at the top in the hook_block case statement
function tinytax_block($op = 'list', $delta = 0, $edit = array()){
switch ($op){
case 'list':
return _tinytax_list_blocks();
case 'configure': // No need to add any extra configuration - Open to suggestions.
return _tinytax_configure($delta);
case 'view':
// Load the Javascript and CSS
drupal_add_js(drupal_get_path('module','tinytax').'/tinytax.js');
drupal_add_css(drupal_get_path('module','tinytax').'/tinytax.css','module','screen',FALSE);
return _tinytax_view_blocks($delta);
case 'save':
_tinytax_save($delta, $edit);
break;
}
}does not make any difference. Clearly the .module code is getting called because I see the block with its heading and root term displayed, so the lines to load the Java and css surely must be getting called. So they must be failing somewhere down the line in the Drupal core functions.
I am stuck. Anybody got any ideas?

#1
Sounds like a cache issue, can you try adding the following in the foreach block of the _tinytax_list_blocks() function:
$blocks['tinytax-'.$vocabulary->vid]['cache'] = BLOCK_NO_CACHE;#2
Stuart, can you try the code in our SVN repo and let me know if that works for you. Note, ensure you clear your sites cache after upgrading.
Simon
#3
1. The $blocks['tinytax-'.$vocabulary->vid]['cache'] = BLOCK_NO_CACHE; line didn't help
2. The latest version from the SVN repositry makes matters worse!
- it now only works if user 1 is logged in where as previously it worked for any "authorised user"
- after the first use for any user other than 1, a full list of genera is shown, but not in a block with a scroll bar, and each is spaced several lines apart - so it makes for an enormously long list! As before, the images before the names are not shown and the terms do not expand.
Stuart
#4
Oh, by the way, the version from the SVN repositry has a bug in lines 244 and 245:
while(array_pop(db_fetch_array(db_query("SELECT COUNT(t.tid) FROM term_data t, term_hierarchy h WHERE vid = %d AND t.tid = h.tid AND parent = %d;", $vid, $tid))) === "1"){$tid = array_pop(db_fetch_array(db_query("SELECT t.tid FROM term_data t, term_hierarchy h WHERE vid = %d AND t.tid = h.tid AND parent = %d;", $vid, $tid)));
the tables names "term_data" and "term_hierarchy" lack {} round them - so it breaks if there is a table prefix - as there is in my case.
Stuart
#5
Do you have "Optimize JavaScript files" and "Optimize CSS files" enabled? You may want to try disabling these to ensure that the correct Javascript and CSS files are being included. Any chance you can send me a link to your site too.
#6
Under Administration > Performance
This is a development system on my PC, so I'm afaraid it is not accessible.
Stuart
#7
Last thing, can you disable "Block cache".
I've just tested this with a completely clean install of Drupal, and am afraid to say I can not reproduce your error.