No results show unless all caches are cleared before every search
lrobeson - August 31, 2009 - 17:59
| Project: | Google Search Appliance |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
When doing a search, no results are shown unless I select "Flush All Caches" (using Administration Menu module). When I clear the cache, the results immediately show up. But if I hit refresh or click any pager links, they all disappear again. I'm using 6.x-2.x-dev but this happens with 6.x-2.0-beta1 as well. There are no PHP or server errors in the Drupal or server Log.
When I view the source for the blank results page, there are a bunch of empty DT tags. The pager always shows the correct number of results.
Cache cleared:
<dl class="search-results google-appliance-results">
<span id="thmr_38" class="thmr_call">
<dt class="title">
<a href="http://shop.healthcarelogistics.com/default.aspx?page=item%20detail&itemcode=1500">Product Details for Item 1500 - Health Care Logistics</a>
</dt>
<dd>
<p class="search-snippet"><b>1500</b> - Health Care Logistics is a distributor of unique and hard to find healthcare<br> products. <b>...</b> Item Code: <b>1500</b>. Description: Economy Shelf Unit. <b>...</b> </p>
<p class="search-info"><span id="thmr_17" class="thmr_call">
<a href="http://http://70.60.136.88/search?q=cache:B7eCsRspSQ8J:shop.healthcarelogistics.com/default.aspx?page=item%20detail&itemcode=1500">cached version</a></span>
</p>
</dd>
</span>Cache not cleared:
<span id="thmr_31" class="thmr_call">
<dl class="search-results google-appliance-results">
<span id="thmr_45" class="thmr_call">
<dt class="title">
<a href=""></a>
</dt>
<dd>
</dd>
</span>Attached are 2 screenshots: when the cache is cleared and when it's not.
| Attachment | Size |
|---|---|
| searchCacheNotCleared.jpg | 188.95 KB |
| searchCacheCleared.jpg | 215.4 KB |

