ENHANCEMENT: Full-text search with double quotes returns too many results. ticket #5733. Thanks ktauber.

Using htmlentities($keywords,ENT_NOQUOTES) instead of proposed solution (from r108417)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112731 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2010-10-18 22:58:23 +00:00
parent 3ddd5647a1
commit e5a07227c2
2 changed files with 17 additions and 2 deletions

View File

@ -763,7 +763,7 @@ class MySQLDatabase extends SS_Database {
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", $extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false) {
$fileFilter = '';
$keywords = Convert::raw2sql($keywords);
$htmlEntityKeywords = htmlentities($keywords);
$htmlEntityKeywords = htmlentities($keywords,ENT_NOQUOTES);
$extraFilters = array('SiteTree' => '', 'File' => '');

View File

@ -42,7 +42,7 @@ class SearchFormTest extends FunctionalTest {
function testPublishedPagesMatchedByTitle() {
$sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
$publishedPage->publish('Stage', 'Live');
$results = $sf->getResults(null, array('Search'=>'publicPublishedPage'));
@ -53,6 +53,21 @@ class SearchFormTest extends FunctionalTest {
);
}
function testDoubleQuotesPublishedPagesMatchedByTitle() {
$sf = new SearchForm($this->mockController, 'SearchForm');
$publishedPage = $this->objFromFixture('SiteTree', 'publicPublishedPage');
$publishedPage->Title = "finding me";
$publishedPage->write();
$publishedPage->publish('Stage', 'Live');
$results = $sf->getResults(null, array('Search'=>'"finding me"'));
$this->assertContains(
$publishedPage->ID,
$results->column('ID'),
'Published pages are found by searchform'
);
}
/*
function testUnpublishedPagesNotIncluded() {
$sf = new SearchForm($this->mockController, 'SearchForm');