diff --git a/composer.json b/composer.json index 4f1e052a9..71633d783 100644 --- a/composer.json +++ b/composer.json @@ -22,4 +22,4 @@ "autoload": { "classmap": ["tests/behat/features/bootstrap"] } -} \ No newline at end of file +} diff --git a/model/Database.php b/model/Database.php index ea73d5503..e8a083ffe 100644 --- a/model/Database.php +++ b/model/Database.php @@ -142,7 +142,7 @@ abstract class SS_Database { * Returns true if the given table exists in the database */ abstract public function hasTable($tableName); - + /** * Returns the enum values available on the given field */ @@ -177,12 +177,12 @@ abstract class SS_Database { * @var array */ protected $indexList; - + /** * Keeps track whether we are currently updating the schema. */ protected $schemaIsUpdating = false; - + /** * Large array structure that represents a schema update transaction */ @@ -210,16 +210,16 @@ abstract class SS_Database { public function endSchemaUpdate() { foreach($this->schemaUpdateTransaction as $tableName => $changes) { switch($changes['command']) { - case 'create': + case 'create': $this->createTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['options'], @$changes['advancedOptions']); - break; - - case 'alter': - $this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'], + break; + + case 'alter': + $this->alterTable($tableName, $changes['newFields'], $changes['newIndexes'], $changes['alteredFields'], $changes['alteredIndexes'], $changes['alteredOptions'], @$changes['advancedOptions']); - break; + break; } } $this->schemaUpdateTransaction = null; @@ -444,7 +444,7 @@ abstract class SS_Database { } } } - + if($newTable || !isset($this->indexList[$table][$index_alt])) { $this->transCreateIndex($table, $index, $spec); $this->alterationMessage("Index $table.$index: created as " @@ -662,7 +662,7 @@ abstract class SS_Database { */ public static function replace_with_null(&$array) { $array = preg_replace('/= *\'\'/', '= null', $array); - + if(is_array($array)) { foreach($array as $key => $value) { if(is_array($value)) { @@ -694,7 +694,7 @@ abstract class SS_Database { } /** - * Show a message about database alteration + * Show a message about database alteration * * @param string message to display * @param string type one of [created|changed|repaired|obsolete|deleted|error] @@ -733,7 +733,7 @@ abstract class SS_Database { break; case "deleted": $color = "red"; - break; + break; case "changed": $color = "blue"; break; @@ -835,8 +835,8 @@ abstract class SS_Database { public function sqlLimitToString($limit) { $clause = ''; - // Pass limit as array or SQL string value - if(is_array($limit)) { + // Pass limit as array or SQL string value + if(is_array($limit)) { if(!array_key_exists('limit', $limit)) { throw new InvalidArgumentException('Database::sqlLimitToString(): Wrong format for $limit: ' . var_export($limit, true)); @@ -846,11 +846,11 @@ abstract class SS_Database { && is_numeric($limit['limit'])) { $combinedLimit = $limit['start'] ? "$limit[limit] OFFSET $limit[start]" : "$limit[limit]"; - } elseif(isset($limit['limit']) && is_numeric($limit['limit'])) { - $combinedLimit = (int) $limit['limit']; - } else { - $combinedLimit = false; - } + } elseif(isset($limit['limit']) && is_numeric($limit['limit'])) { + $combinedLimit = (int)$limit['limit']; + } else { + $combinedLimit = false; + } if(!empty($combinedLimit)) $clause .= ' LIMIT ' . $combinedLimit; } else { $clause .= ' LIMIT ' . $limit; @@ -868,9 +868,9 @@ abstract class SS_Database { public function sqlQueryToString(SQLQuery $query) { if($query->getDelete()) { $text = 'DELETE '; - } else { + } else { $text = $this->sqlSelectToString($query->getSelect(), $query->getDistinct()); - } + } if($query->getFrom()) $text .= $this->sqlFromToString($query->getFrom()); if($query->getWhere()) $text .= $this->sqlWhereToString($query->getWhere(), $query->getConnective()); @@ -882,10 +882,10 @@ abstract class SS_Database { if($query->getOrderBy()) $text .= $this->sqlOrderByToString($query->getOrderBy()); if($query->getLimit()) $text .= $this->sqlLimitToString($query->getLimit()); } - + return $text; } - + /** * Wrap a string into DB-specific quotes. MySQL, PostgreSQL and SQLite3 only need single quotes around the string. * MSSQL will overload this and include it's own N prefix to mark the string as unicode, so characters like macrons @@ -1007,9 +1007,9 @@ abstract class SS_Database { */ public function supportsLocks() { return false; - } - - /** +} + +/** * Returns if the lock is available. * See {@link supportsLocks()} to check if locking is generally supported. * @@ -1157,7 +1157,7 @@ abstract class SS_Query implements Iterator { $result .= ""; foreach($record as $k => $v) { $result .= "" . Convert::raw2xml($k) . " "; - } + } $result .= " \n"; } @@ -1234,7 +1234,7 @@ abstract class SS_Query implements Iterator { */ public function valid() { if(!$this->queryHasBegun) $this->next(); - return $this->currentRecord !== false; + return $this->currentRecord !== false; } /** diff --git a/tests/core/CoreTest.php b/tests/core/CoreTest.php index fe084f278..5603204e1 100644 --- a/tests/core/CoreTest.php +++ b/tests/core/CoreTest.php @@ -21,6 +21,8 @@ class CoreTest extends SapphireTest { if(file_exists($this->tempPath)) { $this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath . '/' . $user); } else { + $user = getTempFolderUsername(); + // A typical Windows location for where sites are stored on IIS $this->assertEquals(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project/' . $user, getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));