mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
3ddd5647a1
commit
e5a07227c2
@ -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' => '');
|
||||
|
||||
|
@ -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');
|
||||
|
Loading…
x
Reference in New Issue
Block a user