Merge remote-tracking branch 'origin/1.4' into 2.0

# Conflicts:
#	.travis.yml
#	code/SQLite3Database.php
#	composer.json
This commit is contained in:
Damian Mooyman 2017-12-07 16:16:11 +13:00
commit e8f4e55b8a
No known key found for this signature in database
GPG Key ID: 78B823A10DE27D1A
3 changed files with 42 additions and 20 deletions

View File

@ -178,7 +178,8 @@ class SQLite3Database extends Database
* *
* @return string|null * @return string|null
*/ */
public function getPath() { public function getPath()
{
if ($this->getLivesInMemory()) { if ($this->getLivesInMemory()) {
return null; return null;
} }
@ -278,9 +279,19 @@ class SQLite3Database extends Database
* @param bool $invertedMatch * @param bool $invertedMatch
* @return PaginatedList DataObjectSet of result pages * @return PaginatedList DataObjectSet of result pages
*/ */
public function searchEngine($classesToSearch, $keywords, $start, $pageLength, $sortBy = "Relevance DESC", public function searchEngine(
$extraFilter = "", $booleanSearch = false, $alternativeFileFilter = "", $invertedMatch = false $classesToSearch,
$keywords,
$start,
$pageLength,
$sortBy = "Relevance DESC",
$extraFilter = "",
$booleanSearch = false,
$alternativeFileFilter = "",
$invertedMatch = false
) { ) {
$start = (int)$start;
$pageLength = (int)$pageLength;
$keywords = $this->escapeString(str_replace(array('*','+','-','"','\''), '', $keywords)); $keywords = $this->escapeString(str_replace(array('*','+','-','"','\''), '', $keywords));
$htmlEntityKeywords = htmlentities(utf8_decode($keywords)); $htmlEntityKeywords = htmlentities(utf8_decode($keywords));
@ -307,7 +318,7 @@ class SQLite3Database extends Database
$extraFilters[$fileClass] .= " AND ShowInSearch <> 0"; $extraFilters[$fileClass] .= " AND ShowInSearch <> 0";
} }
$limit = $start . ", " . (int) $pageLength; $limit = $start . ", " . $pageLength;
$notMatch = $invertedMatch ? "NOT " : ""; $notMatch = $invertedMatch ? "NOT " : "";
if ($keywords) { if ($keywords) {
@ -464,7 +475,12 @@ class SQLite3Database extends Database
$this->query("DELETE FROM \"$table\""); $this->query("DELETE FROM \"$table\"");
} }
public function comparisonClause($field, $value, $exact = false, $negate = false, $caseSensitive = null, public function comparisonClause(
$field,
$value,
$exact = false,
$negate = false,
$caseSensitive = null,
$parameterised = false $parameterised = false
) { ) {
if ($exact && !$caseSensitive) { if ($exact && !$caseSensitive) {

View File

@ -74,7 +74,6 @@ class SQLite3SchemaManager extends DBSchemaManager
$databases = array(); $databases = array();
if ($files !== false) { if ($files !== false) {
foreach ($files as $file) { foreach ($files as $file) {
// Filter non-files // Filter non-files
if (!is_file("$directory/$file")) { if (!is_file("$directory/$file")) {
continue; continue;
@ -173,8 +172,14 @@ class SQLite3SchemaManager extends DBSchemaManager
return $table; return $table;
} }
public function alterTable($tableName, $newFields = null, $newIndexes = null, $alteredFields = null, public function alterTable(
$alteredIndexes = null, $alteredOptions = null, $advancedOptions = null $tableName,
$newFields = null,
$newIndexes = null,
$alteredFields = null,
$alteredIndexes = null,
$alteredOptions = null,
$advancedOptions = null
) { ) {
if ($newFields) { if ($newFields) {
foreach ($newFields as $fieldName => $fieldSpec) { foreach ($newFields as $fieldName => $fieldSpec) {
@ -345,8 +350,10 @@ class SQLite3SchemaManager extends DBSchemaManager
$fieldList = array(); $fieldList = array();
if ($sqlCreate && $sqlCreate['sql']) { if ($sqlCreate && $sqlCreate['sql']) {
preg_match('/^[\s]*CREATE[\s]+TABLE[\s]+[\'"]?[a-zA-Z0-9_\\\]+[\'"]?[\s]*\((.+)\)[\s]*$/ims', preg_match(
$sqlCreate['sql'], $matches '/^[\s]*CREATE[\s]+TABLE[\s]+[\'"]?[a-zA-Z0-9_\\\]+[\'"]?[\s]*\((.+)\)[\s]*$/ims',
$sqlCreate['sql'],
$matches
); );
$fields = isset($matches[1]) $fields = isset($matches[1])
? preg_split('/,(?=(?:[^\'"]*$)|(?:[^\'"]*[\'"][^\'"]*[\'"][^\'"]*)*$)/x', $matches[1]) ? preg_split('/,(?=(?:[^\'"]*$)|(?:[^\'"]*[\'"][^\'"]*[\'"][^\'"]*)*$)/x', $matches[1])
@ -425,7 +432,6 @@ class SQLite3SchemaManager extends DBSchemaManager
// Enumerate each index and related fields // Enumerate each index and related fields
foreach ($this->query("PRAGMA index_list(\"$table\")") as $index) { foreach ($this->query("PRAGMA index_list(\"$table\")") as $index) {
// The SQLite internal index name, not the actual Silverstripe name // The SQLite internal index name, not the actual Silverstripe name
$indexName = $index["name"]; $indexName = $index["name"];
$indexType = $index['unique'] ? 'unique' : 'index'; $indexType = $index['unique'] ? 'unique' : 'index';