Commit 1bc549de authored by gdd's avatar gdd

Merge remote-tracking branch 'origin/8.x' into 8.x-file-config

parents 80448f69 8ea8b35a
......@@ -174,7 +174,7 @@ Contextual module
Dashboard module
- ?
Database logging module
Database Logging module
- Khalid Baheyeldin 'kbahey' <http://drupal.org/user/4063>
Field module
......
......@@ -351,8 +351,6 @@ function ajax_get_form() {
/**
* Page callback: Handles Ajax requests for the #ajax Form API property.
*
* Path: system/ajax
*
* This rebuilds the form from cache and invokes the defined #ajax['callback']
* to return an Ajax command structure for JavaScript. In case no 'callback' has
* been defined, nothing will happen.
......@@ -388,11 +386,6 @@ function ajax_form_callback() {
/**
* Theme callback: Returns the correct theme for an Ajax request.
*
* Paths:
* - system/ajax
* - file/ajax
* - file/progress
*
* Many different pages can invoke an Ajax request to system/ajax or another
* generic Ajax path. It is almost always desired for an Ajax response to be
* rendered using the same theme as the base page, because most themes are built
......
<?php
use Drupal\Core\Database\Database;
use Symfony\Component\ClassLoader\UniversalClassLoader;
use Symfony\Component\ClassLoader\ApcUniversalClassLoader;
......
<?php
use Drupal\Core\Database\Database;
/**
* @file
* Common functions that many Drupal modules will need to reference.
......
This diff is collapsed.
This diff is collapsed.
<?php
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Install\TaskException;
/**
* @file
* API functions for installing Drupal.
......@@ -223,6 +226,27 @@ function install_begin_request(&$install_state) {
// Allow command line scripts to override server variables used by Drupal.
require_once DRUPAL_ROOT . '/core/includes/bootstrap.inc';
// Ensure that the class loader is available so that we can leverage classes
// as part of the install routine.
$loader = drupal_classloader();
// Register explicit vendor namespaces.
$loader->registerNamespaces(array(
// All Symfony-borrowed code lives in /core/includes/Symfony.
'Symfony' => DRUPAL_ROOT . '/core/vendor',
));
// Register the Drupal namespace for classes in core as a fallback.
// This allows to register additional namespaces within the Drupal namespace
// (e.g., for modules) and avoids an additional file_exists() on the Drupal
// core namespace, since the class loader can already determine the best
// namespace match based on a string comparison. It further allows modules to
// register/overload namespaces in Drupal core.
$loader->registerNamespaceFallbacks(array(
// All Drupal-namespaced code in core lives in /core/includes/Drupal.
'Drupal' => DRUPAL_ROOT . '/core/lib',
));
if (!$install_state['interactive']) {
drupal_override_server_variables($install_state['server']);
}
......@@ -961,7 +985,7 @@ function install_database_errors($database, $settings_file) {
try {
db_run_tasks($driver);
}
catch (DatabaseTaskException $e) {
catch (TaskException $e) {
// These are generic errors, so we do not have any specific key of the
// database connection array to attach them to; therefore, we just put
// them in the error array with standard numeric keys.
......
This diff is collapsed.
<?php
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\Query\SelectInterface;
/**
* @file
* Functions to aid in presenting database results as a set of pages.
*/
/**
* Query extender for pager queries.
*
* This is the "default" pager mechanism. It creates a paged query with a fixed
* number of entries per page.
*/
class PagerDefault extends SelectQueryExtender {
class PagerDefault extends SelectExtender {
/**
* The highest element we've autogenerated so far.
......@@ -42,7 +45,7 @@ class PagerDefault extends SelectQueryExtender {
*/
protected $customCountQuery = FALSE;
public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
// Add pager tag. Do this here to ensure that it is always added before
......@@ -103,7 +106,7 @@ protected function ensureElement() {
* The count query object. It must return a single row with a single column,
* which is the total number of records.
*/
public function setCountQuery(SelectQueryInterface $query) {
public function setCountQuery(SelectInterface $query) {
$this->customCountQuery = $query;
}
......
<?php
use Drupal\Core\Database\Database;
/**
* @file
* This file contains the code registry parser engine.
......@@ -20,18 +22,12 @@
*/
function _registry_update() {
// The registry serves as a central autoloader for all classes, including
// the database query builders. However, the registry rebuild process
// requires write ability to the database, which means having access to the
// query builders that require the registry in order to be loaded. That
// causes a fatal race condition. Therefore we manually include the
// appropriate query builders for the currently active database before the
// registry rebuild process runs.
// The registry serves as a central autoloader for all non-namespaced classes.
// It is backed by the database, but the database system is autoloaded using
// a PSR-0 class loader. That avoids a fata circular dependency here, since
// the other class loader will be able to load the database for us.
$connection_info = Database::getConnectionInfo();
$driver = $connection_info['default']['driver'];
require_once DRUPAL_ROOT . '/core/includes/database/query.inc';
require_once DRUPAL_ROOT . '/core/includes/database/select.inc';
require_once DRUPAL_ROOT . '/core/includes/database/' . $driver . '/query.inc';
// Get current list of modules and their files.
$modules = db_query("SELECT * FROM {system} WHERE type = 'module'")->fetchAll();
......
<?php
use Drupal\Core\Database\Connection;
use Drupal\Core\Database\Query\SelectExtender;
use Drupal\Core\Database\Query\SelectInterface;
/**
* @file
* Functions to aid in the creation of sortable tables.
......@@ -8,11 +12,10 @@
* column headers that the user can click on to sort the table by that column.
*/
/**
* Query extender class for tablesort queries.
*/
class TableSort extends SelectQueryExtender {
class TableSort extends SelectExtender {
/**
* The array of fields that can be sorted by.
......@@ -21,7 +24,7 @@ class TableSort extends SelectQueryExtender {
*/
protected $header = array();
public function __construct(SelectQueryInterface $query, DatabaseConnection $connection) {
public function __construct(SelectInterface $query, Connection $connection) {
parent::__construct($query, $connection);
// Add convenience tag to mark that this is an extended query. We have to
......
This diff is collapsed.
<?php
/**
* @file
* Definition of Drupal\Core\Database\ConnectionNotDefinedException
*/
namespace Drupal\Core\Database;
use RuntimeException;
/**
* Exception thrown if an undefined database connection is requested.
*/
class ConnectionNotDefinedException extends RuntimeException {}
This diff is collapsed.
<?php
/**
* @file
* Definition of Drupal\Core\Database\DatabaseException
*/
namespace Drupal\Core\Database;
/**
* Interface for a database exception.
*
* All Database exceptions should implement this interface so that they can be
* caught collectively. Note that this applies only to Drupal-spawned
* exceptions. PDOException will not implement this interface and module
* developers should account for it separately.
*/
interface DatabaseException { }
......@@ -2,15 +2,24 @@
/**
* @file
* Database interface code for MySQL database servers.
* Definition of Drupal\Core\Database\Driver\mysql\Connection
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\TransactionCommitFailedException;
use Drupal\Core\Database\Connection as DatabaseConnection;
use PDO;
use PDOException;
/**
* @ingroup database
* @{
*/
class DatabaseConnection_mysql extends DatabaseConnection {
class Connection extends DatabaseConnection {
/**
* Flag to indicate if we have registered the nextID cleanup function.
......@@ -165,7 +174,7 @@ protected function popCommittableTransactions() {
unset($this->transactionLayers[$name]);
if (empty($this->transactionLayers)) {
if (!PDO::commit()) {
throw new DatabaseTransactionCommitFailedException();
throw new TransactionCommitFailedException();
}
}
else {
......
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Delete
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Delete as QueryDelete;
class Delete extends QueryDelete { }
<?php
/**
* @ingroup database
* @{
*/
/**
* @file
* Query code for MySQL embedded database engine.
* Definition of Drupal\Core\Database\Driver\mysql\Insert
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Insert as QueryInsert;
class InsertQuery_mysql extends InsertQuery {
class Insert extends QueryInsert {
public function execute() {
if (!$this->preExecute()) {
......@@ -85,23 +83,3 @@ public function __toString() {
return $query;
}
}
class TruncateQuery_mysql extends TruncateQuery {
public function __toString() {
// TRUNCATE is actually a DDL statement on MySQL, and DDL statements are
// not transactional, and result in an implicit COMMIT. When we are in a
// transaction, fallback to the slower, but transactional, DELETE.
if ($this->connection->inTransaction()) {
// Create a comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '}';
}
else {
return parent::__toString();
}
}
}
/**
* @} End of "ingroup database".
*/
......@@ -2,13 +2,17 @@
/**
* @file
* Installation code for MySQL embedded database engine.
* Definition of Drupal\Core\Database\Driver\mysql\Install\Tasks
*/
namespace Drupal\Core\Database\Driver\mysql\Install;
use Drupal\Core\Database\Install\Tasks as InstallTasks;
/**
* Specifies installation tasks for MySQL and equivalent databases.
*/
class DatabaseTasks_mysql extends DatabaseTasks {
class Tasks extends InstallTasks {
/**
* The PDO driver name for MySQL and equivalent databases.
*
......@@ -30,4 +34,3 @@ public function minimumVersion() {
return '5.0.15';
}
}
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Merge
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Merge as QueryMerge;
class Merge extends QueryMerge { }
......@@ -2,16 +2,25 @@
/**
* @file
* Database schema code for MySQL database servers.
* Definition of Drupal\Core\Database\Driver\mysql\Schema
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Database;
use Drupal\Core\Database\Query\Condition;
use Drupal\Core\Database\SchemaObjectExistsException;
use Drupal\Core\Database\SchemaObjectDoesNotExistException;
use Drupal\Core\Database\Schema as DatabaseSchema;
use Exception;
/**
* @ingroup schemaapi
* @{
*/
class DatabaseSchema_mysql extends DatabaseSchema {
class Schema extends DatabaseSchema {
/**
* Maximum length of a table comment in MySQL.
......@@ -59,7 +68,7 @@ protected function buildTableNameCondition($table_name, $operator = '=', $add_pr
$table_info = $this->getPrefixInfo($table_name, $add_prefix);
$condition = new DatabaseCondition('AND');
$condition = new Condition('AND');
$condition->condition('table_schema', $table_info['database']);
$condition->condition('table_name', $table_info['table'], $operator);
return $condition;
......@@ -296,10 +305,10 @@ protected function createKeysSqlHelper($fields) {
public function renameTable($table, $new_name) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
throw new SchemaObjectDoesNotExistException(t("Cannot rename %table to %table_new: table %table doesn't exist.", array('%table' => $table, '%table_new' => $new_name)));
}
if ($this->tableExists($new_name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
throw new SchemaObjectExistsException(t("Cannot rename %table to %table_new: table %table_new already exists.", array('%table' => $table, '%table_new' => $new_name)));
}
$info = $this->getPrefixInfo($new_name);
......@@ -317,10 +326,10 @@ public function dropTable($table) {
public function addField($table, $field, $spec, $keys_new = array()) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
throw new SchemaObjectDoesNotExistException(t("Cannot add field %table.%field: table doesn't exist.", array('%field' => $field, '%table' => $table)));
}
if ($this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
throw new SchemaObjectExistsException(t("Cannot add field %table.%field: field already exists.", array('%field' => $field, '%table' => $table)));
}
$fixnull = FALSE;
......@@ -356,7 +365,7 @@ public function dropField($table, $field) {
public function fieldSetDefault($table, $field, $default) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
throw new SchemaObjectDoesNotExistException(t("Cannot set default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
if (!isset($default)) {
......@@ -371,7 +380,7 @@ public function fieldSetDefault($table, $field, $default) {
public function fieldSetNoDefault($table, $field) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
throw new SchemaObjectDoesNotExistException(t("Cannot remove default value of field %table.%field: field doesn't exist.", array('%table' => $table, '%field' => $field)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ALTER COLUMN `' . $field . '` DROP DEFAULT');
......@@ -386,10 +395,10 @@ public function indexExists($table, $name) {
public function addPrimaryKey($table, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
throw new SchemaObjectDoesNotExistException(t("Cannot add primary key to table %table: table doesn't exist.", array('%table' => $table)));
}
if ($this->indexExists($table, 'PRIMARY')) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
throw new SchemaObjectExistsException(t("Cannot add primary key to table %table: primary key already exists.", array('%table' => $table)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD PRIMARY KEY (' . $this->createKeySql($fields) . ')');
......@@ -406,10 +415,10 @@ public function dropPrimaryKey($table) {
public function addUniqueKey($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
throw new SchemaObjectDoesNotExistException(t("Cannot add unique key %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
throw new SchemaObjectExistsException(t("Cannot add unique key %name to table %table: unique key already exists.", array('%table' => $table, '%name' => $name)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD UNIQUE KEY `' . $name . '` (' . $this->createKeySql($fields) . ')');
......@@ -426,10 +435,10 @@ public function dropUniqueKey($table, $name) {
public function addIndex($table, $name, $fields) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
throw new SchemaObjectDoesNotExistException(t("Cannot add index %name to table %table: table doesn't exist.", array('%table' => $table, '%name' => $name)));
}
if ($this->indexExists($table, $name)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
throw new SchemaObjectExistsException(t("Cannot add index %name to table %table: index already exists.", array('%table' => $table, '%name' => $name)));
}
$this->connection->query('ALTER TABLE {' . $table . '} ADD INDEX `' . $name . '` (' . $this->createKeySql($fields) . ')');
......@@ -446,10 +455,10 @@ public function dropIndex($table, $name) {
public function changeField($table, $field, $field_new, $spec, $keys_new = array()) {
if (!$this->fieldExists($table, $field)) {
throw new DatabaseSchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
throw new SchemaObjectDoesNotExistException(t("Cannot change the definition of field %table.%name: field doesn't exist.", array('%table' => $table, '%name' => $field)));
}
if (($field != $field_new) && $this->fieldExists($table, $field_new)) {
throw new DatabaseSchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
throw new SchemaObjectExistsException(t("Cannot rename field %table.%name to %name_new: target field already exists.", array('%table' => $table, '%name' => $field, '%name_new' => $field_new)));
}
$sql = 'ALTER TABLE {' . $table . '} CHANGE `' . $field . '` ' . $this->createFieldSql($field_new, $this->processField($spec));
......
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Select
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Select as QuerySelect;
class Select extends QuerySelect { }
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Transaction
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Transaction as DatabaseTransaction;
class Transaction extends DatabaseTransaction { }
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Truncate
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Truncate as QueryTruncate;
class Truncate extends QueryTruncate {
public function __toString() {
// TRUNCATE is actually a DDL statement on MySQL, and DDL statements are
// not transactional, and result in an implicit COMMIT. When we are in a
// transaction, fallback to the slower, but transactional, DELETE.
if ($this->connection->inTransaction()) {
// Create a comment string to prepend to the query.
$comments = $this->connection->makeComment($this->comments);
return $comments . 'DELETE FROM {' . $this->connection->escapeTable($this->table) . '}';
}
else {
return parent::__toString();
}
}
}
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\mysql\Update
*/
namespace Drupal\Core\Database\Driver\mysql;
use Drupal\Core\Database\Query\Update as QueryUpdate;
class Update extends QueryUpdate { }
<?php
/**
* @file
* Definition of Drupal\Core\Database\Driver\pgsql\Delete
*/
namespace Drupal\Core\Database\Driver\pgsql;
use Drupal\Core\Database\Query\Delete as QueryDelete;
class Delete extends QueryDelete { }
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.