Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -129,7 +129,7 @@ abstract class Database {
*/
final public static function getLog($logging_key, $key = 'default') {
if (empty(self::$logs[$key])) {
return NULL;
return [];
}
$queries = self::$logs[$key]->get($logging_key);
self::$logs[$key]->end($logging_key);

View file

@ -411,6 +411,11 @@ class Schema extends DatabaseSchema {
->fields(array($field => $spec['initial']))
->execute();
}
if (isset($spec['initial_from_field'])) {
$this->connection->update($table)
->expression($field, $spec['initial_from_field'])
->execute();
}
if ($fixnull) {
$spec['not null'] = TRUE;
$this->changeField($table, $field, $field, $spec);

View file

@ -210,13 +210,8 @@ class Connection extends DatabaseConnection {
// need to be escaped.
$escaped = $this->escapeTable($table) . '.' . $this->escapeAlias($column);
}
elseif (preg_match('/[A-Z]/', $escaped)) {
// Quote the field name for case-sensitivity.
$escaped = '"' . $escaped . '"';
}
elseif (in_array(strtolower($escaped), $this->postgresqlReservedKeyWords)) {
// Quote the field name for PostgreSQL reserved key words.
$escaped = '"' . $escaped . '"';
else {
$escaped = $this->doEscape($escaped);
}
return $escaped;
@ -227,16 +222,7 @@ class Connection extends DatabaseConnection {
*/
public function escapeAlias($field) {
$escaped = preg_replace('/[^A-Za-z0-9_]+/', '', $field);
// Escape the alias in quotes for case-sensitivity.
if (preg_match('/[A-Z]/', $escaped)) {
$escaped = '"' . $escaped . '"';
}
elseif (in_array(strtolower($escaped), $this->postgresqlReservedKeyWords)) {
// Quote the alias name for PostgreSQL reserved key words.
$escaped = '"' . $escaped . '"';
}
$escaped = $this->doEscape($escaped);
return $escaped;
}
@ -246,18 +232,35 @@ class Connection extends DatabaseConnection {
public function escapeTable($table) {
$escaped = parent::escapeTable($table);
// Quote identifier to make it case-sensitive.
if (preg_match('/[A-Z]/', $escaped)) {
$escaped = '"' . $escaped . '"';
}
elseif (in_array(strtolower($escaped), $this->postgresqlReservedKeyWords)) {
// Quote the table name for PostgreSQL reserved key words.
$escaped = '"' . $escaped . '"';
}
// Ensure that each part (database, schema and table) of the table name is
// properly and independently escaped.
$parts = explode('.', $escaped);
$parts = array_map([$this, 'doEscape'], $parts);
$escaped = implode('.', $parts);
return $escaped;
}
/**
* Escape a string if needed.
*
* @param $string
* The string to escape.
* @return string
* The escaped string.
*/
protected function doEscape($string) {
// Quote identifier to make it case-sensitive.
if (preg_match('/[A-Z]/', $string)) {
$string = '"' . $string . '"';
}
elseif (in_array(strtolower($string), $this->postgresqlReservedKeyWords)) {
// Quote the string for PostgreSQL reserved key words.
$string = '"' . $string . '"';
}
return $string;
}
public function driver() {
return 'pgsql';
}

View file

@ -65,7 +65,7 @@ class Tasks extends InstallTasks {
$this->pass('Drupal can CONNECT to the database ok.');
}
catch (\Exception $e) {
// Attempt to create the database if it is not found.
// Attempt to create the database if it is not found.
if ($e->getCode() == Connection::DATABASE_NOT_FOUND) {
// Remove the database string from connection info.
$connection_info = Database::getConnectionInfo();

View file

@ -531,6 +531,11 @@ class Schema extends DatabaseSchema {
->fields(array($field => $spec['initial']))
->execute();
}
if (isset($spec['initial_from_field'])) {
$this->connection->update($table)
->expression($field, $spec['initial_from_field'])
->execute();
}
if ($fixnull) {
$this->connection->query("ALTER TABLE {" . $table . "} ALTER $field SET NOT NULL");
}

View file

@ -124,6 +124,16 @@ class Connection extends DatabaseConnection {
// Create a user-space case-insensitive collation with UTF-8 support.
$pdo->sqliteCreateCollation('NOCASE_UTF8', array('Drupal\Component\Utility\Unicode', 'strcasecmp'));
// Set SQLite init_commands if not already defined. Enable the Write-Ahead
// Logging (WAL) for SQLite. See https://www.drupal.org/node/2348137 and
// https://www.sqlite.org/wal.html.
$connection_options += array(
'init_commands' => array(),
);
$connection_options['init_commands'] += array(
'wal' => "PRAGMA journal_mode=WAL",
);
// Execute sqlite init_commands.
if (isset($connection_options['init_commands'])) {
$pdo->exec(implode('; ', $connection_options['init_commands']));

View file

@ -316,6 +316,11 @@ class Schema extends DatabaseSchema {
->fields(array($field => $specification['initial']))
->execute();
}
if (isset($specification['initial_from_field'])) {
$this->connection->update($table)
->expression($field, $specification['initial_from_field'])
->execute();
}
}
else {
// We cannot add the field directly. Use the slower table alteration
@ -335,6 +340,13 @@ class Schema extends DatabaseSchema {
'arguments' => array(':newfieldinitial' => $specification['initial']),
);
}
elseif (isset($specification['initial_from_field'])) {
// If we have a initial value, copy it over.
$mapping[$field] = array(
'expression' => $specification['initial_from_field'],
'arguments' => [],
);
}
else {
// Else use the default of the field.
$mapping[$field] = NULL;

View file

@ -300,6 +300,7 @@ class Condition implements ConditionInterface, \Countable {
// $specials does not use drupal_static as its value never changes.
static $specials = array(
'BETWEEN' => array('delimiter' => ' AND '),
'NOT BETWEEN' => array('delimiter' => ' AND '),
'IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
'NOT IN' => array('delimiter' => ', ', 'prefix' => ' (', 'postfix' => ')'),
'EXISTS' => array('prefix' => ' (', 'postfix' => ')'),

View file

@ -340,6 +340,12 @@ interface SelectInterface extends ConditionInterface, AlterableInterface, Extend
* An array of arguments to replace into the $condition of this join.
* @return
* The unique alias that was assigned for this table.
*
* @deprecated as of Drupal 8.1.x, will be removed in Drupal 9.0.0. Instead,
* change the query to use leftJoin(). For instance:
* db_query('A')->rightJoin('B') is identical to
* db_query('B')->leftJoin('A'). This functionality has been deprecated
* because SQLite does not support it.
*/
public function rightJoin($table, $alias = NULL, $condition = NULL, $arguments = array());

View file

@ -305,6 +305,8 @@ abstract class Schema implements PlaceholderInterface {
* created field will be set to the value of the key in all rows.
* This is most useful for creating NOT NULL columns with no default
* value in existing tables.
* Alternatively, the 'initial_form_field' key may be used, which will
* auto-populate the new field with values from the specified field.
* @param $keys_new
* (optional) Keys and indexes specification to be created on the
* table along with adding the field. The format is the same as a

View file

@ -90,7 +90,7 @@ interface StatementInterface extends \Traversable {
* If $mode is PDO::FETCH_CLASS, the optional arguments to pass to the
* constructor.
*/
public function setFetchMode($mode, $a1 = NULL, $a2 = array());
public function setFetchMode($mode, $a1 = NULL, $a2 = array());
/**
* Fetches the next row from a result set.
@ -109,7 +109,7 @@ interface StatementInterface extends \Traversable {
* @return
* A result, formatted according to $mode.
*/
public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL);
public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL);
/**
* Returns a single field from the next record of a result set.
@ -128,7 +128,7 @@ interface StatementInterface extends \Traversable {
* The object will be of the class specified by StatementInterface::setFetchMode()
* or stdClass if not specified.
*/
public function fetchObject();
public function fetchObject();
/**
* Fetches the next row and returns it as an associative array.
@ -155,7 +155,7 @@ interface StatementInterface extends \Traversable {
* @return
* An array of results.
*/
function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL);
function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL);
/**
* Returns an entire single column of a result set as an indexed array.