#1
Thanks to DougVann and a developer friend of his, after several hours of confusion, we were able to figure this out today.
I finally realized when I switched my theme back to Garland everything worked fine. I took the search-results.tpl.php and search-result.tpl.php files out of my Zen sub-theme folder and that corrected everything. I have no idea why those templates caused such a problem, or why the problem was temporarily corrected by clearing the cache, but that's how I was able to solve it.
#2
Curious.
One thing to note is that this module provides for alternative search results template file names if you don't want GSA results to be themed the same as Drupal search results.
So if you are still using the Drupal search module for some things, and you would like to retain your custom theme for those results, you could try restoring your old template files, and then adding the following:
search-result-google-appliance.tpl.php
search-results-google-appliance.tpl.php
which I would suggest you create as copies of the templates in /modules/search/ to begin with, given the problems you were having.
(Although possibly the first thing to try before that is to simply copy the search module's templates into your theme without renaming them, and see what happens.)
And if theme templates are central to the problem, I'm inclined to think that it's the theme registry cache specifically that is involved. Could you confirm that? (using the admin_menu module's sub-menu for cache clearing).
The "sub-theme" comment also grabs my attention. There may be a bug which causes issues with sub-themes, but does not arise with other themes.
#3
Automatically closed -- issue fixed for 2 weeks with no activity.
#4
Correct me if I'm wrong, lrobeson, but it sounds as though your solution was to use the Garland theme for your site in order to display your search results?
I'm having the exact same problem as you in a situation where I need to theme the results; if you found the solution for getting it to work with your own theming, please could you elaborate?
In my theme directory, I've got the files search-results.tpl.php and search-result.tpl.php as per the module instructions, and experience the exact same issue: it works for a single load after clearing the theme cache, but on a subsequent page load, no results get shown. The theme is not a sub-theme.
I'm using 6.x-2.0-beta1. I haven't yet tried the -dev version given the original issue description. Hope you can help.
#5
Well, I didn't switch to the Garland theme permanently, I just switched temporarily to rule out a theme-related issue. After realizing it worked fine using Garland, I figured it was an issue with my sub-theme. I deleted the search-results.tpl.php file from my theme folder and the problem was resolved. I do however have the search-result.tpl.php still in my theme folder though, so it seems like it's just the search-results one that causes the problem?
#6
I'm almost sorry it's not a bug with sub-themes. That would have handily explained why I'd not encountered it.
Could one of you try my template naming suggestion?
google_appliance.module will use search-result-google-appliance.tpl.php and search-results-google-appliance.tpl.php in preference to the standard templates (although IIRC it won't actually find them unless you also have the matching search-results.tpl.php and/or search-result.tpl.php in your theme directory).
If the module works without search-results.tpl.php in your theme, then:
a) Try adding an exact copy of /modules/search/search-results.tpl.php to your theme, and testing with that
b) If that works, then try adding search-results-google-appliance.tpl.php to your theme as a copy of search-results.tpl.php
c) If that works, try customising search-results-google-appliance.tpl.php
#7
Hi guys - thanks for your replies.
I've tried using the search-result(s)-google-appliance.tpl.php files (yes, I believe search-result(s).tpl.php must be present in the theme folder in order for the override one to be picked up).
I too have found that removing search-results.tpl.php but keeping search-result.tpl.php works. I've copied /modules/search/search-results.tpl.php to my theme, but as soon as the cache is cleared the results are empty elements after the first page load, so my experience is also that it's only an issue when search-results.tpl.php comes into play.
#8
So for clarity:
1. With neither search-results.tpl.php nor search-results-google-appliance.tpl.php in your theme, it works fine.
2. But if you then add an exact copy of /modules/search/search-results.tpl.php to your theme and clear the caches, the problem occurs?
I'm grasping at straws here, but could you check the theme registry before you search?
<?php$theme_registry = theme_get_registry();
$theme_search_results = "<pre>" . print_r($theme_registry['search_results'], TRUE) . "</pre>";
?>
And maybe add that into one of your region variables in your theme's preprocess_page function. Something like:
<?php$vars['content'] = $theme_search_results . $vars['content'];
?>
The values shown shouldn't change at all between searches.
The other thing to try that I can think of is enabling (or disabling) the core search module. google_appliance uses the core search templates regardless of whether that module is enabled, but how it manages that varies depending on the situation. If this made a difference, it should help narrow it down.
When the bug is active, I presume that you still get no results if you enter a completely new search term?
#9
Thanks for your reply, jweowu.
I worked through your suggestions above; turns out that disabling the core search module was needed before search-results.tpl.php could exist in my theme. With the core search module disabled, I can also now use search-results-google-appliance.tpl.php if I wish.
Not sure if there would be a situation where someone might need the core search module enabled and where this would then be a bug, but have marked as fixed. Thanks again.
#10
Glad to hear it's working.
I'm marking this active again, because the code was specifically intended to work with or without search.module, and so clearly there's a bug. I don't have a GSA to test with at present, but this issue should remain open until the module works properly in both situations.
#11
Note that there's a 'vitual' version of the GSA available (no charge for testing and/or development use) at:
http://code.google.com/enterprise/gsave/download_main.html
Might be good enough for you to test with...
#12
Damn! I had this flagged to try when I had the time, but Google have discontinued this before I got around to downloading it. If anyone has an alternative download (assuming it doesn't need to talk to the mothership, in which case I suspect it simply won't work now), please point me to it.
#13
Hey guys..
Can somebody guide me in teh righ direction.. I'm drupal newby..
Where do I get these files:
search-result(s)-google-appliance.tpl.php
in core drupal module search only I found:
search-results.tpl.php
and
search-result.tpl.php
so i went and copy those in my theme directory out side.. but the notice this directory so i move them in:
C:\xampp\htdocs\drupal613\sites\all\themes\marinelli\tploverrides\aggregator
where do they suppose to go??
help me out I'm not getting any results..
#14
I'm not familiar with that 'tploverrides' subdirectory, but presumably the marinelli theme sets that up as a path for drupal_discover_template() to look in?
Anyway, these templates are alternatives to the default search templates. Create them yourself (as copies of search-result(s).tpl.php) if you want the GSA results to be themed differently to the standard Drupal search results.
As per the README.txt file:
Note that the workaround for this issue is to disable the core search module, whereupon having search-result(s)-google-appliance.tpl.php template files becomes slightly redundant (until this bug is resolved).