Fix SearchEngine to use quoted table names

If quotes are omitted, SQLExpression::sql() cannot replace table names
with the proper table for the current Stage.
This commit is contained in:
martimiz 2017-07-13 15:48:19 +02:00 committed by Daniel Hensby
parent 884f53e0f2
commit b726d64d1d
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
1 changed files with 5 additions and 5 deletions

View File

@ -226,10 +226,10 @@ class MySQLDatabase extends Database
// Generate initial DataLists and base table names
$lists = array();
$baseClasses = array($pageClass => '', $fileClass => '');
$sqlTables = array($pageClass => '', $fileClass => '');
foreach ($classesToSearch as $class) {
$lists[$class] = DataList::create($class)->where($notMatch . $match[$class] . $extraFilters[$class]);
$baseClasses[$class] = '"' . $class . '"';
$sqlTables[$class] = '"' . DataObject::getSchema()->tableName($class) . '"';
}
$charset = static::config()->get('charset');
@ -237,14 +237,14 @@ class MySQLDatabase extends Database
// Make column selection lists
$select = array(
$pageClass => array(
"ClassName", "{$pageTable}.\"ID\"", "ParentID",
"ClassName", "{$sqlTables[$pageClass]}.\"ID\"", "ParentID",
"Title", "MenuTitle", "URLSegment", "Content",
"LastEdited", "Created",
"Name" => "_{$charset}''",
"Relevance" => $relevance[$pageClass], "CanViewType"
),
$fileClass => array(
"ClassName", "{$fileTable}.\"ID\"", "ParentID",
"ClassName", "{$sqlTables[$fileClass]}.\"ID\"", "ParentID",
"Title", "MenuTitle" => "_{$charset}''", "URLSegment" => "_{$charset}''", "Content" => "_{$charset}''",
"LastEdited", "Created",
"Name",
@ -262,7 +262,7 @@ class MySQLDatabase extends Database
$query = $list->dataQuery()->query();
// There's no need to do all that joining
$query->setFrom($table);
$query->setFrom($sqlTables[$class]);
$query->setSelect($select[$class]);
$query->setOrderBy(array());