This is an odd one. It *feels* like a bug in EE, but if it is a lot of people would be hitting it, which doesn’t seem to be happening, so I’m putting it up here to see if anyone has any thoughts.
Results from simple searches on a site I manage are hitting frequent issues where the titles of search results don’t match URLs. Specifically, mismatches seem to occur where the URL of a static page is included twice in the search results, once with its page_url, from the Pages module, and again with its title URL, as returned by {auto_path}.
Here’s a real example of search results from the site. I’ve included the first ten results, both titles and URLs, and numbered them so you can see which title corresponds to which URL:
[1] Self-Care Among Latinos with Diabetes Studied
[1] chan.usc.edu/news-and-events/news/usc-researcher-studies-self-care-among-latinos-with-diabetes
[2] Summer Occupational Therapy and English Program for International Students and Therapists
[2] chan.usc.edu/academics/summer-english
[3] Shain Davis, OTD ‘13, MA ‘12
[2] chan.usc.edu/academics/summer-occupational-therapy-and-english-program-for-international-students
[4] Chantelle Rice, OTD ‘09, BS-MA ‘08
[3] chan.usc.edu/about-us/family/shain-davis
[5] Health and Wellness
[4] chan.usc.edu/about-us/family/chantelle-rice
[6] Interdisciplinary Health Fair
[5] chan.usc.edu/admissions/student-blog/health-and-wellness
[7] Life Management Series
[7] chan.usc.edu/academics/continuing-education/life-management-series
[8] Student Research
[8] chan.usc.edu/research/student-research
[9] Occupation Renewal
[6] chan.usc.edu/admissions/student-blog/interdisciplinary-health-fair
[10] Our Faculty Expertise
[10] chan.usc.edu/faculty/expertise
You can see that things start to go wrong with the 3rd search result, which incorrectly returns the title URL from the *2nd* search result. Here, a single page has returned two separate URLs: the page_url in the 2nd search result, and the title URL in the 3rd. Things continue to be offset until the 7th search result, which is correct. The 9th search result then incorrectly gives the title URL from the 6th search result.
So, in essence, pages created using the Pages module are sometimes returning two separate URLs in the search results, the page_url, and then the title URL, and this is causing mismatches.
The code I’m using here is very simple, and doesn’t seem to be leaving room for any problems. The form code is:
{exp:search:simple_form search_in="entries" results="10" status="open" where="all" channel="about-us|academics|admissions|alumni|campaign|faculty|home|news-and-events|patient-care|research|jobs|news|profiles|student-blog|vacancies" result_page="search/index" no_result_page="search/fail"}
<input type="text" name="keywords" id="keywords" value="search" maxlength="100" />
{/exp:search:simple_form}And the code to handle the search results is:
{exp:search:search_results}
<div class="searchitem">
<a href="http://{if">{title} →</a>
<?php echo strip_http("{if page_url}{page_url}{if:else}{auto_path}{/if}"); ?>
{excerpt}
</div>
{paginate}
<div class="paginationcontrols">
{if "{total_pages}" != 1}Page {current_page} of {total_pages} pages {pagination_links}{/if}
</div>
{/paginate}
{/exp:search:search_results}To be clear, this isn’t the result of duplicated channel entries. Single entries are returning multiple URLs. I also tried deleting and re-entering entries, just in case there was some database corruption.
I’m running EE 2.9.0. (I’ve just checked the release notes for 2.9.1, and I don’t see anything that’s relevant.)
Thanks for any input.