diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index a34fdc8c9fd2ec00cb4367981c27927ebf7f2466..42b0909a0310ad15497c50742c9fa01f7172782c 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -958,16 +958,7 @@ function install_get_form($form_id, array &$install_state) { // values taken from the installation state. $install_form_id = $form_builder->getFormId($form_id, $form_state); if (!empty($install_state['forms'][$install_form_id])) { - $values = $install_state['forms'][$install_form_id]; - if ($install_form_id === 'install_settings_form' && isset($values['driver']) && !str_contains($values['driver'], "\\")) { - @trigger_error("Passing a database driver name '{$values['driver']}' to " . __FUNCTION__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Pass a database driver namespace instead. See https://www.drupal.org/node/3258175', E_USER_DEPRECATED); - $driverExtension = Database::getDriverList()->getFromDriverName($values['driver']); - $tmp = []; - $tmp['driver'] = $driverExtension->getName(); - $tmp[$driverExtension->getName()] = $values[$values['driver']]; - $values = $tmp; - } - $form_state->setValues($values); + $form_state->setValues($install_state['forms'][$install_form_id]); } $form_builder->submitForm($form_id, $form_state); diff --git a/core/includes/install.inc b/core/includes/install.inc index 083776a5377030be7ea87ae8f0b5400b4aefeb5d..f7966a040a2cc819dbcad7cd8737178c5ca0c90c 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -141,109 +141,6 @@ function drupal_install_profile_distribution_version() { } } -/** - * Detects all supported databases that are compiled into PHP. - * - * @return array - * An array of database types compiled into PHP. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * DatabaseDriverList::getList() instead. - * - * @see https://www.drupal.org/node/3258175 - */ -function drupal_detect_database_types() { - @trigger_error('drupal_detect_database_types() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175', E_USER_DEPRECATED); - $databases = drupal_get_database_types(); - - foreach ($databases as $driver => $installer) { - $databases[$driver] = $installer->name(); - } - - return $databases; -} - -/** - * Returns all supported database driver installer objects. - * - * @return \Drupal\Core\Database\Install\Tasks[] - * An array of available database driver installer objects. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * DatabaseDriverList::getList() instead. - * - * @see https://www.drupal.org/node/3258175 - */ -function drupal_get_database_types() { - @trigger_error('drupal_get_database_types() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175', E_USER_DEPRECATED); - $databases = []; - $drivers = []; - - // The internal database driver name is any valid PHP identifier. - $mask = ExtensionDiscovery::PHP_FUNCTION_PATTERN; - - // Find drivers in the Drupal\Driver namespace. - // @todo remove discovering in the Drupal\Driver namespace in D10. - /** @var \Drupal\Core\File\FileSystemInterface $file_system */ - $file_system = \Drupal::service('file_system'); - $files = []; - if (is_dir(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database')) { - $files = $file_system->scanDirectory(DRUPAL_ROOT . '/drivers/lib/Drupal/Driver/Database/', $mask, ['recurse' => FALSE]); - } - foreach ($files as $file) { - if (file_exists($file->uri . '/Install/Tasks.php')) { - // The namespace doesn't need to be added here, because - // db_installer_object() will find it. - $drivers[$file->filename] = NULL; - } - } - - // Find drivers in Drupal module namespaces. - /** @var \Composer\Autoload\ClassLoader $class_loader */ - $class_loader = \Drupal::service('class_loader'); - // We cannot use the file cache because it does not always exist. - $extension_discovery = new ExtensionDiscovery(DRUPAL_ROOT, FALSE, []); - $modules = $extension_discovery->scan('module'); - foreach ($modules as $module) { - $module_driver_path = DRUPAL_ROOT . '/' . $module->getPath() . '/src/Driver/Database'; - if (is_dir($module_driver_path)) { - $driver_files = $file_system->scanDirectory($module_driver_path, $mask, ['recurse' => FALSE]); - foreach ($driver_files as $driver_file) { - $tasks_file = $module_driver_path . '/' . $driver_file->filename . '/Install/Tasks.php'; - if (file_exists($tasks_file)) { - $namespace = 'Drupal\\' . $module->getName() . '\\Driver\\Database\\' . $driver_file->filename; - - // Add the driver with its own classes' namespace. - $drivers[$driver_file->filename] = $namespace; - - // The directory needs to be added to the autoloader, because this is - // early in the installation process: the module hasn't been enabled - // yet and the database connection info array (including its 'autoload' - // key) hasn't been created yet. - $class_loader->addPsr4($namespace . '\\', $module->getPath() . '/src/Driver/Database/' . $driver_file->filename); - } - } - } - } - - foreach ($drivers as $driver => $namespace) { - $installer_class = $namespace . "\\Install\\Tasks"; - $installer = new $installer_class(); - if ($installer->installable()) { - $databases[$driver] = $installer; - } - } - - // Usability: unconditionally put the MySQL driver on top. - if (isset($databases['mysql'])) { - $mysql_database = $databases['mysql']; - unset($databases['mysql']); - $databases = ['mysql' => $mysql_database] + $databases; - } - - return $databases; -} - /** * Replaces values in settings.php with values in the submitted array. * @@ -1080,46 +977,3 @@ function install_profile_info($profile, $langcode = 'en') { } return $cache[$profile][$langcode]; } - -/** - * Returns a database installer object. - * - * Before calling this function it is important the database installer object - * is autoloadable. Database drivers provided by contributed modules are added - * to the autoloader in drupal_get_database_types() and Settings::initialize(). - * - * @param $driver - * The name of the driver. - * @param string $namespace - * (optional) The database driver namespace. - * - * @return \Drupal\Core\Database\Install\Tasks - * A class defining the requirements and tasks for installing the database. - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3256641 - * @see drupal_get_database_types() - * @see \Drupal\Core\Site\Settings::initialize() - */ -function db_installer_object($driver, $namespace = NULL) { - @trigger_error('db_installer_object() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3256641', E_USER_DEPRECATED); - - // We cannot use Database::getConnection->getDriverClass() here, because - // the connection object is not yet functional. - if ($namespace) { - $task_class = $namespace . "\\Install\\Tasks"; - return new $task_class(); - } - // Old Drupal 8 style contrib namespace. - $task_class = "Drupal\\Driver\\Database\\{$driver}\\Install\\Tasks"; - if (class_exists($task_class)) { - return new $task_class(); - } - else { - // Core provided driver. - $task_class = "Drupal\\Core\\Database\\Driver\\{$driver}\\Install\\Tasks"; - return new $task_class(); - } -} diff --git a/core/lib/Drupal/Core/Command/InstallCommand.php b/core/lib/Drupal/Core/Command/InstallCommand.php index ef4ec3c1080a2b017c9887d4aa3f635389596c06..5691f9d54160ea5f4623500a3e98a5daf56a7333 100644 --- a/core/lib/Drupal/Core/Command/InstallCommand.php +++ b/core/lib/Drupal/Core/Command/InstallCommand.php @@ -131,6 +131,7 @@ protected function isDrupalInstalled() { * The command exit status. */ protected function install($class_loader, SymfonyStyle $io, $profile, $langcode, $site_path, $site_name) { + $sqliteDriverNamespace = 'Drupal\\sqlite\\Driver\\Database\\sqlite'; $password = Crypt::randomBytesBase64(12); $parameters = [ 'interactive' => FALSE, @@ -141,8 +142,8 @@ protected function install($class_loader, SymfonyStyle $io, $profile, $langcode, ], 'forms' => [ 'install_settings_form' => [ - 'driver' => 'sqlite', - 'sqlite' => [ + 'driver' => $sqliteDriverNamespace, + $sqliteDriverNamespace => [ 'database' => $site_path . '/files/.sqlite', ], ], diff --git a/core/lib/Drupal/Core/Config/DatabaseStorage.php b/core/lib/Drupal/Core/Config/DatabaseStorage.php index 4430298da39ed91119d22da0384ac73c8ac9a719..81a0b50c65210b5960e963ab7f2d2f8bf3818476 100644 --- a/core/lib/Drupal/Core/Config/DatabaseStorage.php +++ b/core/lib/Drupal/Core/Config/DatabaseStorage.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Config; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; use Drupal\Core\Database\DatabaseException; use Drupal\Core\DependencyInjection\DependencySerializationTrait; @@ -152,10 +151,7 @@ public function write($name, array $data) { * @return bool */ protected function doWrite($name, $data) { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options = ['return' => Database::RETURN_AFFECTED] + $this->options; - return (bool) $this->connection->merge($this->table, $options) + return (bool) $this->connection->merge($this->table, $this->options) ->keys(['collection', 'name'], [$this->collection, $name]) ->fields(['data' => $data]) ->execute(); @@ -229,10 +225,7 @@ protected static function schemaDefinition() { * @todo Ignore replica targets for data manipulation operations. */ public function delete($name) { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options = ['return' => Database::RETURN_AFFECTED] + $this->options; - return (bool) $this->connection->delete($this->table, $options) + return (bool) $this->connection->delete($this->table, $this->options) ->condition('collection', $this->collection) ->condition('name', $name) ->execute(); @@ -244,10 +237,7 @@ public function delete($name) { * @throws \PDOException */ public function rename($name, $new_name) { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options = ['return' => Database::RETURN_AFFECTED] + $this->options; - return (bool) $this->connection->update($this->table, $options) + return (bool) $this->connection->update($this->table, $this->options) ->fields(['name' => $new_name]) ->condition('name', $name) ->condition('collection', $this->collection) @@ -300,10 +290,7 @@ public function listAll($prefix = '') { */ public function deleteAll($prefix = '') { try { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options = ['return' => Database::RETURN_AFFECTED] + $this->options; - return (bool) $this->connection->delete($this->table, $options) + return (bool) $this->connection->delete($this->table, $this->options) ->condition('name', $prefix . '%', 'LIKE') ->condition('collection', $this->collection) ->execute(); diff --git a/core/lib/Drupal/Core/Database/Connection.php b/core/lib/Drupal/Core/Database/Connection.php index a5fad548940465781c98948ef8e3b5c3cab7b128..11fa3a6835ec3f4d33da2d3e92c0ff29c8eb1b1b 100644 --- a/core/lib/Drupal/Core/Database/Connection.php +++ b/core/lib/Drupal/Core/Database/Connection.php @@ -55,22 +55,6 @@ abstract class Connection { */ protected $logger = NULL; - /** - * Tracks the number of "layers" of transactions currently active. - * - * On many databases transactions cannot nest. Instead, we track - * nested calls to transactions and collapse them into a single - * transaction. - * - * @var array - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. The - * transaction stack is now managed by TransactionManager. - * - * @see https://www.drupal.org/node/3381002 - */ - protected $transactionLayers = []; - /** * Index of what driver-specific class to use for various operations. * @@ -134,54 +118,6 @@ abstract class Connection { */ protected array $tablePlaceholderReplacements; - /** - * The prefixes used by this database connection. - * - * @var array - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3257198 - */ - protected $prefixes = []; - - /** - * List of search values for use in prefixTables(). - * - * @var array - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3257198 - */ - protected $prefixSearch = []; - - /** - * List of replacement values for use in prefixTables(). - * - * @var array - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3257198 - */ - protected $prefixReplace = []; - - /** - * List of un-prefixed table names, keyed by prefixed table names. - * - * @var array - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3257198 - */ - protected $unprefixedTablesMap = []; - /** * List of escaped table names, keyed by unescaped names. * @@ -206,18 +142,6 @@ abstract class Connection { */ protected $escapedAliases = []; - /** - * Post-root (non-nested) transaction commit callbacks. - * - * @var callable[] - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. The - * transaction end callbacks are now managed by TransactionManager. - * - * @see https://www.drupal.org/node/3381002 - */ - protected $rootTransactionEndCallbacks = []; - /** * The identifier quote characters for the database type. * @@ -240,7 +164,7 @@ abstract class Connection { /** * The transaction manager. */ - protected TransactionManagerInterface|FALSE $transactionManager; + protected TransactionManagerInterface $transactionManager; /** * Constructs a Connection object. @@ -302,19 +226,9 @@ public function __destruct() { */ public function commitAll() { $manager = $this->transactionManager(); - if ($manager && $manager->inTransaction() && method_exists($manager, 'commitAll')) { + if ($manager->inTransaction() && method_exists($manager, 'commitAll')) { $this->transactionManager()->commitAll(); } - - // BC layer. - // @phpstan-ignore-next-line - if (!empty($this->transactionLayers)) { - // Make all transactions committable. - // @phpstan-ignore-next-line - $this->transactionLayers = array_fill_keys(array_keys($this->transactionLayers), FALSE); - // @phpstan-ignore-next-line - $this->popCommittableTransactions(); - } } /** @@ -342,27 +256,6 @@ public function getClientConnection(): object { * class. If a string is specified, each record will be fetched into a new * object of that class. The behavior of all other values is defined by PDO. * See http://php.net/manual/pdostatement.fetch.php - * - return: (deprecated) Depending on the type of query, different return - * values may be meaningful. This directive instructs the system which type - * of return value is desired. The system will generally set the correct - * value automatically, so it is extremely rare that a module developer will - * ever need to specify this value. Setting it incorrectly will likely lead - * to unpredictable results or fatal errors. Legal values include: - * - Database::RETURN_STATEMENT: Return the prepared statement object for - * the query. This is usually only meaningful for SELECT queries, where - * the statement object is how one accesses the result set returned by the - * query. - * - Database::RETURN_AFFECTED: Return the number of rows found (matched) by - * the WHERE clause of an UPDATE or DELETE query (not the number of rows - * actually changed). Note that although named RETURN_AFFECTED for - * historical reasons, the number of rows matched is returned for - * consistency across database engines. - * - Database::RETURN_INSERT_ID: Return the sequence ID (primary key) - * created by an INSERT statement on a table that contains a serial - * column. - * - Database::RETURN_NULL: Do not return anything, as there is no - * meaningful value to return. That is the case for INSERT queries on - * tables that do not contain a serial column. * - allow_delimiter_in_query: By default, queries which have the ; delimiter * any place in them will cause an exception. This reduces the chance of SQL * injection attacks that terminate the original query and add one or more @@ -496,42 +389,6 @@ public function quoteIdentifiers($sql) { return str_replace(['[', ']'], $this->identifierQuotes, $sql); } - /** - * Find the prefix for a table. - * - * This function is for when you want to know the prefix of a table. This - * is not used in prefixTables due to performance reasons. - * - * @param string $table - * (optional) The table to find the prefix for. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. - * Instead, you should just use Connection::getPrefix(). - * - * @see https://www.drupal.org/node/3260849 - */ - public function tablePrefix($table = 'default') { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead, you should just use Connection::getPrefix(). See https://www.drupal.org/node/3260849', E_USER_DEPRECATED); - return $this->prefix; - } - - /** - * Gets a list of individually prefixed table names. - * - * @return array - * An array of un-prefixed table names, keyed by their fully qualified table - * names (i.e. prefix + table_name). - * - * @deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3257198 - */ - public function getUnprefixedTablesMap() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3257198', E_USER_DEPRECATED); - return $this->unprefixedTablesMap; - } - /** * Get a fully qualified table name. * @@ -573,9 +430,7 @@ public function getFullQualifiedTableName($table) { * @throws \Drupal\Core\Database\DatabaseExceptionWrapper */ public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface { - if (isset($options['return'])) { - @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED); - } + assert(!isset($options['return']), 'Passing "return" option to prepareStatement() has no effect. See https://www.drupal.org/node/3185520'); try { $query = $this->preprocessStatement($query, $options); @@ -704,39 +559,6 @@ public function getLogger() { return $this->logger; } - /** - * Creates the appropriate sequence name for a given table and serial field. - * - * This information is exposed to all database drivers, although it is only - * useful on some of them. This method is table prefix-aware. - * - * Note that if a sequence was generated automatically by the database, its - * name might not match the one returned by this function. Therefore, in those - * cases, it is generally advised to use a database-specific way of retrieving - * the name of an auto-created sequence. For example, PostgreSQL provides a - * dedicated function for this purpose: pg_get_serial_sequence(). - * - * @param string $table - * The table name to use for the sequence. - * @param string $field - * The field name to use for the sequence. - * - * @return string - * A table prefix-parsed string for the sequence name. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3377046 - */ - public function makeSequenceName($table, $field) { - @trigger_error(__METHOD__ . "() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3377046", E_USER_DEPRECATED); - $sequence_name = $this->prefixTables('{' . $table . '}_' . $field . '_seq'); - // Remove identifier quotes as we are constructing a new name from a - // prefixed and quoted table name. - return str_replace($this->identifierQuotes, '', $sequence_name); - } - /** * Flatten an array of query comments into a single comment string. * @@ -814,17 +636,8 @@ protected function filterComment($comment = '') { * Typically, $options['return'] will be set by a default or by a query * builder, and should not be set by a user. * - * @return \Drupal\Core\Database\StatementInterface|int|string|null - * This method will return one of the following: - * - If either $options['return'] === self::RETURN_STATEMENT, or - * $options['return'] is not set (due to self::defaultOptions()), - * returns the executed statement. - * - If $options['return'] === self::RETURN_AFFECTED, - * returns the number of rows matched by the query - * (not the number affected). - * - If $options['return'] === self::RETURN_INSERT_ID, - * returns the generated insert ID of the last query as a string. - * - If $options['return'] === self::RETURN_NULL, returns NULL. + * @return \Drupal\Core\Database\StatementInterface|null + * The executed statement. * * @throws \Drupal\Core\Database\DatabaseExceptionWrapper * @throws \Drupal\Core\Database\IntegrityConstraintViolationException @@ -834,54 +647,22 @@ protected function filterComment($comment = '') { */ public function query($query, array $args = [], $options = []) { assert(is_string($query), 'The \'$query\' argument to ' . __METHOD__ . '() must be a string'); + assert(!isset($options['return']), 'Passing "return" option to query() has no effect. See https://www.drupal.org/node/3185520'); + assert(!isset($options['target']), 'Passing "target" option to query() has no effect. See https://www.drupal.org/node/2993033'); // Use default values if not already set. $options += $this->defaultOptions(); - if (isset($options['return'])) { - @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED); - } - - assert(!isset($options['target']), 'Passing "target" option to query() has no effect. See https://www.drupal.org/node/2993033'); - $this->expandArguments($query, $args); - $stmt = $this->prepareStatement($query, $options); - + $statement = $this->prepareStatement($query, $options); try { - $stmt->execute($args, $options); - - // Depending on the type of query we may need to return a different value. - // See DatabaseConnection::defaultOptions() for a description of each - // value. - // @todo the block below is deprecated and as of Drupal 11 will be - // removed, query() will only return a StatementInterface object. - // @see https://www.drupal.org/project/drupal/issues/3256524 - switch ($options['return'] ?? Database::RETURN_STATEMENT) { - case Database::RETURN_STATEMENT: - return $stmt; - - // Database::RETURN_AFFECTED should not be used; enable row counting - // by passing the appropriate argument to the constructor instead. - // @see https://www.drupal.org/node/3186368 - case Database::RETURN_AFFECTED: - $stmt->allowRowCount = TRUE; - return $stmt->rowCount(); - - case Database::RETURN_INSERT_ID: - $sequence_name = $options['sequence_name'] ?? NULL; - return $this->lastInsertId($sequence_name); - - case Database::RETURN_NULL: - return NULL; - - default: - throw new \PDOException('Invalid return directive: ' . $options['return']); - - } + $result = $statement->execute($args, $options); } catch (\Exception $e) { - $this->exceptionHandler()->handleExecutionException($e, $stmt, $args, $options); + $this->exceptionHandler()->handleExecutionException($e, $statement, $args, $options); + $result = FALSE; } + return $result ? $statement : NULL; } /** @@ -972,7 +753,7 @@ public function getDriverClass($class) { 'Truncate', 'Schema', 'Condition', - 'Transaction' => @trigger_error('Calling ' . __METHOD__ . '() for \'' . $class . '\' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use standard autoloading in the methods that return database operations. See https://www.drupal.org/node/3217534', E_USER_DEPRECATED), + 'Transaction' => throw new InvalidQueryException('Calling ' . __METHOD__ . '() for \'' . $class . '\' is not supported. Use standard autoloading in the methods that return database operations. See https://www.drupal.org/node/3217534'), default => NULL, }; if (empty($this->driverClasses[$class])) { @@ -1039,12 +820,9 @@ public function getDriverClass($class) { * * @return \Drupal\Core\Database\ExceptionHandler * The database exceptions handler. - * - * @todo in drupal:11.0.0, return a new ExceptionHandler instance directly. */ public function exceptionHandler() { - $class = $this->getDriverClass('ExceptionHandler'); - return new $class(); + return new ExceptionHandler(); } /** @@ -1065,13 +843,10 @@ public function exceptionHandler() { * driver. * * @see \Drupal\Core\Database\Query\Select - * - * @todo in drupal:11.0.0, return a new Query\Select instance directly. */ public function select($table, $alias = NULL, array $options = []) { assert(is_string($alias) || $alias === NULL, 'The \'$alias\' argument to ' . __METHOD__ . '() must be a string or NULL'); - $class = $this->getDriverClass('Select'); - return new $class($this, $table, $alias, $options); + return new Select($this, $table, $alias, $options); } /** @@ -1089,12 +864,9 @@ public function select($table, $alias = NULL, array $options = []) { * * @see \Drupal\Core\Database\Query\Insert * @see \Drupal\Core\Database\Connection::defaultOptions() - * - * @todo in drupal:11.0.0, return a new Query\Insert instance directly. */ public function insert($table, array $options = []) { - $class = $this->getDriverClass('Insert'); - return new $class($this, $table, $options); + return new Insert($this, $table, $options); } /** @@ -1139,12 +911,9 @@ public function lastInsertId(?string $name = NULL): string { * A new Merge query object. * * @see \Drupal\Core\Database\Query\Merge - * - * @todo in drupal:11.0.0, return a new Query\Merge instance directly. */ public function merge($table, array $options = []) { - $class = $this->getDriverClass('Merge'); - return new $class($this, $table, $options); + return new Merge($this, $table, $options); } /** @@ -1159,14 +928,8 @@ public function merge($table, array $options = []) { * A new Upsert query object. * * @see \Drupal\Core\Database\Query\Upsert - * - * @todo in drupal:11.0.0, make this method abstract since Query\Upsert is - * an abstract class. */ - public function upsert($table, array $options = []) { - $class = $this->getDriverClass('Upsert'); - return new $class($this, $table, $options); - } + abstract public function upsert($table, array $options = []); /** * Prepares and returns an UPDATE query object. @@ -1183,12 +946,9 @@ public function upsert($table, array $options = []) { * * @see \Drupal\Core\Database\Query\Update * @see \Drupal\Core\Database\Connection::defaultOptions() - * - * @todo in drupal:11.0.0, return a new Query\Update instance directly. */ public function update($table, array $options = []) { - $class = $this->getDriverClass('Update'); - return new $class($this, $table, $options); + return new Update($this, $table, $options); } /** @@ -1206,12 +966,9 @@ public function update($table, array $options = []) { * * @see \Drupal\Core\Database\Query\Delete * @see \Drupal\Core\Database\Connection::defaultOptions() - * - * @todo in drupal:11.0.0, return a new Query\Delete instance directly. */ public function delete($table, array $options = []) { - $class = $this->getDriverClass('Delete'); - return new $class($this, $table, $options); + return new Delete($this, $table, $options); } /** @@ -1226,12 +983,9 @@ public function delete($table, array $options = []) { * A new Truncate query object. * * @see \Drupal\Core\Database\Query\Truncate - * - * @todo in drupal:11.0.0, return a new Query\Truncate instance directly. */ public function truncate($table, array $options = []) { - $class = $this->getDriverClass('Truncate'); - return new $class($this, $table, $options); + return new Truncate($this, $table, $options); } /** @@ -1241,17 +995,8 @@ public function truncate($table, array $options = []) { * * @return \Drupal\Core\Database\Schema * The database Schema object for this connection. - * - * @todo in drupal:11.0.0, make this method abstract since Schema is - * an abstract class. */ - public function schema() { - if (empty($this->schema)) { - $class = $this->getDriverClass('Schema'); - $this->schema = new $class($this); - } - return $this->schema; - } + abstract public function schema(); /** * Prepares and returns a CONDITION query object. @@ -1263,15 +1008,12 @@ public function schema() { * A new Condition query object. * * @see \Drupal\Core\Database\Query\Condition - * - * @todo in drupal:11.0.0, return a new Condition instance directly. */ public function condition($conjunction) { - $class = $this->getDriverClass('Condition'); // Creating an instance of the class Drupal\Core\Database\Query\Condition // should only be created from the database layer. This will allow database // drivers to override the default Condition class. - return new $class($conjunction); + return new Condition($conjunction); } /** @@ -1395,17 +1137,15 @@ public function escapeLike($string) { /** * Returns the transaction manager. * - * @return \Drupal\Core\Database\Transaction\TransactionManagerInterface|false + * @return \Drupal\Core\Database\Transaction\TransactionManagerInterface * The transaction manager, or FALSE if not available. + * + * @throws \LogicException + * If the transaction manager is undefined or unavailable. */ - public function transactionManager(): TransactionManagerInterface|FALSE { + public function transactionManager(): TransactionManagerInterface { if (!isset($this->transactionManager)) { - try { - $this->transactionManager = $this->driverTransactionManager(); - } - catch (\LogicException $e) { - $this->transactionManager = FALSE; - } + $this->transactionManager = $this->driverTransactionManager(); } return $this->transactionManager; } @@ -1434,32 +1174,7 @@ protected function driverTransactionManager(): TransactionManagerInterface { * TRUE if we're currently in a transaction, FALSE otherwise. */ public function inTransaction() { - if ($this->transactionManager()) { - return $this->transactionManager()->inTransaction(); - } - // Start of BC layer. - // @phpstan-ignore-next-line - return ($this->transactionDepth() > 0); - // End of BC layer. - } - - /** - * Determines the current transaction depth. - * - * @return int - * The current transaction depth. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not - * access the transaction stack depth, it is an implementation detail. - * - * @see https://www.drupal.org/node/3381002 - */ - public function transactionDepth() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not access the transaction stack depth, it is an implementation detail. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - if ($this->transactionManager()) { - return $this->transactionManager()->stackDepth(); - } - return count($this->transactionLayers); + return $this->transactionManager()->inTransaction(); } /** @@ -1472,248 +1187,9 @@ public function transactionDepth() { * A Transaction object. * * @see \Drupal\Core\Database\Transaction - * - * @todo in drupal:11.0.0, push to the TransactionManager directly. */ public function startTransaction($name = '') { - if ($this->transactionManager()) { - return $this->transactionManager()->push($name); - } - $class = $this->getDriverClass('Transaction'); - return new $class($this, $name); - } - - /** - * Rolls back the transaction entirely or to a named savepoint. - * - * This method throws an exception if no transaction is active. - * - * @param string $savepoint_name - * (optional) The name of the savepoint. The default, 'drupal_transaction', - * will roll the entire transaction back. - * - * @throws \Drupal\Core\Database\TransactionOutOfOrderException - * @throws \Drupal\Core\Database\TransactionNoActiveException - * - * @see \Drupal\Core\Database\Transaction::rollBack() - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not - * rollback the connection, roll back the Transaction objects instead. - * - * @see https://www.drupal.org/node/3381002 - */ - public function rollBack($savepoint_name = 'drupal_transaction') { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not rollback the connection, roll back the Transaction objects instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - if ($this->transactionManager()) { - $this->transactionManager()->rollback($savepoint_name, 'bc-force-rollback'); - return; - } - if (!$this->inTransaction()) { - throw new TransactionNoActiveException(); - } - // A previous rollback to an earlier savepoint may mean that the savepoint - // in question has already been accidentally committed. - if (!isset($this->transactionLayers[$savepoint_name])) { - throw new TransactionNoActiveException(); - } - - // We need to find the point we're rolling back to, all other savepoints - // before are no longer needed. If we rolled back other active savepoints, - // we need to throw an exception. - $rolled_back_other_active_savepoints = FALSE; - while ($savepoint = array_pop($this->transactionLayers)) { - if ($savepoint == $savepoint_name) { - // If it is the last the transaction in the stack, then it is not a - // savepoint, it is the transaction itself so we will need to roll back - // the transaction rather than a savepoint. - if (empty($this->transactionLayers)) { - break; - } - $this->query('ROLLBACK TO SAVEPOINT ' . $savepoint); - $this->popCommittableTransactions(); - if ($rolled_back_other_active_savepoints) { - throw new TransactionOutOfOrderException(); - } - return; - } - else { - $rolled_back_other_active_savepoints = TRUE; - } - } - - // Notify the callbacks about the rollback. - $callbacks = $this->rootTransactionEndCallbacks; - $this->rootTransactionEndCallbacks = []; - foreach ($callbacks as $callback) { - call_user_func($callback, FALSE); - } - - $this->connection->rollBack(); - if ($rolled_back_other_active_savepoints) { - throw new TransactionOutOfOrderException(); - } - } - - /** - * Increases the depth of transaction nesting. - * - * If no transaction is already active, we begin a new transaction. - * - * @param string $name - * The name of the transaction. - * - * @throws \Drupal\Core\Database\TransactionNameNonUniqueException - * - * @see \Drupal\Core\Database\Transaction - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * TransactionManagerInterface methods instead. - * - * @see https://www.drupal.org/node/3381002 - */ - public function pushTransaction($name) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - if (isset($this->transactionLayers[$name])) { - throw new TransactionNameNonUniqueException($name . " is already in use."); - } - // If we're already in a transaction then we want to create a savepoint - // rather than try to create another transaction. - if ($this->inTransaction()) { - $this->query('SAVEPOINT ' . $name); - } - else { - $this->connection->beginTransaction(); - } - $this->transactionLayers[$name] = $name; - } - - /** - * Decreases the depth of transaction nesting. - * - * If we pop off the last transaction layer, then we either commit or roll - * back the transaction as necessary. If no transaction is active, we return - * because the transaction may have manually been rolled back. - * - * @param string $name - * The name of the savepoint. - * - * @throws \Drupal\Core\Database\TransactionNoActiveException - * @throws \Drupal\Core\Database\TransactionCommitFailedException - * - * @see \Drupal\Core\Database\Transaction - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * TransactionManagerInterface methods instead. - * - * @see https://www.drupal.org/node/3381002 - */ - public function popTransaction($name) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - // The transaction has already been committed earlier. There is nothing we - // need to do. If this transaction was part of an earlier out-of-order - // rollback, an exception would already have been thrown by - // Database::rollBack(). - if (!isset($this->transactionLayers[$name])) { - return; - } - - // Mark this layer as committable. - $this->transactionLayers[$name] = FALSE; - $this->popCommittableTransactions(); - } - - /** - * Adds a root transaction end callback. - * - * These callbacks are invoked immediately after the transaction has been - * committed. - * - * It can for example be used to avoid deadlocks on write-heavy tables that - * do not need to be part of the transaction, like cache tag invalidations. - * - * Another use case is that services using alternative backends like Redis and - * Memcache cache implementations can replicate the transaction-behavior of - * the database cache backend and avoid race conditions. - * - * An argument is passed to the callbacks that indicates whether the - * transaction was successful or not. - * - * @param callable $callback - * The callback to invoke. - * - * @see \Drupal\Core\Database\Connection::doCommit() - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * TransactionManagerInterface::addPostTransactionCallback() instead. - * - * @see https://www.drupal.org/node/3381002 - */ - public function addRootTransactionEndCallback(callable $callback) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface::addPostTransactionCallback() instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - if ($this->transactionManager()) { - $this->transactionManager()->addPostTransactionCallback($callback); - return; - } - if (!$this->transactionLayers) { - throw new \LogicException('Root transaction end callbacks can only be added when there is an active transaction.'); - } - $this->rootTransactionEndCallbacks[] = $callback; - } - - /** - * Commit all the transaction layers that can commit. - * - * @internal - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * TransactionManagerInterface methods instead. - * - * @see https://www.drupal.org/node/3381002 - */ - protected function popCommittableTransactions() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - // Commit all the committable layers. - foreach (array_reverse($this->transactionLayers) as $name => $active) { - // Stop once we found an active transaction. - if ($active) { - break; - } - - // If there are no more layers left then we should commit. - unset($this->transactionLayers[$name]); - if (empty($this->transactionLayers)) { - $this->doCommit(); - } - else { - $this->query('RELEASE SAVEPOINT ' . $name); - } - } - } - - /** - * Do the actual commit, invoke post-commit callbacks. - * - * @internal - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * TransactionManagerInterface methods instead. - * - * @see https://www.drupal.org/node/3381002 - */ - protected function doCommit() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - $success = $this->connection->commit(); - if (!empty($this->rootTransactionEndCallbacks)) { - $callbacks = $this->rootTransactionEndCallbacks; - $this->rootTransactionEndCallbacks = []; - foreach ($callbacks as $callback) { - call_user_func($callback, $success); - } - } - - if (!$success) { - throw new TransactionCommitFailedException(); - } + return $this->transactionManager()->push($name); } /** @@ -1828,52 +1304,6 @@ abstract public function createDatabase($database); */ abstract public function mapConditionOperator($operator); - /** - * Throws an exception to deny direct access to transaction commits. - * - * We do not want to allow users to commit transactions at any time, only - * by destroying the transaction object or allowing it to go out of scope. - * A direct commit bypasses all of the safety checks we've built on top of - * the database client's transaction routines. - * - * @throws \Drupal\Core\Database\TransactionExplicitCommitNotAllowedException - * - * @see \Drupal\Core\Database\Transaction - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not - * commit the connection, void the Transaction objects instead. - * - * @see https://www.drupal.org/node/3381002 - */ - public function commit() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not commit the connection, void the Transaction objects instead. See https://www.drupal.org/node/3381002', E_USER_DEPRECATED); - throw new TransactionExplicitCommitNotAllowedException(); - } - - /** - * Retrieves a unique ID from a given sequence. - * - * Use this function if for some reason you can't use a serial field. For - * example, MySQL has no ways of reading of the current value of a sequence - * and PostgreSQL can not advance the sequence to be larger than a given - * value. Or sometimes you just need a unique integer. - * - * @param $existing_id - * (optional) After a database import, it might be that the sequences table - * is behind, so by passing in the maximum existing ID, it can be assured - * that we never issue the same ID. - * - * @return int|string - * An integer number larger than any number returned by earlier calls and - * also larger than the $existing_id if one was passed in. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules - * should use instead the keyvalue storage for the last used id. - * - * @see https://www.drupal.org/node/3349345 - */ - abstract public function nextId($existing_id = 0); - /** * Quotes a string for use in a query. * diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php index ee5d6597ecb959921efee2c6df74653fb1ca6ca3..354857616ad933cbcc681db519e068d10892ede2 100644 --- a/core/lib/Drupal/Core/Database/Database.php +++ b/core/lib/Drupal/Core/Database/Database.php @@ -16,49 +16,6 @@ */ abstract class Database { - /** - * Flag to indicate a query call should simply return NULL. - * - * This is used for queries that have no reasonable return value anyway, such - * as INSERT statements to a table without a serial primary key. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3185520 - */ - const RETURN_NULL = 0; - - /** - * Flag to indicate a query call should return the prepared statement. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3185520 - */ - const RETURN_STATEMENT = 1; - - /** - * Flag to indicate a query call should return the number of matched rows. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3185520 - */ - const RETURN_AFFECTED = 2; - - /** - * Flag to indicate a query call should return the "last insert id". - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. There is no - * replacement. - * - * @see https://www.drupal.org/node/3185520 - */ - const RETURN_INSERT_ID = 3; - /** * A nested array of active connections, keyed by database name and target. * @@ -621,75 +578,6 @@ public static function getDriverList(): DatabaseDriverList { } } - /** - * Finds the directory to add to the autoloader for the driver's namespace. - * - * For Drupal sites that manage their codebase with Composer, the package - * that provides the database driver should add the driver's namespace to - * Composer's autoloader. However, to support sites that add Drupal modules - * without Composer, and because the database connection must be established - * before Drupal adds the module's entire namespace to the autoloader, the - * database connection info array can include an "autoload" key containing - * the autoload directory for the driver's namespace. For requests that - * connect to the database via a connection info array, the value of the - * "autoload" key is automatically added to the autoloader. - * - * This method can be called to find the default value of that key when the - * database connection info array isn't available. This includes: - * - Console commands and test runners that connect to a database specified - * by a database URL rather than a connection info array. - * - During installation, prior to the connection info array being written to - * settings.php. - * - * This method returns the directory that must be added to the autoloader for - * the given namespace. - * - If the namespace is a sub-namespace of a Drupal module, then this method - * returns the autoload directory for that namespace, allowing Drupal - * modules containing database drivers to be added to a Drupal website - * without Composer. - * - If the namespace is a sub-namespace of Drupal\Core or Drupal\Driver, - * then this method returns FALSE, because Drupal core's autoloader already - * includes these namespaces, so no additional autoload directory is - * required for any code within them. - * - If the namespace is anything else, then this method returns FALSE, - * because neither drupal_get_database_types() nor - * static::convertDbUrlToConnectionInfo() support that anyway. One can - * manually edit the connection info array in settings.php to reference - * any arbitrary namespace, but requests using that would use the - * corresponding 'autoload' key in that connection info rather than calling - * this method. - * - * @param string $namespace - * The database driver's namespace. - * @param string $root - * The root directory of the Drupal installation. - * @param bool|null $include_test_drivers - * (optional) Whether to include test extensions. If FALSE, all 'tests' - * directories are excluded in the search. When NULL will be determined by - * the extension_discovery_scan_tests setting. - * - * @return string|false - * The PSR-4 directory to add to the autoloader for the namespace if the - * namespace is a sub-namespace of a Drupal module. FALSE otherwise, as - * explained above. - * - * @throws \RuntimeException - * Exception thrown when a module provided database driver does not exist. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * DatabaseDriverList::getList() instead. - * - * @see https://www.drupal.org/node/3258175 - */ - public static function findDriverAutoloadDirectory($namespace, $root, ?bool $include_test_drivers = NULL) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175', E_USER_DEPRECATED); - $autoload_info = static::getDriverList() - ->includeTestDrivers($include_test_drivers) - ->get($namespace) - ->getAutoloadInfo(); - return $autoload_info['autoload'] ?? FALSE; - } - /** * Gets database connection info as a URL. * @@ -708,46 +596,14 @@ public static function getConnectionInfoAsUrl($key = 'default') { throw new \RuntimeException("Database connection $key not defined or missing the 'default' settings"); } $namespace = $db_info['default']['namespace']; - - // If the driver namespace is within a Drupal module, add the module name - // to the connection options to make it easy for the connection class's - // createUrlFromConnectionOptions() method to add it to the URL. - if (static::isWithinModuleNamespace($namespace)) { - $db_info['default']['module'] = explode('\\', $namespace)[1]; - } - + // Add the module name to the connection options to make it easy for the + // connection class's createUrlFromConnectionOptions() method to add it to + // the URL. + $db_info['default']['module'] = explode('\\', $namespace)[1]; $connection_class = $namespace . '\\Connection'; return $connection_class::createUrlFromConnectionOptions($db_info['default']); } - /** - * Checks whether a namespace is within the namespace of a Drupal module. - * - * This can be used to determine if a database driver's namespace is provided - * by a Drupal module. - * - * @param string $namespace - * The namespace (for example, of a database driver) to check. - * - * @return bool - * TRUE if the passed in namespace is a sub-namespace of a Drupal module's - * namespace. - * - * @todo remove in Drupal 11. - * - * @see https://www.drupal.org/node/3256524 - */ - private static function isWithinModuleNamespace(string $namespace) { - [$first, $second] = explode('\\', $namespace, 3); - - // The namespace for Drupal modules is Drupal\MODULE_NAME, and the module - // name must be all lowercase. Second-level namespaces containing uppercase - // letters (e.g., "Core", "Component", "Driver") are not modules. - // @see \Drupal\Core\DrupalKernel::getModuleNamespacesPsr4() - // @see https://www.drupal.org/docs/8/creating-custom-modules/naming-and-placing-your-drupal-8-module#s-name-your-module - return ($first === 'Drupal' && strtolower($second) === $second); - } - /** * Calls commitAll() on all the open connections. * diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php b/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php deleted file mode 100644 index 8ae316c821a7b41a6f4fe64fc3026665ac264b07..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Connection.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql; - -use Drupal\mysql\Driver\Database\mysql\Connection as MysqlConnection; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * MySQL implementation of \Drupal\Core\Database\Connection. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Connection extends MysqlConnection {} diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php b/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php deleted file mode 100644 index 95c7be731f414a7a4bafcc594809f809450fca66..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/ExceptionHandler.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql; - -use Drupal\mysql\Driver\Database\mysql\ExceptionHandler as MysqlExceptionHandler; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\ExceptionHandler is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * MySql database exception handler class. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class ExceptionHandler extends MysqlExceptionHandler {} diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php b/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php deleted file mode 100644 index 6fca6386e138902bf0c2b595b0d62f9173e7aea7..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Insert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql; - -use Drupal\mysql\Driver\Database\mysql\Insert as MysqlInsert; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * MySQL implementation of \Drupal\Core\Database\Query\Insert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Insert extends MysqlInsert {} diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php deleted file mode 100644 index 2cb93a9b4f6a69506c26aab984bf0ab019930498..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Install/Tasks.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql\Install; - -use Drupal\mysql\Driver\Database\mysql\Install\Tasks as MysqlTasks; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * Specifies installation tasks for MySQL and equivalent databases. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Tasks extends MysqlTasks {} diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php b/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php deleted file mode 100644 index ef9a0f12926f1464702c68470286b2dc4a0369a4..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Schema.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql; - -use Drupal\mysql\Driver\Database\mysql\Schema as MysqlSchema; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * MySQL implementation of \Drupal\Core\Database\Schema. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Schema extends MysqlSchema {} diff --git a/core/lib/Drupal/Core/Database/Driver/mysql/Upsert.php b/core/lib/Drupal/Core/Database/Driver/mysql/Upsert.php deleted file mode 100644 index e8b21ac7bf32892c4a726d3d0a9df4b33b6df18f..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/mysql/Upsert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\mysql; - -use Drupal\mysql\Driver\Database\mysql\Upsert as MysqlUpsert; - -@trigger_error('\Drupal\Core\Database\Driver\mysql\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * MySQL implementation of \Drupal\Core\Database\Query\Upsert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL - * database driver has been moved to the mysql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Upsert extends MysqlUpsert {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php deleted file mode 100644 index b015bda694167924eb5cd7f060a69303dbc22042..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Connection.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Connection as PgsqlConnection; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Connection. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Connection extends PgsqlConnection {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Delete.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Delete.php deleted file mode 100644 index 0c3333003575cd42bdf58522322a22c4a20b5682..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Delete.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Delete as PgsqlDelete; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Delete is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Delete. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Delete extends PgsqlDelete {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php deleted file mode 100644 index 0702d38a6d58ccf9da221062c8acbb51e416c2ab..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Insert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Insert as PgsqlInsert; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Insert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Insert extends PgsqlInsert {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php deleted file mode 100644 index c7104cc0c1313d01c11a7f7389030453e8aff8b2..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Install/Tasks.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql\Install; - -use Drupal\pgsql\Driver\Database\pgsql\Install\Tasks as PgsqlTasks; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * Specifies installation tasks for PostgreSQL databases. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Tasks extends PgsqlTasks {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php deleted file mode 100644 index 2dbe382ec58b7d21a815f80fa82c7e892e7f01e1..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Schema.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Schema as PgsqlSchema; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Schema. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Schema extends PgsqlSchema {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php deleted file mode 100644 index 169aaed84410979e3637860cd10b39ce9eb237cc..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Select.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Select as PgsqlSelect; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Select is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Select. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Select extends PgsqlSelect {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Truncate.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Truncate.php deleted file mode 100644 index 01ed66c3445551eb85ff0b39d356b79ab972dc5d..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Truncate.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Truncate as PgsqlTruncate; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Truncate is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Truncate. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Truncate extends PgsqlTruncate {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php deleted file mode 100644 index 0e31b0dd2001fdf1b27c1244912aee0bce1dc901..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Update.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Update as PgsqlUpdate; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Update is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Update. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Update extends PgsqlUpdate {} diff --git a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php b/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php deleted file mode 100644 index e1eb3d95c54d73da917c9fc20fc387c504e1f749..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/pgsql/Upsert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\pgsql; - -use Drupal\pgsql\Driver\Database\pgsql\Upsert as PgsqlUpsert; - -@trigger_error('\Drupal\Core\Database\Driver\pgsql\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * PostgreSQL implementation of \Drupal\Core\Database\Query\Upsert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL - * database driver has been moved to the pgsql module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Upsert extends PgsqlUpsert {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php deleted file mode 100644 index c4b130d1f0458145b09f622b8247320447788bcd..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Connection.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Connection as SqliteConnection; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Connection. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Connection extends SqliteConnection {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php deleted file mode 100644 index 1685c8ba02bb4be4f47eabe1d3ba872c976e1e3b..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Insert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Insert as SqliteInsert; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Query\Insert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Insert extends SqliteInsert {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php deleted file mode 100644 index 22929b619430724e887ae715151e93672157dd7a..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Install/Tasks.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite\Install; - -use Drupal\sqlite\Driver\Database\sqlite\Install\Tasks as SqliteTasks; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * Specifies installation tasks for SQLite databases. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Tasks extends SqliteTasks {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php deleted file mode 100644 index b880d2c45bdfb5e849b5be60e88b00519196a2d8..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Schema.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Schema as SqliteSchema; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Schema. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Schema extends SqliteSchema {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Select.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Select.php deleted file mode 100644 index 8cfe31cf3f23eb96b414a7b6b86eff31f7f9508d..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Select.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Select as SqliteSelect; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Select is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Query\Select. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Select extends SqliteSelect {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php deleted file mode 100644 index c189fe84943eea6119b2b48f405969f2789f6690..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Statement.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Statement as SqliteStatement; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Statement is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Statement. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Statement extends SqliteStatement {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Truncate.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Truncate.php deleted file mode 100644 index d9f83cac5b1f6229cfc1e60d763b259d600285e6..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Truncate.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Truncate as SqliteTruncate; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Truncate is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Query\Truncate. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Truncate extends SqliteTruncate {} diff --git a/core/lib/Drupal/Core/Database/Driver/sqlite/Upsert.php b/core/lib/Drupal/Core/Database/Driver/sqlite/Upsert.php deleted file mode 100644 index 9a6ad99d29081c3d8912c7a7234cdcfbeee9b303..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/Driver/sqlite/Upsert.php +++ /dev/null @@ -1,17 +0,0 @@ -<?php - -namespace Drupal\Core\Database\Driver\sqlite; - -use Drupal\sqlite\Driver\Database\sqlite\Upsert as SqliteUpsert; - -@trigger_error('\Drupal\Core\Database\Driver\sqlite\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492', E_USER_DEPRECATED); - -/** - * SQLite implementation of \Drupal\Core\Database\Query\Upsert. - * - * @deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite - * database driver has been moved to the sqlite module. - * - * @see https://www.drupal.org/node/3129492 - */ -class Upsert extends SqliteUpsert {} diff --git a/core/lib/Drupal/Core/Database/FetchModeTrait.php b/core/lib/Drupal/Core/Database/FetchModeTrait.php index b9e0018d519b3d68b42a6c9f8fd2c2d71830a38f..8b9b129bf2db333c1b9e6ace4aa77f1498d6f3ff 100644 --- a/core/lib/Drupal/Core/Database/FetchModeTrait.php +++ b/core/lib/Drupal/Core/Database/FetchModeTrait.php @@ -42,27 +42,6 @@ trait FetchModeTrait { \PDO::FETCH_OBJ, ]; - /** - * Converts a row of data in FETCH_ASSOC format to FETCH_BOTH. - * - * @param array $rowAssoc - * A row of data in FETCH_ASSOC format. - * - * @return array - * The row in FETCH_BOTH format. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * supported modes only. - * - * @see https://www.drupal.org/node/3377999 - */ - protected function assocToBoth(array $rowAssoc): array { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - // \PDO::FETCH_BOTH returns an array indexed by both the column name - // and the column number. - return $rowAssoc + array_values($rowAssoc); - } - /** * Converts a row of data in FETCH_ASSOC format to FETCH_NUM. * @@ -110,52 +89,6 @@ protected function assocToClass(array $rowAssoc, string $className, array $const return $classObj; } - /** - * Converts a row of data to FETCH_CLASS | FETCH_CLASSTYPE. - * - * @param array $rowAssoc - * A row of data in FETCH_ASSOC format. - * @param array $constructorArguments - * Elements of this array are passed to the constructor. - * - * @return object - * The row in FETCH_CLASS format. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * supported modes only. - * - * @see https://www.drupal.org/node/3377999 - */ - protected function assocToClassType(array $rowAssoc, array $constructorArguments): object { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - $className = array_shift($rowAssoc); - return $this->assocToClass($rowAssoc, $className, $constructorArguments); - } - - /** - * Fills an object with data from a FETCH_ASSOC row. - * - * @param array $rowAssoc - * A row of data in FETCH_ASSOC format. - * @param object $object - * The object receiving the data. - * - * @return object - * The object receiving the data. - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use - * supported modes only. - * - * @see https://www.drupal.org/node/3377999 - */ - protected function assocIntoObject(array $rowAssoc, object $object): object { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - foreach ($rowAssoc as $column => $value) { - $object->$column = $value; - } - return $object; - } - /** * Converts a row of data in FETCH_ASSOC format to FETCH_COLUMN. * diff --git a/core/lib/Drupal/Core/Database/Log.php b/core/lib/Drupal/Core/Database/Log.php index 876be39f8b985d66ebbc26030142cffe23ed942f..193a5e78e57045f8575a7b5e7941c17f1b02fe3d 100644 --- a/core/lib/Drupal/Core/Database/Log.php +++ b/core/lib/Drupal/Core/Database/Log.php @@ -121,124 +121,4 @@ public function logFromEvent(StatementExecutionEndEvent $event): void { } } - /** - * Log a query to all active logging keys. - * - * @param \Drupal\Core\Database\StatementInterface $statement - * The prepared statement object to log. - * @param array $args - * The arguments passed to the statement object. - * @param float $time - * The time the query took to execute as a float (in seconds with - * microsecond precision). - * @param float $start - * The time the query started as a float (in seconds since the Unix epoch - * with microsecond precision). - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * ::logFromEvent(). - * - * @see https://www.drupal.org/node/3328053 - */ - public function log(StatementInterface $statement, $args, $time, float $start = NULL) { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use ::logFromEvent(). See https://www.drupal.org/node/3328053', E_USER_DEPRECATED); - foreach (array_keys($this->queryLog) as $key) { - $this->queryLog[$key][] = [ - 'query' => $statement->getQueryString(), - 'args' => $args, - 'target' => $statement->getConnectionTarget(), - 'caller' => $this->findCaller(), - 'time' => $time, - 'start' => $start, - ]; - } - } - - /** - * Determine the routine that called this query. - * - * Traversing the call stack from the very first call made during the - * request, we define "the routine that called this query" as the last entry - * in the call stack that is not any method called from the namespace of the - * database driver, is not inside the Drupal\Core\Database namespace and does - * have a file (which excludes call_user_func_array(), anonymous functions - * and similar). That makes the climbing logic very simple, and handles the - * variable stack depth caused by the query builders. - * - * See the @link http://php.net/debug_backtrace debug_backtrace() @endlink - * function. - * - * @return array|null - * This method returns a stack trace entry similar to that generated by - * debug_backtrace(). However, it flattens the trace entry and the trace - * entry before it so that we get the function and args of the function that - * called into the database system, not the function and args of the - * database call itself. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * Connection::findCallerFromDebugBacktrace(). - * - * @see https://www.drupal.org/node/3328053 - */ - public function findCaller() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::findCallerFromDebugBacktrace(). See https://www.drupal.org/node/3328053', E_USER_DEPRECATED); - $driver_namespace = Database::getConnectionInfo($this->connectionKey)['default']['namespace']; - $stack = static::removeDatabaseEntries($this->getDebugBacktrace(), $driver_namespace); - - // Return the first function call whose stack entry has a 'file' key, that - // is, it is not a callback or a closure. - for ($i = 0; $i < count($stack); $i++) { - if (!empty($stack[$i]['file'])) { - return [ - 'file' => $stack[$i]['file'], - 'line' => $stack[$i]['line'], - 'function' => $stack[$i + 1]['function'], - 'class' => $stack[$i + 1]['class'] ?? NULL, - 'type' => $stack[$i + 1]['type'] ?? NULL, - 'args' => $stack[$i + 1]['args'] ?? [], - ]; - } - } - } - - /** - * Removes database related calls from a backtrace array. - * - * @param array $backtrace - * A standard PHP backtrace. Passed by reference. - * @param string $driver_namespace - * The PHP namespace of the database driver. - * - * @return array - * The cleaned backtrace array. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * Connection::removeDatabaseEntriesFromDebugBacktrace(). - * - * @see https://www.drupal.org/node/3328053 - */ - public static function removeDatabaseEntries(array $backtrace, string $driver_namespace): array { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::removeDatabaseEntriesFromDebugBacktrace(). See https://www.drupal.org/node/3328053', E_USER_DEPRECATED); - return Connection::removeDatabaseEntriesFromDebugBacktrace($backtrace, $driver_namespace); - } - - /** - * Gets the debug backtrace. - * - * Wraps the debug_backtrace function to allow mocking results in PHPUnit - * tests. - * - * @return array[] - * The debug backtrace. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3328053 - */ - protected function getDebugBacktrace() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3328053', E_USER_DEPRECATED); - return debug_backtrace(); - } - } diff --git a/core/lib/Drupal/Core/Database/Query/Condition.php b/core/lib/Drupal/Core/Database/Query/Condition.php index f0f71aed610e8de06f1b337ce036864ab9efce5f..fcd0b5dfba3032d9b83486e78588582588a10fd7 100644 --- a/core/lib/Drupal/Core/Database/Query/Condition.php +++ b/core/lib/Drupal/Core/Database/Query/Condition.php @@ -111,8 +111,7 @@ public function condition($field, $value = NULL, $operator = '=') { throw new InvalidQueryException(sprintf("Query condition '%s %s %s' must have an array compatible operator.", $field, $operator, $value)); } else { - $value = $value[0]; - @trigger_error('Calling ' . __METHOD__ . '() without an array compatible operator is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3350985', E_USER_DEPRECATED); + throw new InvalidQueryException('Calling ' . __METHOD__ . '() without an array compatible operator is not supported. See https://www.drupal.org/node/3350985'); } } diff --git a/core/lib/Drupal/Core/Database/Query/Delete.php b/core/lib/Drupal/Core/Database/Query/Delete.php index 864d0648dd2295f7548c41516c75190e62ac1def..946f91240e1f4b3a2cdf099214dc9ce0cce3c3fc 100644 --- a/core/lib/Drupal/Core/Database/Query/Delete.php +++ b/core/lib/Drupal/Core/Database/Query/Delete.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; /** @@ -32,9 +31,6 @@ class Delete extends Query implements ConditionInterface { * Array of database options. */ public function __construct(Connection $connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; diff --git a/core/lib/Drupal/Core/Database/Query/Insert.php b/core/lib/Drupal/Core/Database/Query/Insert.php index 58bd8d181190a0040f081d553cd966fac314b2bb..3bae7ab74bd2dbebfcbc44df66fbd2130e31782f 100644 --- a/core/lib/Drupal/Core/Database/Query/Insert.php +++ b/core/lib/Drupal/Core/Database/Query/Insert.php @@ -2,8 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; - /** * General class for an abstracted INSERT query. * @@ -31,11 +29,6 @@ class Insert extends Query implements \Countable { * Array of database options. */ public function __construct($connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - if (!isset($options['return'])) { - $options['return'] = Database::RETURN_INSERT_ID; - } parent::__construct($connection, $options); $this->table = $table; } diff --git a/core/lib/Drupal/Core/Database/Query/Merge.php b/core/lib/Drupal/Core/Database/Query/Merge.php index 6d1b96e7c427f9276d2a934181bfffca79802486..2e7a00cb7f9d1e3b9dce9b313a08449f5b94d7bf 100644 --- a/core/lib/Drupal/Core/Database/Query/Merge.php +++ b/core/lib/Drupal/Core/Database/Query/Merge.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; use Drupal\Core\Database\IntegrityConstraintViolationException; @@ -134,9 +133,6 @@ class Merge extends Query implements ConditionInterface { * Array of database options. */ public function __construct(Connection $connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; $this->conditionTable = $table; @@ -331,14 +327,8 @@ public function keys(array $fields, array $values = []) { * @see \Drupal\Core\Database\Query\Merge::keys() */ public function key($field, $value = NULL) { - // @todo D9: Remove this backwards-compatibility shim. - if (is_array($field)) { - @trigger_error("Passing an array to the \$field argument of " . __METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/2205327', E_USER_DEPRECATED); - $this->keys($field, $value ?? []); - } - else { - $this->keys([$field => $value]); - } + assert(is_string($field)); + $this->keys([$field => $value]); return $this; } diff --git a/core/lib/Drupal/Core/Database/Query/Select.php b/core/lib/Drupal/Core/Database/Query/Select.php index 157696d1c28fd322b5893b10e9eef37b7f77095a..cccdc6ad5e967412bbeefc109877140bbcc9c10c 100644 --- a/core/lib/Drupal/Core/Database/Query/Select.php +++ b/core/lib/Drupal/Core/Database/Query/Select.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; /** @@ -142,9 +141,6 @@ class Select extends Query implements SelectInterface { * Array of query options. */ public function __construct(Connection $connection, $table, $alias = NULL, $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_STATEMENT; parent::__construct($connection, $options); $conjunction = $options['conjunction'] ?? 'AND'; $this->condition = $this->connection->condition($conjunction); diff --git a/core/lib/Drupal/Core/Database/Query/Truncate.php b/core/lib/Drupal/Core/Database/Query/Truncate.php index 01f0c9d47daa63868c9e25b8e4e08fe93a904a80..45f1c8447ac303f3a2df34135f1ad63d134622fd 100644 --- a/core/lib/Drupal/Core/Database/Query/Truncate.php +++ b/core/lib/Drupal/Core/Database/Query/Truncate.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; /** @@ -28,9 +27,6 @@ class Truncate extends Query { * Array of database options. */ public function __construct(Connection $connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; } diff --git a/core/lib/Drupal/Core/Database/Query/Update.php b/core/lib/Drupal/Core/Database/Query/Update.php index fb7db437af8a2f09c99e9dd195c74f204c7e3ada..f1ac9ceba35593d231718b8bd1da32dfa4c128fb 100644 --- a/core/lib/Drupal/Core/Database/Query/Update.php +++ b/core/lib/Drupal/Core/Database/Query/Update.php @@ -2,7 +2,6 @@ namespace Drupal\Core\Database\Query; -use Drupal\Core\Database\Database; use Drupal\Core\Database\Connection; /** @@ -61,9 +60,6 @@ class Update extends Query implements ConditionInterface { * Array of database options. */ public function __construct(Connection $connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; diff --git a/core/lib/Drupal/Core/Database/Query/Upsert.php b/core/lib/Drupal/Core/Database/Query/Upsert.php index 00c26cddbb60d3bc7bac29a4d92b64ba626c8312..2b845fcccc43e76ec6d566281befda3210e94ccc 100644 --- a/core/lib/Drupal/Core/Database/Query/Upsert.php +++ b/core/lib/Drupal/Core/Database/Query/Upsert.php @@ -3,7 +3,6 @@ namespace Drupal\Core\Database\Query; use Drupal\Core\Database\Connection; -use Drupal\Core\Database\Database; /** * General class for an abstracted "Upsert" (UPDATE or INSERT) query operation. @@ -35,9 +34,6 @@ abstract class Upsert extends Query implements \Countable { * (optional) An array of database options. */ public function __construct(Connection $connection, $table, array $options = []) { - // @todo Remove $options['return'] in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options['return'] = Database::RETURN_AFFECTED; parent::__construct($connection, $options); $this->table = $table; } diff --git a/core/lib/Drupal/Core/Database/StatementInterface.php b/core/lib/Drupal/Core/Database/StatementInterface.php index ad993fa0e25fe3995d08a45eb93383996050d5e1..c269c9819b55c079df9cba38d297f6ecd6f64787 100644 --- a/core/lib/Drupal/Core/Database/StatementInterface.php +++ b/core/lib/Drupal/Core/Database/StatementInterface.php @@ -117,21 +117,16 @@ public function fetchField($index = 0); * The object will be of the class specified by StatementInterface::setFetchMode() * or stdClass if not specified. * - * phpcs:disable Drupal.Commenting - * @todo Uncomment new method parameters before drupal:11.0.0. - * @see https://www.drupal.org/project/drupal/issues/3354672 - * * @param string|null $class_name * Name of the created class. * @param array $constructor_arguments * Elements of this array are passed to the constructor. - * phpcs:enable * * @return mixed * The object of specified class or \stdClass if not specified. Returns * FALSE or NULL if there is no next row. */ - public function fetchObject(/* string $class_name = NULL, array $constructor_arguments = [] */); + public function fetchObject(string $class_name = NULL, array $constructor_arguments = []); /** * Fetches the next row and returns it as an associative array. diff --git a/core/lib/Drupal/Core/Database/StatementIteratorTrait.php b/core/lib/Drupal/Core/Database/StatementIteratorTrait.php index c4071545caa1e3401675a63264d382dcb024abc9..bab319d03fda3c1ca7a4a2c6f420032b28ed06a8 100644 --- a/core/lib/Drupal/Core/Database/StatementIteratorTrait.php +++ b/core/lib/Drupal/Core/Database/StatementIteratorTrait.php @@ -105,10 +105,9 @@ public function key(): mixed { public function rewind(): void { // Nothing to do: our DatabaseStatement can't be rewound. Error out when // attempted. - // @todo convert the error to an exception in Drupal 11. if ($this->resultsetKey >= 0) { - trigger_error('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.', E_USER_WARNING); $this->markResultsetIterable(FALSE); + throw new DatabaseExceptionWrapper('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); } } diff --git a/core/lib/Drupal/Core/Database/StatementPrefetch.php b/core/lib/Drupal/Core/Database/StatementPrefetch.php deleted file mode 100644 index b717da2efb676de3235cdc312e56359343777f20..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/StatementPrefetch.php +++ /dev/null @@ -1,602 +0,0 @@ -<?php - -namespace Drupal\Core\Database; - -@trigger_error('\Drupal\Core\Database\StatementPrefetch is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Database\StatementPrefetchIterator instead. See https://www.drupal.org/node/3265938', E_USER_DEPRECATED); - -use Drupal\Core\Database\Event\StatementExecutionEndEvent; -use Drupal\Core\Database\Event\StatementExecutionStartEvent; - -/** - * An implementation of StatementInterface that pre-fetches all data. - * - * This class behaves very similar to a StatementWrapper of a \PDOStatement - * but as it always fetches every row it is possible to manipulate those - * results. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\Database\StatementPrefetchIterator instead. - * - * @see https://www.drupal.org/node/3265938 - */ -class StatementPrefetch implements \Iterator, StatementInterface { - - /** - * The query string. - * - * @var string - */ - protected $queryString; - - /** - * Driver-specific options. Can be used by child classes. - * - * @var array - */ - protected $driverOptions; - - /** - * The Drupal database connection object. - * - * @var \Drupal\Core\Database\Connection - */ - protected $connection; - - /** - * Reference to the PDO connection object for this statement. - * - * @var \PDO - */ - protected $pdoConnection; - - /** - * Main data store. - * - * @var array - */ - protected $data = []; - - /** - * The current row, retrieved in \PDO::FETCH_ASSOC format. - * - * @var array - */ - protected $currentRow = NULL; - - /** - * The key of the current row. - * - * @var int - */ - protected $currentKey = NULL; - - /** - * The list of column names in this result set. - * - * @var array - */ - protected $columnNames = NULL; - - /** - * The number of rows matched by the last query. - * - * @var int - */ - protected $rowCount = NULL; - - /** - * The number of rows in this result set. - * - * @var int - */ - protected $resultRowCount = 0; - - /** - * Holds the current fetch style (which will be used by the next fetch). - * @see \PDOStatement::fetch() - * - * @var int - */ - protected $fetchStyle = \PDO::FETCH_OBJ; - - /** - * Holds supplementary current fetch options (which will be used by the next fetch). - * - * @var array - */ - protected $fetchOptions = [ - 'class' => 'stdClass', - 'constructor_args' => [], - 'object' => NULL, - 'column' => 0, - ]; - - /** - * Holds the default fetch style. - * - * @var int - */ - protected $defaultFetchStyle = \PDO::FETCH_OBJ; - - /** - * Holds supplementary default fetch options. - * - * @var array - */ - protected $defaultFetchOptions = [ - 'class' => 'stdClass', - 'constructor_args' => [], - 'object' => NULL, - 'column' => 0, - ]; - - /** - * Is rowCount() execution allowed. - * - * @var bool - */ - protected $rowCountEnabled = FALSE; - - /** - * Constructs a StatementPrefetch object. - * - * @param \PDO $pdo_connection - * An object of the PDO class representing a database connection. - * @param \Drupal\Core\Database\Connection $connection - * The database connection. - * @param string $query - * The query string. - * @param array $driver_options - * Driver-specific options. - * @param bool $row_count_enabled - * (optional) Enables counting the rows matched. Defaults to FALSE. - */ - public function __construct(\PDO $pdo_connection, Connection $connection, $query, array $driver_options = [], bool $row_count_enabled = FALSE) { - $this->pdoConnection = $pdo_connection; - $this->connection = $connection; - $this->queryString = $query; - $this->driverOptions = $driver_options; - $this->rowCountEnabled = $row_count_enabled; - } - - /** - * {@inheritdoc} - */ - public function getConnectionTarget(): string { - return $this->connection->getTarget(); - } - - /** - * {@inheritdoc} - */ - public function execute($args = [], $options = []) { - if (isset($options['fetch'])) { - if (is_string($options['fetch'])) { - // Default to an object. Note: db fields will be added to the object - // before the constructor is run. If you need to assign fields after - // the constructor is run. See https://www.drupal.org/node/315092. - $this->setFetchMode(\PDO::FETCH_CLASS, $options['fetch']); - } - else { - $this->setFetchMode($options['fetch']); - } - } - - if ($this->connection->isEventEnabled(StatementExecutionStartEvent::class)) { - $startEvent = new StatementExecutionStartEvent( - spl_object_id($this), - $this->connection->getKey(), - $this->connection->getTarget(), - $this->getQueryString(), - $args ?? [], - $this->connection->findCallerFromDebugBacktrace() - ); - $this->connection->dispatchEvent($startEvent); - } - - // Prepare the query. - $statement = $this->getStatement($this->queryString, $args); - if (!$statement) { - $this->throwPDOException(); - } - - $return = $statement->execute($args); - if (!$return) { - $this->throwPDOException(); - } - - if ($this->rowCountEnabled) { - $this->rowCount = $statement->rowCount(); - } - // Fetch all the data from the reply, in order to release any lock - // as soon as possible. - $this->data = $statement->fetchAll(\PDO::FETCH_ASSOC); - // Destroy the statement as soon as possible. See the documentation of - // \Drupal\sqlite\Driver\Database\sqlite\Statement for an explanation. - unset($statement); - - $this->resultRowCount = count($this->data); - - if ($this->resultRowCount) { - $this->columnNames = array_keys($this->data[0]); - } - else { - $this->columnNames = []; - } - - if (isset($startEvent) && $this->connection->isEventEnabled(StatementExecutionEndEvent::class)) { - $this->connection->dispatchEvent(new StatementExecutionEndEvent( - $startEvent->statementObjectId, - $startEvent->key, - $startEvent->target, - $startEvent->queryString, - $startEvent->args, - $startEvent->caller, - $startEvent->time - )); - } - - // Initialize the first row in $this->currentRow. - $this->next(); - - return $return; - } - - /** - * Throw a PDO Exception based on the last PDO error. - */ - protected function throwPDOException() { - $error_info = $this->connection->errorInfo(); - // We rebuild a message formatted in the same way as PDO. - $exception = new \PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]); - $exception->errorInfo = $error_info; - throw $exception; - } - - /** - * Grab a PDOStatement object from a given query and its arguments. - * - * Some drivers (including SQLite) will need to perform some preparation - * themselves to get the statement right. - * - * @param $query - * The query. - * @param array|null $args - * An array of arguments. This can be NULL. - * - * @return \PDOStatement - * A PDOStatement object. - */ - protected function getStatement($query, &$args = []) { - return $this->connection->prepare($query, $this->driverOptions); - } - - /** - * {@inheritdoc} - */ - public function getQueryString() { - return $this->queryString; - } - - /** - * {@inheritdoc} - */ - public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - $this->defaultFetchStyle = $mode; - switch ($mode) { - case \PDO::FETCH_CLASS: - $this->defaultFetchOptions['class'] = $a1; - if ($a2) { - $this->defaultFetchOptions['constructor_args'] = $a2; - } - break; - - case \PDO::FETCH_COLUMN: - $this->defaultFetchOptions['column'] = $a1; - break; - - case \PDO::FETCH_INTO: - $this->defaultFetchOptions['object'] = $a1; - break; - } - - // Set the values for the next fetch. - $this->fetchStyle = $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - } - - /** - * Return the current row formatted according to the current fetch style. - * - * This is the core method of this class. It grabs the value at the current - * array position in $this->data and format it according to $this->fetchStyle - * and $this->fetchMode. - * - * @return mixed - * The current row formatted as requested. - */ - #[\ReturnTypeWillChange] - public function current() { - if (isset($this->currentRow)) { - switch ($this->fetchStyle) { - case \PDO::FETCH_ASSOC: - return $this->currentRow; - - case \PDO::FETCH_BOTH: - // \PDO::FETCH_BOTH returns an array indexed by both the column name - // and the column number. - return $this->currentRow + array_values($this->currentRow); - - case \PDO::FETCH_NUM: - return array_values($this->currentRow); - - case \PDO::FETCH_LAZY: - // We do not do lazy as everything is fetched already. Fallback to - // \PDO::FETCH_OBJ. - case \PDO::FETCH_OBJ: - return (object) $this->currentRow; - - case \PDO::FETCH_CLASS | \PDO::FETCH_CLASSTYPE: - $class_name = array_shift($this->currentRow); - // Deliberate no break. - case \PDO::FETCH_CLASS: - if (!isset($class_name)) { - $class_name = $this->fetchOptions['class']; - } - if (count($this->fetchOptions['constructor_args'])) { - $reflector = new \ReflectionClass($class_name); - $result = $reflector->newInstanceArgs($this->fetchOptions['constructor_args']); - } - else { - $result = new $class_name(); - } - foreach ($this->currentRow as $k => $v) { - $result->$k = $v; - } - return $result; - - case \PDO::FETCH_INTO: - foreach ($this->currentRow as $k => $v) { - $this->fetchOptions['object']->$k = $v; - } - return $this->fetchOptions['object']; - - case \PDO::FETCH_COLUMN: - if (isset($this->columnNames[$this->fetchOptions['column']])) { - return $this->currentRow[$this->columnNames[$this->fetchOptions['column']]]; - } - else { - return; - } - } - } - } - - /** - * {@inheritdoc} - */ - #[\ReturnTypeWillChange] - public function key() { - return $this->currentKey; - } - - /** - * {@inheritdoc} - */ - #[\ReturnTypeWillChange] - public function rewind() { - // Nothing to do: our DatabaseStatement can't be rewound. - } - - /** - * {@inheritdoc} - */ - #[\ReturnTypeWillChange] - public function next() { - if (!empty($this->data)) { - $this->currentRow = reset($this->data); - $this->currentKey = key($this->data); - unset($this->data[$this->currentKey]); - } - else { - $this->currentRow = NULL; - } - } - - /** - * {@inheritdoc} - */ - #[\ReturnTypeWillChange] - public function valid() { - return isset($this->currentRow); - } - - /** - * {@inheritdoc} - */ - public function rowCount() { - // SELECT query should not use the method. - if ($this->rowCountEnabled) { - return $this->rowCount; - } - else { - throw new RowCountException(); - } - } - - /** - * {@inheritdoc} - */ - public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset = NULL) { - if (isset($this->currentRow)) { - // Set the fetch parameter. - $this->fetchStyle = $fetch_style ?? $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - - // Grab the row in the format specified above. - $return = $this->current(); - // Advance the cursor. - $this->next(); - - // Reset the fetch parameters to the value stored using setFetchMode(). - $this->fetchStyle = $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - return $return; - } - else { - return FALSE; - } - } - - public function fetchColumn($index = 0) { - if (isset($this->currentRow) && isset($this->columnNames[$index])) { - // We grab the value directly from $this->data, and format it. - $return = $this->currentRow[$this->columnNames[$index]]; - $this->next(); - return $return; - } - else { - return FALSE; - } - } - - /** - * {@inheritdoc} - */ - public function fetchField($index = 0) { - return $this->fetchColumn($index); - } - - /** - * {@inheritdoc} - */ - public function fetchObject(string $class_name = NULL, array $constructor_arguments = []) { - if (isset($this->currentRow)) { - if (!isset($class_name)) { - // Directly cast to an object to avoid a function call. - $result = (object) $this->currentRow; - } - else { - $this->fetchStyle = \PDO::FETCH_CLASS; - $this->fetchOptions = [ - 'class' => $class_name, - 'constructor_args' => $constructor_arguments, - ]; - // Grab the row in the format specified above. - $result = $this->current(); - // Reset the fetch parameters to the value stored using setFetchMode(). - $this->fetchStyle = $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - } - - $this->next(); - - return $result; - } - else { - return FALSE; - } - } - - /** - * {@inheritdoc} - */ - public function fetchAssoc() { - if (isset($this->currentRow)) { - $result = $this->currentRow; - $this->next(); - return $result; - } - else { - return FALSE; - } - } - - /** - * {@inheritdoc} - */ - public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - $this->fetchStyle = $mode ?? $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - if (isset($column_index)) { - $this->fetchOptions['column'] = $column_index; - } - if (isset($constructor_arguments)) { - $this->fetchOptions['constructor_args'] = $constructor_arguments; - } - - $result = []; - // Traverse the array as PHP would have done. - while (isset($this->currentRow)) { - // Grab the row in the format specified above. - $result[] = $this->current(); - $this->next(); - } - - // Reset the fetch parameters to the value stored using setFetchMode(). - $this->fetchStyle = $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - return $result; - } - - /** - * {@inheritdoc} - */ - public function fetchCol($index = 0) { - if (isset($this->columnNames[$index])) { - $result = []; - // Traverse the array as PHP would have done. - while (isset($this->currentRow)) { - $result[] = $this->currentRow[$this->columnNames[$index]]; - $this->next(); - } - return $result; - } - else { - return []; - } - } - - /** - * {@inheritdoc} - */ - public function fetchAllKeyed($key_index = 0, $value_index = 1) { - if (!isset($this->columnNames[$key_index]) || !isset($this->columnNames[$value_index])) { - return []; - } - - $key = $this->columnNames[$key_index]; - $value = $this->columnNames[$value_index]; - - $result = []; - // Traverse the array as PHP would have done. - while (isset($this->currentRow)) { - $result[$this->currentRow[$key]] = $this->currentRow[$value]; - $this->next(); - } - return $result; - } - - /** - * {@inheritdoc} - */ - public function fetchAllAssoc($key, $fetch_style = NULL) { - $this->fetchStyle = $fetch_style ?? $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - - $result = []; - // Traverse the array as PHP would have done. - while (isset($this->currentRow)) { - // Grab the row in its raw \PDO::FETCH_ASSOC format. - $result_row = $this->current(); - $result[$this->currentRow[$key]] = $result_row; - $this->next(); - } - - // Reset the fetch parameters to the value stored using setFetchMode(). - $this->fetchStyle = $this->defaultFetchStyle; - $this->fetchOptions = $this->defaultFetchOptions; - return $result; - } - -} diff --git a/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php b/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php index 96e3acfa3d7068929f79eab7a5713e17efe6c8c8..4e7ef8fb32724fb5de04724b6a7d860c0c5f5499 100644 --- a/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php +++ b/core/lib/Drupal/Core/Database/StatementPrefetchIterator.php @@ -161,23 +161,6 @@ public function execute($args = [], $options = []) { return $return; } - /** - * Throw a PDO Exception based on the last PDO error. - * - * @deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3410663 - */ - protected function throwPDOException(): void { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3410663', E_USER_DEPRECATED); - $error_info = $this->connection->errorInfo(); - // We rebuild a message formatted in the same way as PDO. - $exception = new \PDOException("SQLSTATE[" . $error_info[0] . "]: General error " . $error_info[1] . ": " . $error_info[2]); - $exception->errorInfo = $error_info; - throw $exception; - } - /** * Grab a PDOStatement object from a given query and its arguments. * @@ -207,9 +190,8 @@ public function getQueryString() { * {@inheritdoc} */ public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - if (!in_array($mode, $this->supportedFetchModes)) { - @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - } + assert(in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + $this->defaultFetchStyle = $mode; switch ($mode) { case \PDO::FETCH_CLASS: @@ -259,23 +241,15 @@ public function fetch($fetch_style = NULL, $cursor_orientation = \PDO::FETCH_ORI // Now, format the next prefetched record according to the required fetch // style. - // @todo in Drupal 11, remove arms for deprecated fetch modes. $rowAssoc = $this->data[$currentKey]; - $row = match($fetch_style ?? $this->defaultFetchStyle) { + $mode = $fetch_style ?? $this->defaultFetchStyle; + $row = match($mode) { \PDO::FETCH_ASSOC => $rowAssoc, - // @phpstan-ignore-next-line - \PDO::FETCH_BOTH => $this->assocToBoth($rowAssoc), - \PDO::FETCH_NUM => $this->assocToNum($rowAssoc), - \PDO::FETCH_LAZY, \PDO::FETCH_OBJ => $this->assocToObj($rowAssoc), - // @phpstan-ignore-next-line - \PDO::FETCH_CLASS | \PDO::FETCH_CLASSTYPE => $this->assocToClassType($rowAssoc, $this->fetchOptions['constructor_args']), - \PDO::FETCH_CLASS => $this->assocToClass($rowAssoc, $this->fetchOptions['class'], $this->fetchOptions['constructor_args']), - // @phpstan-ignore-next-line - \PDO::FETCH_INTO => $this->assocIntoObject($rowAssoc, $this->fetchOptions['object']), + \PDO::FETCH_CLASS, \PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE => $this->assocToClass($rowAssoc, $this->fetchOptions['class'], $this->fetchOptions['constructor_args']), \PDO::FETCH_COLUMN => $this->assocToColumn($rowAssoc, $this->columnNames, $this->fetchOptions['column']), - // @todo in Drupal 11, throw an exception if the fetch style cannot be - // matched. - default => FALSE, + \PDO::FETCH_NUM => $this->assocToNum($rowAssoc), + \PDO::FETCH_OBJ => $this->assocToObj($rowAssoc), + default => throw new DatabaseExceptionWrapper('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'), }; $this->setResultsetCurrentRow($row); return $row; @@ -323,10 +297,10 @@ public function fetchAssoc() { * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - if (isset($mode) && !in_array($mode, $this->supportedFetchModes)) { - @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - } $fetchStyle = $mode ?? $this->defaultFetchStyle; + + assert(in_array($fetchStyle, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$fetchStyle] ?? $fetchStyle) . ' is not supported. Use supported modes only.'); + if (isset($column_index)) { $this->fetchOptions['column'] = $column_index; } diff --git a/core/lib/Drupal/Core/Database/StatementWrapper.php b/core/lib/Drupal/Core/Database/StatementWrapper.php deleted file mode 100644 index 965e68fce359840420a21d35d5caec225d2f7c6f..0000000000000000000000000000000000000000 --- a/core/lib/Drupal/Core/Database/StatementWrapper.php +++ /dev/null @@ -1,290 +0,0 @@ -<?php - -namespace Drupal\Core\Database; - -use Drupal\Core\Database\Event\StatementExecutionEndEvent; -use Drupal\Core\Database\Event\StatementExecutionStartEvent; - -// cSpell:ignore maxlen driverdata INOUT - -@trigger_error('\Drupal\Core\Database\StatementWrapper is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Database\StatementWrapperIterator instead. See https://www.drupal.org/node/3265938', E_USER_DEPRECATED); - -/** - * Implementation of StatementInterface encapsulating PDOStatement. - * - * @deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use - * \Drupal\Core\Database\StatementWrapperIterator instead. - * - * @see https://www.drupal.org/node/3265938 - */ -class StatementWrapper implements \IteratorAggregate, StatementInterface { - - /** - * The Drupal database connection object. - * - * @var \Drupal\Core\Database\Connection - */ - protected $connection; - - /** - * The client database Statement object. - * - * For a \PDO client connection, this will be a \PDOStatement object. - * - * @var object - */ - protected $clientStatement; - - /** - * Is rowCount() execution allowed. - * - * @var bool - */ - protected $rowCountEnabled = FALSE; - - /** - * Constructs a StatementWrapper object. - * - * @param \Drupal\Core\Database\Connection $connection - * Drupal database connection object. - * @param object $client_connection - * Client database connection object, for example \PDO. - * @param string $query - * The SQL query string. - * @param array $options - * Array of query options. - * @param bool $row_count_enabled - * (optional) Enables counting the rows matched. Defaults to FALSE. - */ - public function __construct(Connection $connection, $client_connection, string $query, array $options, bool $row_count_enabled = FALSE) { - $this->connection = $connection; - $this->clientStatement = $client_connection->prepare($query, $options); - $this->rowCountEnabled = $row_count_enabled; - $this->setFetchMode(\PDO::FETCH_OBJ); - } - - /** - * Returns the client-level database statement object. - * - * This method should normally be used only within database driver code. - * - * @return object - * The client-level database statement, for example \PDOStatement. - */ - public function getClientStatement() { - return $this->clientStatement; - } - - /** - * {@inheritdoc} - */ - public function getConnectionTarget(): string { - return $this->connection->getTarget(); - } - - /** - * {@inheritdoc} - */ - public function execute($args = [], $options = []) { - if (isset($options['fetch'])) { - if (is_string($options['fetch'])) { - // \PDO::FETCH_PROPS_LATE tells __construct() to run before properties - // are added to the object. - $this->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $options['fetch']); - } - else { - $this->setFetchMode($options['fetch']); - } - } - - if ($this->connection->isEventEnabled(StatementExecutionStartEvent::class)) { - $startEvent = new StatementExecutionStartEvent( - spl_object_id($this), - $this->connection->getKey(), - $this->connection->getTarget(), - $this->getQueryString(), - $args ?? [], - $this->connection->findCallerFromDebugBacktrace() - ); - $this->connection->dispatchEvent($startEvent); - } - - $return = $this->clientStatement->execute($args); - - if (isset($startEvent) && $this->connection->isEventEnabled(StatementExecutionEndEvent::class)) { - $this->connection->dispatchEvent(new StatementExecutionEndEvent( - $startEvent->statementObjectId, - $startEvent->key, - $startEvent->target, - $startEvent->queryString, - $startEvent->args, - $startEvent->caller, - $startEvent->time - )); - } - - return $return; - } - - /** - * {@inheritdoc} - */ - public function getQueryString() { - return $this->clientStatement->queryString; - } - - /** - * {@inheritdoc} - */ - public function fetchCol($index = 0) { - return $this->fetchAll(\PDO::FETCH_COLUMN, $index); - } - - /** - * {@inheritdoc} - */ - public function fetchAllAssoc($key, $fetch = NULL) { - $return = []; - if (isset($fetch)) { - if (is_string($fetch)) { - $this->setFetchMode(\PDO::FETCH_CLASS, $fetch); - } - else { - $this->setFetchMode($fetch); - } - } - - foreach ($this as $record) { - $record_key = is_object($record) ? $record->$key : $record[$key]; - $return[$record_key] = $record; - } - - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchAllKeyed($key_index = 0, $value_index = 1) { - $return = []; - $this->setFetchMode(\PDO::FETCH_NUM); - foreach ($this as $record) { - $return[$record[$key_index]] = $record[$value_index]; - } - return $return; - } - - /** - * {@inheritdoc} - */ - public function fetchField($index = 0) { - // Call \PDOStatement::fetchColumn to fetch the field. - return $this->clientStatement->fetchColumn($index); - } - - /** - * {@inheritdoc} - */ - public function fetchAssoc() { - // Call \PDOStatement::fetch to fetch the row. - return $this->fetch(\PDO::FETCH_ASSOC); - } - - /** - * {@inheritdoc} - */ - public function fetchObject(string $class_name = NULL, array $constructor_arguments = []) { - if ($class_name) { - return $this->clientStatement->fetchObject($class_name, $constructor_arguments); - } - return $this->clientStatement->fetchObject(); - } - - /** - * {@inheritdoc} - */ - public function rowCount() { - // SELECT query should not use the method. - if ($this->rowCountEnabled) { - return $this->clientStatement->rowCount(); - } - else { - throw new RowCountException(); - } - } - - /** - * {@inheritdoc} - */ - public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - // Call \PDOStatement::setFetchMode to set fetch mode. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to be pass the exact number of arguments we where given. - switch (func_num_args()) { - case 1: - return $this->clientStatement->setFetchMode($mode); - - case 2: - return $this->clientStatement->setFetchMode($mode, $a1); - - case 3: - default: - return $this->clientStatement->setFetchMode($mode, $a1, $a2); - } - } - - /** - * {@inheritdoc} - */ - public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) { - // Call \PDOStatement::fetchAll to fetch all rows. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to be pass the exact number of arguments we where given. - switch (func_num_args()) { - case 0: - return $this->clientStatement->fetch(); - - case 1: - return $this->clientStatement->fetch($mode); - - case 2: - return $this->clientStatement->fetch($mode, $cursor_orientation); - - case 3: - default: - return $this->clientStatement->fetch($mode, $cursor_orientation, $cursor_offset); - } - } - - /** - * {@inheritdoc} - */ - public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - // Call \PDOStatement::fetchAll to fetch all rows. - // \PDOStatement is picky about the number of arguments in some cases so we - // need to be pass the exact number of arguments we where given. - switch (func_num_args()) { - case 0: - return $this->clientStatement->fetchAll(); - - case 1: - return $this->clientStatement->fetchAll($mode); - - case 2: - return $this->clientStatement->fetchAll($mode, $column_index); - - case 3: - default: - return $this->clientStatement->fetchAll($mode, $column_index, $constructor_arguments); - } - } - - /** - * {@inheritdoc} - */ - #[\ReturnTypeWillChange] - public function getIterator() { - return new \ArrayIterator($this->fetchAll()); - } - -} diff --git a/core/lib/Drupal/Core/Database/StatementWrapperIterator.php b/core/lib/Drupal/Core/Database/StatementWrapperIterator.php index c6dd50383b184302abb9e26e633600209e62773e..cc1a25ed5237d63a201b578668bb4c78f4fb77d0 100644 --- a/core/lib/Drupal/Core/Database/StatementWrapperIterator.php +++ b/core/lib/Drupal/Core/Database/StatementWrapperIterator.php @@ -269,9 +269,8 @@ public function rowCount() { * {@inheritdoc} */ public function setFetchMode($mode, $a1 = NULL, $a2 = []) { - if (!in_array($mode, $this->supportedFetchModes)) { - @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - } + assert(in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + // Call \PDOStatement::setFetchMode to set fetch mode. // \PDOStatement is picky about the number of arguments in some cases so we // need to be pass the exact number of arguments we where given. @@ -286,9 +285,8 @@ public function setFetchMode($mode, $a1 = NULL, $a2 = []) { * {@inheritdoc} */ public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = NULL) { - if (isset($mode) && !in_array($mode, $this->supportedFetchModes)) { - @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - } + assert(!isset($mode) || in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + // Call \PDOStatement::fetchAll to fetch all rows. // \PDOStatement is picky about the number of arguments in some cases so we // need to pass the exact number of arguments we were given. @@ -312,9 +310,8 @@ public function fetch($mode = NULL, $cursor_orientation = NULL, $cursor_offset = * {@inheritdoc} */ public function fetchAll($mode = NULL, $column_index = NULL, $constructor_arguments = NULL) { - if (isset($mode) && !in_array($mode, $this->supportedFetchModes)) { - @trigger_error('Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999', E_USER_DEPRECATED); - } + assert(!isset($mode) || in_array($mode, $this->supportedFetchModes), 'Fetch mode ' . ($this->fetchModeLiterals[$mode] ?? $mode) . ' is not supported. Use supported modes only.'); + // Call \PDOStatement::fetchAll to fetch all rows. // \PDOStatement is picky about the number of arguments in some cases so we // need to be pass the exact number of arguments we where given. diff --git a/core/lib/Drupal/Core/Database/Transaction.php b/core/lib/Drupal/Core/Database/Transaction.php index 2c1ea5e0458b97bac34e74a16f7a823128f67f02..617013d7b5db9fba5e3f9aa761a7a44450560bc7 100644 --- a/core/lib/Drupal/Core/Database/Transaction.php +++ b/core/lib/Drupal/Core/Database/Transaction.php @@ -23,84 +23,19 @@ */ class Transaction { - /** - * The connection object for this transaction. - * - * @var \Drupal\Core\Database\Connection - */ - protected $connection; - - /** - * A boolean value to indicate whether this transaction has been rolled back. - * - * @var bool - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is - * no replacement. - * - * @see https://www.drupal.org/node/3381002 - */ - protected $rolledBack = FALSE; - - /** - * The name of the transaction. - * - * This is used to label the transaction savepoint. It will be overridden to - * 'drupal_transaction' if there is no transaction depth. - * - * @var string - */ - protected $name; - public function __construct( - Connection $connection, - $name = NULL, - protected readonly string $id = '', + protected readonly Connection $connection, + protected readonly string $name, + protected readonly string $id, ) { // Transactions rely on objects being destroyed in order to be committed. // PHP makes no guarantee about the order in which objects are destroyed so // ensure all transactions are committed on shutdown. Database::commitAllOnShutdown(); - - if ($connection->transactionManager()) { - $this->connection = $connection; - $this->name = $name; - return; - } - // Start of BC layer. - $this->connection = $connection; - // If there is no transaction depth, then no transaction has started. Name - // the transaction 'drupal_transaction'. - // @phpstan-ignore-next-line - if (!$depth = $connection->transactionDepth()) { - $this->name = 'drupal_transaction'; - } - // Within transactions, savepoints are used. Each savepoint requires a - // name. So if no name is present we need to create one. - elseif (!$name) { - $this->name = 'savepoint_' . $depth; - } - else { - $this->name = $name; - } - // @phpstan-ignore-next-line - $this->connection->pushTransaction($this->name); - // End of BC layer. } public function __destruct() { - if ($this->connection->transactionManager()) { - $this->connection->transactionManager()->unpile($this->name, $this->id); - return; - } - // Start of BC layer. - // If we rolled back then the transaction would have already been popped. - // @phpstan-ignore-next-line - if (!$this->rolledBack) { - // @phpstan-ignore-next-line - $this->connection->popTransaction($this->name); - } - // End of BC layer. + $this->connection->transactionManager()->unpile($this->name, $this->id); } /** @@ -121,16 +56,7 @@ public function name() { * @see \Drupal\Core\Database\Connection::rollBack() */ public function rollBack() { - if ($this->connection->transactionManager()) { - $this->connection->transactionManager()->rollback($this->name, $this->id); - return; - } - // Start of BC layer. - // @phpstan-ignore-next-line - $this->rolledBack = TRUE; - // @phpstan-ignore-next-line - $this->connection->rollBack($this->name); - // End of BC layer. + $this->connection->transactionManager()->rollback($this->name, $this->id); } } diff --git a/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php b/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php index 932946a82d43db886f075131548e6302595071dc..07e727b6a018fdcd7c2ce581a181bf075ffdfe31 100644 --- a/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php +++ b/core/lib/Drupal/Core/Database/Transaction/TransactionManagerBase.php @@ -308,21 +308,6 @@ public function unpile(string $name, string $id): void { * {@inheritdoc} */ public function rollback(string $name, string $id): void { - // @todo remove in drupal:11.0.0. - // Start of BC layer. - if ($id === 'bc-force-rollback') { - foreach ($this->stack() as $stackId => $item) { - if ($item->name === $name) { - $id = $stackId; - break; - } - } - if ($id === 'bc-force-rollback') { - throw new TransactionOutOfOrderException(); - } - } - // End of BC layer. - // Rolled back item should match the last one in stack. if ($id != array_key_last($this->stack()) || $name !== $this->stack()[$id]->name) { throw new TransactionOutOfOrderException("Error attempting rollback of {$id}\\{$name}. Active stack: " . $this->dumpStackItemsAsString()); diff --git a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php index c65c623fef0143db71fcc26bee67d4b328257a6a..e67614336ab17d6a3c570f54a26b4348c4f665a6 100644 --- a/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php +++ b/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php @@ -5,7 +5,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\MemoryCache\MemoryCacheInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\SchemaException; use Drupal\Core\Entity\ContentEntityInterface; @@ -940,10 +939,8 @@ protected function doSaveFieldItems(ContentEntityInterface $entity, array $names } } else { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 $insert_id = $this->database - ->insert($this->baseTable, ['return' => Database::RETURN_INSERT_ID]) + ->insert($this->baseTable) ->fields((array) $record) ->execute(); // Even if this is a new entity the ID key might have been set, in which @@ -1145,10 +1142,8 @@ protected function saveRevision(ContentEntityInterface $entity) { $entity->preSaveRevision($this, $record); if ($entity->isNewRevision()) { - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 $insert_id = $this->database - ->insert($this->revisionTable, ['return' => Database::RETURN_INSERT_ID]) + ->insert($this->revisionTable) ->fields((array) $record) ->execute(); // Even if this is a new revision, the revision ID key might have been diff --git a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php index 871ebe95d4458cffa1d879a564c49acb45008db7..7f8054da093843bd867f71a50825704e45530c29 100644 --- a/core/lib/Drupal/Core/Menu/MenuTreeStorage.php +++ b/core/lib/Drupal/Core/Menu/MenuTreeStorage.php @@ -8,7 +8,6 @@ use Drupal\Core\Cache\CacheBackendInterface; use Drupal\Core\Cache\CacheTagsInvalidatorInterface; use Drupal\Core\Database\Connection; -use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\Query\SelectInterface; @@ -289,10 +288,7 @@ protected function doSave(array $link) { $transaction = $this->connection->startTransaction(); if (!$original) { // Generate a new mlid. - // @todo Remove the 'return' option in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - $options = ['return' => Database::RETURN_INSERT_ID] + $this->options; - $link['mlid'] = $this->connection->insert($this->table, $options) + $link['mlid'] = $this->connection->insert($this->table, $this->options) ->fields(['id' => $link['id'], 'menu_name' => $link['menu_name']]) ->execute(); $fields = $this->preSave($link, []); diff --git a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php index 099ec96c49d586a411519344841e0af36823bcc4..d6873999b5597b162011392d87ba91a33498ed76 100644 --- a/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php +++ b/core/modules/migrate/tests/src/Unit/MigrateSqlIdMapEnsureTablesTest.php @@ -174,7 +174,7 @@ protected function runEnsureTablesTest($schema) { ->method('schema') ->willReturn($schema); $database->expects($this->any()) - ->method('tablePrefix') + ->method('getPrefix') ->willReturn(''); $migration = $this->getMigration(); $plugin = $this->createMock('Drupal\migrate\Plugin\MigrateSourceInterface'); diff --git a/core/modules/mysql/src/Driver/Database/mysql/Connection.php b/core/modules/mysql/src/Driver/Database/mysql/Connection.php index 48a42294c070480039a49ec3f830d3fa023a21a1..88187314c6e171ce83039f501667d60b48a2af31 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Connection.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Connection.php @@ -6,9 +6,7 @@ use Drupal\Core\Database\Database; use Drupal\Core\Database\DatabaseAccessDeniedException; use Drupal\Core\Database\DatabaseConnectionRefusedException; -use Drupal\Core\Database\DatabaseException; use Drupal\Core\Database\DatabaseNotFoundException; -use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\StatementWrapperIterator; use Drupal\Core\Database\SupportsTemporaryTablesInterface; use Drupal\Core\Database\Transaction\TransactionManagerInterface; @@ -58,18 +56,6 @@ class Connection extends DatabaseConnection implements SupportsTemporaryTablesIn */ protected $statementWrapperClass = StatementWrapperIterator::class; - /** - * Flag to indicate if the cleanup function in __destruct() should run. - * - * @var bool - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There's no - * replacement. - * - * @see https://www.drupal.org/node/3349345 - */ - protected $needsCleanup = FALSE; - /** * Stores the server version after it has been retrieved from the database. * @@ -251,16 +237,6 @@ public static function open(array &$connection_options = []) { return $pdo; } - /** - * {@inheritdoc} - */ - public function __destruct() { - if ($this->needsCleanup) { - $this->nextIdDelete(); - } - parent::__destruct(); - } - public function queryRange($query, $from, $count, array $args = [], array $options = []) { return $this->query($query . ' LIMIT ' . (int) $from . ', ' . (int) $count, $args, $options); } @@ -359,55 +335,6 @@ public function mapConditionOperator($operator) { return NULL; } - /** - * {@inheritdoc} - */ - public function nextId($existing_id = 0) { - @trigger_error('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); - $this->query('INSERT INTO {sequences} () VALUES ()'); - $new_id = $this->lastInsertId(); - // This should only happen after an import or similar event. - if ($existing_id >= $new_id) { - // If we INSERT a value manually into the sequences table, on the next - // INSERT, MySQL will generate a larger value. However, there is no way - // of knowing whether this value already exists in the table. MySQL - // provides an INSERT IGNORE which would work, but that can mask problems - // other than duplicate keys. Instead, we use INSERT ... ON DUPLICATE KEY - // UPDATE in such a way that the UPDATE does not do anything. This way, - // duplicate keys do not generate errors but everything else does. - $this->query('INSERT INTO {sequences} (value) VALUES (:value) ON DUPLICATE KEY UPDATE value = value', [':value' => $existing_id]); - $this->query('INSERT INTO {sequences} () VALUES ()'); - $new_id = $this->lastInsertId(); - } - $this->needsCleanup = TRUE; - return $new_id; - } - - public function nextIdDelete() { - @trigger_error(__METHOD__ . '() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); - // While we want to clean up the table to keep it up from occupying too - // much storage and memory, we must keep the highest value in the table - // because InnoDB uses an in-memory auto-increment counter as long as the - // server runs. When the server is stopped and restarted, InnoDB - // re-initializes the counter for each table for the first INSERT to the - // table based solely on values from the table so deleting all values would - // be a problem in this case. Also, TRUNCATE resets the auto increment - // counter. - try { - $max_id = $this->query('SELECT MAX(value) FROM {sequences}')->fetchField(); - // We know we are using MySQL here, no need for the slower ::delete(). - $this->query('DELETE FROM {sequences} WHERE value < :value', [':value' => $max_id]); - } - // During testing, this function is called from shutdown with the - // simpletest prefix stored in $this->connection, and those tables are gone - // by the time shutdown is called so we need to ignore the database - // errors. There is no problem with completely ignoring errors here: if - // these queries fail, the sequence will work just fine, just use a bit - // more database storage and memory. - catch (DatabaseException $e) { - } - } - /** * {@inheritdoc} */ @@ -415,13 +342,6 @@ public function exceptionHandler() { return new ExceptionHandler(); } - /** - * {@inheritdoc} - */ - public function select($table, $alias = NULL, array $options = []) { - return new Select($this, $table, $alias, $options); - } - /** * {@inheritdoc} */ @@ -429,13 +349,6 @@ public function insert($table, array $options = []) { return new Insert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function merge($table, array $options = []) { - return new Merge($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -443,27 +356,6 @@ public function upsert($table, array $options = []) { return new Upsert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function update($table, array $options = []) { - return new Update($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function delete($table, array $options = []) { - return new Delete($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function truncate($table, array $options = []) { - return new Truncate($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -474,13 +366,6 @@ public function schema() { return $this->schema; } - /** - * {@inheritdoc} - */ - public function condition($conjunction) { - return new Condition($conjunction); - } - /** * {@inheritdoc} */ @@ -488,13 +373,6 @@ protected function driverTransactionManager(): TransactionManagerInterface { return new TransactionManager($this); } - /** - * {@inheritdoc} - */ - public function startTransaction($name = '') { - return $this->transactionManager()->push($name); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Delete.php b/core/modules/mysql/src/Driver/Database/mysql/Delete.php index 764a99b133c224266fe76ac146229e6e06e14790..6a6c9865dbff460a3bb00051e00fcf65a3550208 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Delete.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Delete.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Delete as QueryDelete; +@trigger_error('Extending from \Drupal\mysql\Driver\Database\mysql\Delete is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * MySQL implementation of \Drupal\Core\Database\Query\Delete. */ class Delete extends QueryDelete { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Insert.php b/core/modules/mysql/src/Driver/Database/mysql/Insert.php index e14e6d0d2802d0d499031d8824389a5d6d7fe668..6db8e4f61279227b8337546fb87a902a93aa937f 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Insert.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Insert.php @@ -9,16 +9,6 @@ */ class Insert extends QueryInsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - public function execute() { if (!$this->preExecute()) { return NULL; diff --git a/core/modules/mysql/src/Driver/Database/mysql/Merge.php b/core/modules/mysql/src/Driver/Database/mysql/Merge.php index f26090032ba2e2d88729c6b1fe26c9e01581acdc..7f84a9d50acd122fd8bcd106f4aab9a5d9126025 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Merge.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Merge.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Merge as QueryMerge; +@trigger_error('Extending from \Drupal\mysql\Driver\Database\mysql\Merge is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * MySQL implementation of \Drupal\Core\Database\Query\Merge. */ class Merge extends QueryMerge { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Select.php b/core/modules/mysql/src/Driver/Database/mysql/Select.php index 534cf38ac24955f4f7ec5db9721d85fa1efc662c..3452a6fff4604c6d204f0c6055e92a3eed2691d6 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Select.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Select.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Select as QuerySelect; +@trigger_error('Extending from \Drupal\mysql\Driver\Database\mysql\Select is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * MySQL implementation of \Drupal\Core\Database\Query\Select. */ class Select extends QuerySelect { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, $table, $alias = NULL, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $alias, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Truncate.php b/core/modules/mysql/src/Driver/Database/mysql/Truncate.php index 6682318f85e7bf458fab8b77ed040e9b9cadc82d..a106371ea00da3980cf6809ee0583d2f2b2ba74c 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Truncate.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Truncate.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Truncate as QueryTruncate; +@trigger_error('Extending from \Drupal\mysql\Driver\Database\mysql\Truncate is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * MySQL implementation of \Drupal\Core\Database\Query\Truncate. */ class Truncate extends QueryTruncate { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Update.php b/core/modules/mysql/src/Driver/Database/mysql/Update.php index e0995d9c881c182467d6b9c5a25a5ff19955c3e1..bf6456cc6c831e96b4754d2eb63a83bbae07ec54 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Update.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Update.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Update as QueryUpdate; +@trigger_error('Extending from \Drupal\mysql\Driver\Database\mysql\Update is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * MySQL implementation of \Drupal\Core\Database\Query\Update. */ class Update extends QueryUpdate { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/mysql/src/Driver/Database/mysql/Upsert.php b/core/modules/mysql/src/Driver/Database/mysql/Upsert.php index 5b2a5929d09b0c6508b5087dd2b143aac1809666..0e5f7d3b50e91e9558126917c32fad8c73ab7770 100644 --- a/core/modules/mysql/src/Driver/Database/mysql/Upsert.php +++ b/core/modules/mysql/src/Driver/Database/mysql/Upsert.php @@ -9,16 +9,6 @@ */ class Upsert extends QueryUpsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php b/core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php index 6521a339f9fbe11259c957ca98a58570e6490885..71be9ea5139eba382b9c0af2afed0991599f2c05 100644 --- a/core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php +++ b/core/modules/mysql/tests/src/Kernel/mysql/ConnectionTest.php @@ -21,14 +21,4 @@ public function testMultipleStatementsForNewPhp(): void { Database::getConnection('default', 'default')->query('SELECT * FROM {test}; SELECT * FROM {test_people}', [], ['allow_delimiter_in_query' => TRUE]); } - /** - * Tests deprecation of ::makeSequenceName(). - * - * @group legacy - */ - public function testMakeSequenceNameDeprecation(): void { - $this->expectDeprecation("Drupal\\Core\\Database\\Connection::makeSequenceName() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3377046"); - $this->assertIsString($this->connection->makeSequenceName('foo', 'bar')); - } - } diff --git a/core/modules/mysql/tests/src/Kernel/mysql/MysqlDriverLegacyTest.php b/core/modules/mysql/tests/src/Kernel/mysql/MysqlDriverLegacyTest.php deleted file mode 100644 index 774cc941dff7f9afb04618db4e3d57add1f6819a..0000000000000000000000000000000000000000 --- a/core/modules/mysql/tests/src/Kernel/mysql/MysqlDriverLegacyTest.php +++ /dev/null @@ -1,79 +0,0 @@ -<?php - -namespace Drupal\Tests\mysql\Kernel\mysql; - -use Drupal\Core\Database\Driver\mysql\Connection; -use Drupal\Core\Database\Driver\mysql\ExceptionHandler; -use Drupal\Core\Database\Driver\mysql\Install\Tasks; -use Drupal\Core\Database\Driver\mysql\Insert; -use Drupal\Core\Database\Driver\mysql\Schema; -use Drupal\Core\Database\Driver\mysql\Upsert; -use Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase; -use Drupal\Tests\Core\Database\Stub\StubPDO; - -/** - * Tests the deprecations of the MySQL database driver classes in Core. - * - * @group legacy - * @group Database - */ -class MysqlDriverLegacyTest extends DriverSpecificDatabaseTestBase { - - /** - * @covers Drupal\Core\Database\Driver\mysql\Install\Tasks - */ - public function testDeprecationInstallTasks() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - $tasks = new Tasks(); - $this->assertInstanceOf(Tasks::class, $tasks); - } - - /** - * @covers Drupal\Core\Database\Driver\mysql\Connection - */ - public function testDeprecationConnection() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - // @todo https://www.drupal.org/project/drupal/issues/3251084 Remove setting - // the $options parameter. - $options['init_commands']['sql_mode'] = ''; - $connection = new Connection($this->createMock(StubPDO::class), $options); - $this->assertInstanceOf(Connection::class, $connection); - } - - /** - * @covers Drupal\Core\Database\Driver\mysql\ExceptionHandler - */ - public function testDeprecationExceptionHandler() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\ExceptionHandler is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - $handler = new ExceptionHandler(); - $this->assertInstanceOf(ExceptionHandler::class, $handler); - } - - /** - * @covers Drupal\Core\Database\Driver\mysql\Insert - */ - public function testDeprecationInsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - $insert = new Insert($this->connection, 'test'); - $this->assertInstanceOf(Insert::class, $insert); - } - - /** - * @covers Drupal\Core\Database\Driver\mysql\Schema - */ - public function testDeprecationSchema() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - $schema = new Schema($this->connection); - $this->assertInstanceOf(Schema::class, $schema); - } - - /** - * @covers Drupal\Core\Database\Driver\mysql\Upsert - */ - public function testDeprecationUpsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\mysql\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The MySQL database driver has been moved to the mysql module. See https://www.drupal.org/node/3129492'); - $upsert = new Upsert($this->connection, 'test'); - $this->assertInstanceOf(Upsert::class, $upsert); - } - -} diff --git a/core/modules/mysql/tests/src/Kernel/mysql/NextIdTest.php b/core/modules/mysql/tests/src/Kernel/mysql/NextIdTest.php deleted file mode 100644 index 7d2c4543b0c5ef869a51bb6910c07c569f1afe0a..0000000000000000000000000000000000000000 --- a/core/modules/mysql/tests/src/Kernel/mysql/NextIdTest.php +++ /dev/null @@ -1,75 +0,0 @@ -<?php - -namespace Drupal\Tests\mysql\Kernel\mysql; - -use Drupal\Core\Database\Database; -use Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase; - -/** - * Tests the sequences API. - * - * @group Database - * @group legacy - */ -class NextIdTest extends DriverSpecificDatabaseTestBase { - - /** - * The modules to enable. - * - * @var array - */ - protected static $modules = ['database_test', 'system']; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - $table_specification = [ - 'description' => 'Stores IDs.', - 'fields' => [ - 'value' => [ - 'description' => 'The value of the sequence.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ], - ], - 'primary key' => ['value'], - ]; - $this->connection->schema()->createTable('sequences', $table_specification); - } - - /** - * Tests that sequences table clear up works when a connection is closed. - * - * @see \Drupal\mysql\Driver\Database\mysql\Connection::__destruct() - */ - public function testDbNextIdClosedConnection() { - $this->expectDeprecation('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345'); - $this->expectDeprecation('Drupal\mysql\Driver\Database\mysql\Connection::nextIdDelete() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345'); - - // Create an additional connection to test closing the connection. - $connection_info = Database::getConnectionInfo(); - Database::addConnectionInfo('default', 'next_id', $connection_info['default']); - - // Get a few IDs to ensure there the clean up needs to run and there is more - // than one row. - Database::getConnection('next_id')->nextId(); - Database::getConnection('next_id')->nextId(); - - // At this point the sequences table should contain unnecessary rows. - $count = $this->connection->select('sequences')->countQuery()->execute()->fetchField(); - $this->assertGreaterThan(1, $count); - - // Close the connection. - Database::closeConnection('next_id'); - - // Test that \Drupal\mysql\Driver\Database\mysql\Connection::__destruct() - // successfully trims the sequences table if the connection is closed. - $count = $this->connection->select('sequences')->countQuery()->execute()->fetchField(); - $this->assertEquals(1, $count); - } - -} diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php b/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php index 3cab209a0d4800b3aaae540ddc66b23dee801dbe..e757e5a7fd66baa0f8f22710a598cd13813bdff8 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Connection.php @@ -7,7 +7,6 @@ use Drupal\Core\Database\DatabaseAccessDeniedException; use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\ExceptionHandler; -use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\StatementInterface; use Drupal\Core\Database\StatementWrapperIterator; use Drupal\Core\Database\SupportsTemporaryTablesInterface; @@ -343,49 +342,6 @@ public function makeSequenceName($table, $field) { return str_replace($this->identifierQuotes, '', $sequence_name); } - /** - * Retrieve a the next id in a sequence. - * - * PostgreSQL has built in sequences. We'll use these instead of inserting - * and updating a sequences table. - */ - public function nextId($existing = 0) { - @trigger_error('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); - // Retrieve the name of the sequence. This information cannot be cached - // because the prefix may change, for example, like it does in tests. - $sequence_name = $this->makeSequenceName('sequences', 'value'); - - // When PostgreSQL gets a value too small then it will lock the table, - // retry the INSERT and if it's still too small then alter the sequence. - $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField(); - if ($id > $existing) { - return $id; - } - - // PostgreSQL advisory locks are simply locks to be used by an - // application such as Drupal. This will prevent other Drupal processes - // from altering the sequence while we are. - $this->query("SELECT pg_advisory_lock(" . self::POSTGRESQL_NEXTID_LOCK . ")"); - - // While waiting to obtain the lock, the sequence may have been altered - // so lets try again to obtain an adequate value. - $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField(); - if ($id > $existing) { - $this->query("SELECT pg_advisory_unlock(" . self::POSTGRESQL_NEXTID_LOCK . ")"); - return $id; - } - - // Reset the sequence to a higher value than the existing id. - $this->query("ALTER SEQUENCE " . $sequence_name . " RESTART WITH " . ($existing + 1)); - - // Retrieve the next id. We know this will be as high as we want it. - $id = $this->query("SELECT nextval('" . $sequence_name . "')")->fetchField(); - - $this->query("SELECT pg_advisory_unlock(" . self::POSTGRESQL_NEXTID_LOCK . ")"); - - return $id; - } - /** * {@inheritdoc} */ @@ -474,13 +430,6 @@ public function insert($table, array $options = []) { return new Insert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function merge($table, array $options = []) { - return new Merge($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -519,13 +468,6 @@ public function schema() { return $this->schema; } - /** - * {@inheritdoc} - */ - public function condition($conjunction) { - return new Condition($conjunction); - } - /** * {@inheritdoc} */ @@ -533,13 +475,6 @@ protected function driverTransactionManager(): TransactionManagerInterface { return new TransactionManager($this); } - /** - * {@inheritdoc} - */ - public function startTransaction($name = '') { - return $this->transactionManager()->push($name); - } - } /** diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Delete.php b/core/modules/pgsql/src/Driver/Database/pgsql/Delete.php index 78f7908956a3ac0abc42ce78e7a0b14a0fa39ee3..9585a9c4bc52ffe3a31d6a602cb36f74f03adadf 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Delete.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Delete.php @@ -9,16 +9,6 @@ */ class Delete extends QueryDelete { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php b/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php index 52d37c7f105aaf6ec74b3c2e011224ef0e9d00da..843b23d414e2f482ac7d40fa027806417356c9c7 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Insert.php @@ -17,16 +17,6 @@ */ class Insert extends QueryInsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - public function execute() { if (!$this->preExecute()) { return NULL; diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php b/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php index 7691422165ef7d43c8535f1cf6e495d894a611e3..0922e47302f0af864d011dce9ffe04aff9047344 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Install/Tasks.php @@ -251,11 +251,7 @@ public function checkExtensions() { $connection = Database::getConnection(); try { // Enable pg_trgm for PostgreSQL 13 or higher. - // @todo Remove this if-statement in D11 when the minimum required version - // for PostgreSQL becomes 13 or higher. https://www.drupal.org/i/3357409 - if (version_compare($connection->version(), '13.0', '>=')) { - $connection->query('CREATE EXTENSION IF NOT EXISTS pg_trgm'); - } + $connection->query('CREATE EXTENSION IF NOT EXISTS pg_trgm'); if ($connection->schema()->extensionExists('pg_trgm')) { $this->pass(t('PostgreSQL has the pg_trgm extension enabled.')); diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Merge.php b/core/modules/pgsql/src/Driver/Database/pgsql/Merge.php index 11fa63868669951f678617bc68676e6700609698..2a24c94f59fd80253986ed2967c4dfeead08d73a 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Merge.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Merge.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Merge as QueryMerge; +@trigger_error('Extending from \Drupal\pgsql\Driver\Database\pgsql\Merge is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * PostgreSQL implementation of \Drupal\Core\Database\Query\Merge. */ class Merge extends QueryMerge { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Select.php b/core/modules/pgsql/src/Driver/Database/pgsql/Select.php index d04f06c440c91df8e21963cdea4953bd38c28a09..26a0e0feb48af1e4acab5ebdd59a94d43f0a1e1d 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Select.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Select.php @@ -14,16 +14,6 @@ */ class Select extends QuerySelect { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, $table, $alias = NULL, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $alias, $options); - unset($this->queryOptions['return']); - } - public function orderRandom() { $alias = $this->addExpression('RANDOM()', 'random_field'); $this->orderBy($alias); diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Truncate.php b/core/modules/pgsql/src/Driver/Database/pgsql/Truncate.php index 102cceae4b51c760aa1376515285fc6ffdca0247..18115e0a7d0517564c5ad6a6b08040037570a5ab 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Truncate.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Truncate.php @@ -9,16 +9,6 @@ */ class Truncate extends QueryTruncate { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Update.php b/core/modules/pgsql/src/Driver/Database/pgsql/Update.php index c680097284ab0ae0c270166e3a704cbe749c8b25..d3f2ebf6431d7b844863701efed9190d2ac6b69e 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Update.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Update.php @@ -10,16 +10,6 @@ */ class Update extends QueryUpdate { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - public function execute() { $max_placeholder = 0; $blobs = []; diff --git a/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php b/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php index e738bf25a0a327283e95b8fe80c49b7aefa50431..35823a270b1c8bd89f2cddba9482cff36da7a8f6 100644 --- a/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php +++ b/core/modules/pgsql/src/Driver/Database/pgsql/Upsert.php @@ -11,16 +11,6 @@ */ class Upsert extends QueryUpsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/pgsql/tests/src/Kernel/pgsql/PgsqlDriverLegacyTest.php b/core/modules/pgsql/tests/src/Kernel/pgsql/PgsqlDriverLegacyTest.php deleted file mode 100644 index bcdd365660c7d34a8e974311e6a0aa181a35bbaf..0000000000000000000000000000000000000000 --- a/core/modules/pgsql/tests/src/Kernel/pgsql/PgsqlDriverLegacyTest.php +++ /dev/null @@ -1,106 +0,0 @@ -<?php - -namespace Drupal\Tests\pgsql\Kernel\pgsql; - -use Drupal\Core\Database\Driver\pgsql\Connection; -use Drupal\Core\Database\Driver\pgsql\Delete; -use Drupal\Core\Database\Driver\pgsql\Install\Tasks; -use Drupal\Core\Database\Driver\pgsql\Insert; -use Drupal\Core\Database\Driver\pgsql\Schema; -use Drupal\Core\Database\Driver\pgsql\Select; -use Drupal\Core\Database\Driver\pgsql\Truncate; -use Drupal\Core\Database\Driver\pgsql\Update; -use Drupal\Core\Database\Driver\pgsql\Upsert; -use Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase; -use Drupal\Tests\Core\Database\Stub\StubPDO; - -/** - * Tests the deprecations of the PostgreSQL database driver classes in Core. - * - * @group legacy - * @group Database - */ -class PgsqlDriverLegacyTest extends DriverSpecificDatabaseTestBase { - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Install\Tasks - */ - public function testDeprecationInstallTasks() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $tasks = new Tasks(); - $this->assertInstanceOf(Tasks::class, $tasks); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Connection - */ - public function testDeprecationConnection() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $connection = new Connection($this->createMock(StubPDO::class), []); - $this->assertInstanceOf(Connection::class, $connection); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Delete - */ - public function testDeprecationDelete() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Delete is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $delete = new Delete($this->connection, 'test'); - $this->assertInstanceOf(Delete::class, $delete); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Insert - */ - public function testDeprecationInsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $insert = new Insert($this->connection, 'test'); - $this->assertInstanceOf(Insert::class, $insert); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Schema - */ - public function testDeprecationSchema() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $schema = new Schema($this->connection); - $this->assertInstanceOf(Schema::class, $schema); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Select - */ - public function testDeprecationSelect() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Select is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $select = new Select($this->connection, 'test'); - $this->assertInstanceOf(Select::class, $select); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Truncate - */ - public function testDeprecationTruncate() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Truncate is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $truncate = new Truncate($this->connection, 'test'); - $this->assertInstanceOf(Truncate::class, $truncate); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Update - */ - public function testDeprecationUpdate() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Update is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $update = new Update($this->connection, 'test'); - $this->assertInstanceOf(Update::class, $update); - } - - /** - * @covers Drupal\Core\Database\Driver\pgsql\Upsert - */ - public function testDeprecationUpsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\pgsql\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The PostgreSQL database driver has been moved to the pgsql module. See https://www.drupal.org/node/3129492'); - $upsert = new Upsert($this->connection, 'test'); - $this->assertInstanceOf(Upsert::class, $upsert); - } - -} diff --git a/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php b/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php index 32d9b5dc1764193366586b6d7199003177f03c5b..9e4e7474c29eda02aa43e79f2def3bbaf36e33c6 100644 --- a/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php +++ b/core/modules/pgsql/tests/src/Kernel/pgsql/SchemaTest.php @@ -234,7 +234,7 @@ public function testReservedKeywordsForNaming(): void { } /** - * @covers \Drupal\Core\Database\Driver\pgsql\Schema::extensionExists + * @covers \Drupal\pgsql\Driver\Database\pgsql\Schema::extensionExists */ public function testPgsqlExtensionExists(): void { // Test the method for a non existing extension. diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php index 31622c35a841d5ebf24c3eed84dd948656f12b4d..73a6c12a5f101c8a2292c9da13896915c2389904 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Connection.php @@ -3,10 +3,8 @@ namespace Drupal\sqlite\Driver\Database\sqlite; use Drupal\Core\Database\Connection as DatabaseConnection; -use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\DatabaseNotFoundException; use Drupal\Core\Database\ExceptionHandler; -use Drupal\Core\Database\Query\Condition; use Drupal\Core\Database\StatementInterface; use Drupal\Core\Database\SupportsTemporaryTablesInterface; use Drupal\Core\Database\Transaction\TransactionManagerInterface; @@ -26,18 +24,6 @@ class Connection extends DatabaseConnection implements SupportsTemporaryTablesIn */ protected $statementWrapperClass = NULL; - /** - * Whether or not the active transaction (if any) will be rolled back. - * - * @var bool - * - * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. It is - * unused. - * - * @see https://www.drupal.org/node/3381002 - */ - protected $willRollback; - /** * A map of condition operators to SQLite operators. * @@ -410,9 +396,7 @@ public function mapConditionOperator($operator) { * {@inheritdoc} */ public function prepareStatement(string $query, array $options, bool $allow_row_count = FALSE): StatementInterface { - if (isset($options['return'])) { - @trigger_error('Passing "return" option to ' . __METHOD__ . '() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520', E_USER_DEPRECATED); - } + assert(!isset($options['return']), 'Passing "return" option to prepareStatement() has no effect. See https://www.drupal.org/node/3185520'); try { $query = $this->preprocessStatement($query, $options); @@ -424,42 +408,6 @@ public function prepareStatement(string $query, array $options, bool $allow_row_ return $statement; } - /** - * {@inheritdoc} - */ - public function nextId($existing_id = 0) { - @trigger_error('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); - try { - $this->startTransaction(); - } - catch (\PDOException $e) { - // $this->exceptionHandler()->handleExecutionException() - // requires a $statement argument, so we cannot use that. - throw new DatabaseExceptionWrapper($e->getMessage(), 0, $e); - } - - // We can safely use literal queries here instead of the slower query - // builder because if a given database breaks here then it can simply - // override nextId. However, this is unlikely as we deal with short strings - // and integers and no known databases require special handling for those - // simple cases. If another transaction wants to write the same row, it will - // wait until this transaction commits. - $stmt = $this->prepareStatement('UPDATE {sequences} SET [value] = GREATEST([value], :existing_id) + 1', [], TRUE); - $args = [':existing_id' => $existing_id]; - try { - $stmt->execute($args); - } - catch (\Exception $e) { - $this->exceptionHandler()->handleExecutionException($e, $stmt, $args, []); - } - if ($stmt->rowCount() === 0) { - $this->query('INSERT INTO {sequences} ([value]) VALUES (:existing_id + 1)', $args); - } - // The transaction gets committed when the transaction object gets destroyed - // because it gets out of scope. - return $this->query('SELECT [value] FROM {sequences}')->fetchField(); - } - /** * {@inheritdoc} */ @@ -537,13 +485,6 @@ public function insert($table, array $options = []) { return new Insert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function merge($table, array $options = []) { - return new Merge($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -551,20 +492,6 @@ public function upsert($table, array $options = []) { return new Upsert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function update($table, array $options = []) { - return new Update($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function delete($table, array $options = []) { - return new Delete($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -582,13 +509,6 @@ public function schema() { return $this->schema; } - /** - * {@inheritdoc} - */ - public function condition($conjunction) { - return new Condition($conjunction); - } - /** * {@inheritdoc} */ @@ -596,11 +516,4 @@ protected function driverTransactionManager(): TransactionManagerInterface { return new TransactionManager($this); } - /** - * {@inheritdoc} - */ - public function startTransaction($name = '') { - return $this->transactionManager()->push($name); - } - } diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Delete.php b/core/modules/sqlite/src/Driver/Database/sqlite/Delete.php index bdbe0138e7dfbdf5a109c118d56e1ea89bf3d641..ffc0aa8a7ab01a5b1b7c5ef4df68891d457ad150 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Delete.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Delete.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Delete as QueryDelete; +@trigger_error('Extending from \Drupal\sqlite\Driver\Database\sqlite\Delete is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * SQLite implementation of \Drupal\Core\Database\Query\Delete. */ class Delete extends QueryDelete { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Insert.php b/core/modules/sqlite/src/Driver/Database/sqlite/Insert.php index bcbb6f2bdf0a7a5a8a52a3fa96eefc079ea014a8..301b6e5bb4f436b5d3cd778ff676c5b8395ff790 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Insert.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Insert.php @@ -14,16 +14,6 @@ */ class Insert extends QueryInsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Merge.php b/core/modules/sqlite/src/Driver/Database/sqlite/Merge.php index 377720784f136b20fbcd6b4a391a65ffc8ee477e..0c295d72b83c05937036c2a2200a407b336d84f3 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Merge.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Merge.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Merge as QueryMerge; +@trigger_error('Extending from \Drupal\sqlite\Driver\Database\sqlite\Merge is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * SQLite implementation of \Drupal\Core\Database\Query\Merge. */ class Merge extends QueryMerge { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Select.php b/core/modules/sqlite/src/Driver/Database/sqlite/Select.php index fbd928065cf6bcebf60c05d96b7d6a7c7a89ba21..5ee521af8b22e24b27327b44245449d1b80654a9 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Select.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Select.php @@ -9,16 +9,6 @@ */ class Select extends QuerySelect { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, $table, $alias = NULL, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $alias, $options); - unset($this->queryOptions['return']); - } - public function forUpdate($set = TRUE) { // SQLite does not support FOR UPDATE so nothing to do. return $this; diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php b/core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php index 137e395b03fb6ff0670476d908b991c74b2603b3..f1535fb0196d8e5894b607c581d697d4a5f0518e 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Truncate.php @@ -12,16 +12,6 @@ */ class Truncate extends QueryTruncate { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - public function __toString() { // Create a sanitized comment string to prepend to the query. $comments = $this->connection->makeComment($this->comments); diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Update.php b/core/modules/sqlite/src/Driver/Database/sqlite/Update.php index d101ed384f75809cdd31543ea1557814fac04b7c..0f29cb24d577a5391d0fc1945e8b7a45ac362c81 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Update.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Update.php @@ -4,19 +4,10 @@ use Drupal\Core\Database\Query\Update as QueryUpdate; +@trigger_error('Extending from \Drupal\sqlite\Driver\Database\sqlite\Update is deprecated in drupal:11.0.0 and is removed from drupal:12.0.0. Extend from the base class instead. See https://www.drupal.org/node/3256524', E_USER_DEPRECATED); + /** * SQLite implementation of \Drupal\Core\Database\Query\Update. */ class Update extends QueryUpdate { - - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - } diff --git a/core/modules/sqlite/src/Driver/Database/sqlite/Upsert.php b/core/modules/sqlite/src/Driver/Database/sqlite/Upsert.php index 9e42fcf4baa064aa21eb6fa0371d3321dae06bd7..59974272531008486cb2dcb35e0893954737922c 100644 --- a/core/modules/sqlite/src/Driver/Database/sqlite/Upsert.php +++ b/core/modules/sqlite/src/Driver/Database/sqlite/Upsert.php @@ -11,16 +11,6 @@ */ class Upsert extends QueryUpsert { - /** - * {@inheritdoc} - */ - public function __construct(Connection $connection, string $table, array $options = []) { - // @todo Remove the __construct in Drupal 11. - // @see https://www.drupal.org/project/drupal/issues/3256524 - parent::__construct($connection, $table, $options); - unset($this->queryOptions['return']); - } - /** * {@inheritdoc} */ diff --git a/core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php b/core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php deleted file mode 100644 index 3f415541ba5eda6865085b74735a3a4c61d6b3e1..0000000000000000000000000000000000000000 --- a/core/modules/sqlite/tests/src/Kernel/sqlite/ConnectionTest.php +++ /dev/null @@ -1,26 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\sqlite\Kernel\sqlite; - -use Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase; - -/** - * SQLite-specific connection tests. - * - * @group Database - */ -class ConnectionTest extends DriverSpecificDatabaseTestBase { - - /** - * Tests deprecation of ::makeSequenceName(). - * - * @group legacy - */ - public function testMakeSequenceNameDeprecation(): void { - $this->expectDeprecation("Drupal\\Core\\Database\\Connection::makeSequenceName() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3377046"); - $this->assertIsString($this->connection->makeSequenceName('foo', 'bar')); - } - -} diff --git a/core/modules/sqlite/tests/src/Kernel/sqlite/SqliteDriverLegacyTest.php b/core/modules/sqlite/tests/src/Kernel/sqlite/SqliteDriverLegacyTest.php deleted file mode 100644 index 73f74e6180282d7b7d5df803cc96cff755eae9c2..0000000000000000000000000000000000000000 --- a/core/modules/sqlite/tests/src/Kernel/sqlite/SqliteDriverLegacyTest.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - -namespace Drupal\Tests\sqlite\Kernel\sqlite; - -use Drupal\Core\Database\Driver\sqlite\Connection; -use Drupal\Core\Database\Driver\sqlite\Install\Tasks; -use Drupal\Core\Database\Driver\sqlite\Insert; -use Drupal\Core\Database\Driver\sqlite\Schema; -use Drupal\Core\Database\Driver\sqlite\Select; -use Drupal\Core\Database\Driver\sqlite\Statement; -use Drupal\Core\Database\Driver\sqlite\Truncate; -use Drupal\Core\Database\Driver\sqlite\Upsert; -use Drupal\KernelTests\Core\Database\DriverSpecificDatabaseTestBase; -use Drupal\Tests\Core\Database\Stub\StubPDO; - -/** - * Tests the deprecations of the SQLite database driver classes in Core. - * - * @group legacy - * @group Database - */ -class SqliteDriverLegacyTest extends DriverSpecificDatabaseTestBase { - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Install\Tasks - */ - public function testDeprecationInstallTasks() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Install\Tasks is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $tasks = new Tasks(); - $this->assertInstanceOf(Tasks::class, $tasks); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Connection - */ - public function testDeprecationConnection() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Connection is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $connection = new Connection($this->createMock(StubPDO::class), []); - $this->assertInstanceOf(Connection::class, $connection); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Insert - */ - public function testDeprecationInsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Insert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $insert = new Insert($this->connection, 'test'); - $this->assertInstanceOf(Insert::class, $insert); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Schema - */ - public function testDeprecationSchema() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Schema is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $schema = new Schema($this->connection); - $this->assertInstanceOf(Schema::class, $schema); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Select - */ - public function testDeprecationSelect() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Select is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $select = new Select($this->connection, 'test'); - $this->assertInstanceOf(Select::class, $select); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Statement - */ - public function testDeprecationStatement() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Statement is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $statement = new Statement($this->createMock(StubPDO::class), $this->connection, '', []); - $this->assertInstanceOf(Statement::class, $statement); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Truncate - */ - public function testDeprecationTruncate() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Truncate is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $truncate = new Truncate($this->connection, 'test'); - $this->assertInstanceOf(Truncate::class, $truncate); - } - - /** - * @covers Drupal\Core\Database\Driver\sqlite\Upsert - */ - public function testDeprecationUpsert() { - $this->expectDeprecation('\Drupal\Core\Database\Driver\sqlite\Upsert is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. The SQLite database driver has been moved to the sqlite module. See https://www.drupal.org/node/3129492'); - $upsert = new Upsert($this->connection, 'test'); - $this->assertInstanceOf(Upsert::class, $upsert); - } - -} diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index 87c7b033a71d9427dcdebe748e1f5be7146dad60..ee57eb05b4b071252bac47ffb0b1680b3bb02c58 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -20,15 +20,6 @@ parameters: count: 1 path: includes/form.inc - - - message: """ - #^Call to deprecated method getFromDriverName\\(\\) of class Drupal\\\\Core\\\\Extension\\\\DatabaseDriverList\\: - in drupal\\:10\\.2\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - DatabaseDriverList\\:\\:get\\(\\) instead, passing a database driver namespace\\.$# - """ - count: 1 - path: includes/install.core.inc - - message: "#^Function install_config_download_translations\\(\\) should return string but return statement is missing\\.$#" count: 1 @@ -188,15 +179,6 @@ parameters: count: 1 path: lib/Drupal/Core/Condition/ConditionManager.php - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 4 - path: lib/Drupal/Core/Config/DatabaseStorage.php - - message: "#^Variable \\$value in isset\\(\\) always exists and is not nullable\\.$#" count: 2 @@ -207,120 +189,21 @@ parameters: count: 1 path: lib/Drupal/Core/Config/ExtensionInstallStorage.php - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Connection.php - - - - message: """ - #^Fetching deprecated class constant RETURN_INSERT_ID of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Connection.php - - - - message: """ - #^Fetching deprecated class constant RETURN_NULL of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Connection.php - - - - message: """ - #^Fetching deprecated class constant RETURN_STATEMENT of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 2 - path: lib/Drupal/Core/Database/Connection.php - - message: "#^Variable \\$statement might not be defined\\.$#" count: 1 path: lib/Drupal/Core/Database/Connection.php - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Delete.php - - message: "#^Method Drupal\\\\Core\\\\Database\\\\Query\\\\Delete\\:\\:execute\\(\\) should return int but return statement is missing\\.$#" count: 1 path: lib/Drupal/Core/Database/Query/Delete.php - - - message: """ - #^Fetching deprecated class constant RETURN_INSERT_ID of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Insert.php - - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Merge.php - - message: "#^Method Drupal\\\\Core\\\\Database\\\\Query\\\\Merge\\:\\:__toString\\(\\) should return string but return statement is missing\\.$#" count: 1 path: lib/Drupal/Core/Database/Query/Merge.php - - - message: """ - #^Fetching deprecated class constant RETURN_STATEMENT of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Select.php - - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Truncate.php - - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Update.php - - - - message: """ - #^Fetching deprecated class constant RETURN_AFFECTED of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Database/Query/Upsert.php - - message: "#^Variable \\$affected_rows might not be defined\\.$#" count: 1 @@ -445,15 +328,6 @@ parameters: count: 5 path: lib/Drupal/Core/Entity/Query/Sql/Tables.php - - - message: """ - #^Fetching deprecated class constant RETURN_INSERT_ID of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 2 - path: lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php - - message: "#^Variable \\$revision_query might not be defined\\.$#" count: 2 @@ -634,15 +508,6 @@ parameters: count: 1 path: lib/Drupal/Core/Menu/MenuLinkManager.php - - - message: """ - #^Fetching deprecated class constant RETURN_INSERT_ID of class Drupal\\\\Core\\\\Database\\\\Database\\: - in drupal\\:9\\.4\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is no - replacement\\.$# - """ - count: 1 - path: lib/Drupal/Core/Menu/MenuTreeStorage.php - - message: "#^Variable \\$transaction in isset\\(\\) always exists and is not nullable\\.$#" count: 1 @@ -1484,15 +1349,6 @@ parameters: count: 8 path: modules/migrate_drupal_ui/tests/src/Functional/MultilingualReviewPageTestBase.php - - - message: """ - #^Access to deprecated property \\$needsCleanup of class Drupal\\\\mysql\\\\Driver\\\\Database\\\\mysql\\\\Connection\\: - in drupal\\:10\\.2\\.0 and is removed from drupal\\:11\\.0\\.0\\. There's no - replacement\\.$# - """ - count: 1 - path: modules/mysql/src/Driver/Database/mysql/Connection.php - - message: "#^Variable \\$last_insert_id might not be defined\\.$#" count: 1 @@ -1588,15 +1444,6 @@ parameters: count: 1 path: modules/path/src/Plugin/Field/FieldType/PathItem.php - - - message: """ - #^Call to deprecated method makeSequenceName\\(\\) of class Drupal\\\\Core\\\\Database\\\\Connection\\: - in drupal\\:10\\.2\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is - no replacement\\.$# - """ - count: 1 - path: modules/pgsql/src/Driver/Database/pgsql/Schema.php - - message: "#^Variable \\$table_field might not be defined\\.$#" count: 1 @@ -1607,15 +1454,6 @@ parameters: count: 1 path: modules/pgsql/src/Driver/Database/pgsql/Upsert.php - - - message: """ - #^Call to deprecated method makeSequenceName\\(\\) of class Drupal\\\\Core\\\\Database\\\\Connection\\: - in drupal\\:10\\.2\\.0 and is removed from drupal\\:11\\.0\\.0\\. There is - no replacement\\.$# - """ - count: 1 - path: modules/pgsql/src/Update10101.php - - message: "#^Variable \\$responsive_image_styles in empty\\(\\) always exists and is not falsy\\.$#" count: 1 @@ -2412,22 +2250,6 @@ parameters: count: 2 path: tests/Drupal/KernelTests/Core/Database/DriverSpecificKernelTestBase.php - - - message: """ - #^Call to deprecated method expectError\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: - https\\://github\\.com/sebastianbergmann/phpunit/issues/5062$# - """ - count: 3 - path: tests/Drupal/KernelTests/Core/Database/StatementTest.php - - - - message: """ - #^Call to deprecated method expectErrorMessage\\(\\) of class PHPUnit\\\\Framework\\\\TestCase\\: - https\\://github\\.com/sebastianbergmann/phpunit/issues/5062$# - """ - count: 3 - path: tests/Drupal/KernelTests/Core/Database/StatementTest.php - - message: "#^Variable \\$title might not be defined\\.$#" count: 2 @@ -2617,24 +2439,6 @@ parameters: count: 1 path: tests/Drupal/Tests/Core/Database/ConditionTest.php - - - message: """ - #^Call to deprecated method findCaller\\(\\) of class Drupal\\\\Core\\\\Database\\\\Log\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - Connection\\:\\:findCallerFromDebugBacktrace\\(\\)\\.$# - """ - count: 1 - path: tests/Drupal/Tests/Core/Database/Stub/StubConnection.php - - - - message: """ - #^Fetching class constant class of deprecated class Drupal\\\\Core\\\\Database\\\\StatementWrapper\\: - in drupal\\:10\\.1\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use - \\\\Drupal\\\\Core\\\\Database\\\\StatementWrapperIterator instead\\.$# - """ - count: 1 - path: tests/Drupal/Tests/Core/Database/Stub/StubConnection.php - - message: """ #^Class Drupal\\\\Tests\\\\Core\\\\DependencyInjection\\\\DependencySerializationTestDummy implements deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\: diff --git a/core/tests/Drupal/FunctionalTests/Installer/InstallerDeprecatedDriverNameTest.php b/core/tests/Drupal/FunctionalTests/Installer/InstallerDeprecatedDriverNameTest.php deleted file mode 100644 index 960671162c24e042016ad3c04e52f0214e853ed4..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/FunctionalTests/Installer/InstallerDeprecatedDriverNameTest.php +++ /dev/null @@ -1,54 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\FunctionalTests\Installer; - -use Drupal\Core\Database\Database; -use Drupal\Tests\BrowserTestBase; - -/** - * Tests deprecation of the non-interactive installer with driver name. - * - * @group Installer - * @group legacy - */ -class InstallerDeprecatedDriverNameTest extends BrowserTestBase { - - /** - * {@inheritdoc} - */ - protected $defaultTheme = 'stark'; - - /** - * Execute the non-interactive installer. - * - * @see install_drupal() - */ - protected function doInstall() { - require_once DRUPAL_ROOT . '/core/includes/install.core.inc'; - $parameters = $this->installParameters(); - // Replace the driver namespace with the driver name in the - // 'install_settings_form' parameter. - $driverNamespace = $parameters['forms']['install_settings_form']['driver']; - $driverName = Database::getDriverList()->get($driverNamespace)->getDriverName(); - $parameters['forms']['install_settings_form']['driver'] = $driverName; - $parameters['forms']['install_settings_form'][$driverName] = $parameters['forms']['install_settings_form'][$driverNamespace]; - unset($parameters['forms']['install_settings_form'][$driverNamespace]); - // Simulate a real install which does not start with the any connections set - // in \Drupal\Core\Database\Database::$connections. - Database::removeConnection('default'); - $this->expectDeprecation("Passing a database driver name '{$driverName}' to install_get_form() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Pass a database driver namespace instead. See https://www.drupal.org/node/3258175"); - $this->expectDeprecation('Drupal\\Core\\Extension\\DatabaseDriverList::getFromDriverName() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::get() instead, passing a database driver namespace. See https://www.drupal.org/node/3258175'); - install_drupal($this->classLoader, $parameters); - } - - /** - * Verifies that installation succeeded. - */ - public function testInstaller() { - $this->assertSession()->addressEquals('/'); - $this->assertSession()->statusCodeEquals(200); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php index a7951e25cd67f50f52e7b25e51c7fe4be1bd30f1..11423f0b891009c9a0c8bfbf487ffb6e824c433d 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php @@ -172,16 +172,6 @@ public function testCondition() { $this->assertSame($namespace, get_class($condition)); } - /** - * Tests deprecation of ::getUnprefixedTablesMap(). - * - * @group legacy - */ - public function testDeprecatedGetUnprefixedTablesMap() { - $this->expectDeprecation('Drupal\Core\Database\Connection::getUnprefixedTablesMap() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3257198'); - $this->assertIsArray($this->connection->getUnprefixedTablesMap()); - } - /** * Tests that the method ::hasJson() returns TRUE. */ @@ -189,14 +179,4 @@ public function testHasJson() { $this->assertTrue($this->connection->hasJson()); } - /** - * Tests deprecation of ::tablePrefix(). - * - * @group legacy - */ - public function testDeprecatedTablePrefix(): void { - $this->expectDeprecation('Drupal\Core\Database\Connection::tablePrefix() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Instead, you should just use Connection::getPrefix(). See https://www.drupal.org/node/3260849'); - $this->assertIsString($this->connection->tablePrefix()); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php b/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php deleted file mode 100644 index 7c2cec9505a2506860c5c6243ac317389e57ad41..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Database/DatabaseLegacyTest.php +++ /dev/null @@ -1,29 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Database; - -use Drupal\Core\Database\Database; - -/** - * Legacy database tests. - * - * @group Database - * @group legacy - */ -class DatabaseLegacyTest extends DatabaseTestBase { - - /** - * Tests deprecation of install.inc database driver functions. - */ - public function testDeprecatedInstallFunctions() { - include_once $this->root . '/core/includes/install.inc'; - $this->expectDeprecation('drupal_detect_database_types() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175'); - $this->expectDeprecation('drupal_get_database_types() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175'); - $installableDriverNames = []; - foreach (Database::getDriverList()->getInstallableList() as $driver => $driverExtension) { - $installableDriverNames[$driverExtension->getDriverName()] = $driverExtension->getInstallTasks()->name(); - } - $this->assertEquals($installableDriverNames, drupal_detect_database_types()); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php index e6bb2f0786f731cb6ab9cc9c60726f9313dc5609..7edbc7a9b1ca35fa9d9b7cea0fd8f26d16ab85c6 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php +++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php @@ -8,7 +8,6 @@ use Drupal\Core\Database\Transaction\StackItem; use Drupal\Core\Database\Transaction\StackItemType; use Drupal\Core\Database\Transaction\TransactionManagerBase; -use Drupal\Core\Database\TransactionExplicitCommitNotAllowedException; use Drupal\Core\Database\TransactionNameNonUniqueException; use Drupal\Core\Database\TransactionOutOfOrderException; use PHPUnit\Framework\Error\Warning; @@ -837,48 +836,4 @@ public function testTransactionManagerFailureOnPendingStackItems(): void { Database::closeConnection('test_fail'); } - /** - * Tests deprecation of Connection methods. - * - * @group legacy - */ - public function testConnectionDeprecations(): void { - $this->cleanUp(); - $transaction = $this->connection->startTransaction(); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::transactionDepth() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not access the transaction stack depth, it is an implementation detail. See https://www.drupal.org/node/3381002'); - $this->assertSame(1, $this->connection->transactionDepth()); - $this->insertRow('row'); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::rollBack() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not rollback the connection, roll back the Transaction objects instead. See https://www.drupal.org/node/3381002'); - $this->connection->rollback(); - $transaction = NULL; - $this->assertRowAbsent('row'); - - $this->cleanUp(); - $transaction = $this->connection->startTransaction(); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::addRootTransactionEndCallback() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface::addPostTransactionCallback() instead. See https://www.drupal.org/node/3381002'); - $this->connection->addRootTransactionEndCallback([$this, 'rootTransactionCallback']); - $this->insertRow('row'); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::commit() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Do not commit the connection, void the Transaction objects instead. See https://www.drupal.org/node/3381002'); - try { - $this->connection->commit(); - } - catch (TransactionExplicitCommitNotAllowedException $e) { - // Do nothing. - } - $transaction = NULL; - $this->assertRowPresent('row'); - - $this->cleanUp(); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::pushTransaction() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002'); - $this->connection->pushTransaction('foo'); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::popTransaction() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002'); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::popCommittableTransactions() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002'); - $this->expectDeprecation('Drupal\\Core\\Database\\Connection::doCommit() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use TransactionManagerInterface methods instead. See https://www.drupal.org/node/3381002'); - $this->connection->popTransaction('foo'); - - // Ensure there are no outstanding transactions left. This is necessary for - // the test to pass when xdebug.mode has the 'develop' option enabled. - $this->connection->commitAll(); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php index e4bc165355dc2d1a2039a4c50e16e8d2ebc6fda6..b9c611ccaa427517911bb4ad7e64172f4885fcc3 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/FetchTest.php @@ -115,30 +115,6 @@ public function testQueryFetchObjectClassNoConstructorArgs(): void { $this->assertSame(1, $records); } - /** - * Confirms that we can fetch a record into a new instance of a custom class. - * - * The name of the class is determined from a value of the first column. - * - * @see \Drupal\Tests\system\Functional\Database\FakeRecord - * - * @group legacy - */ - public function testQueryFetchClasstype() { - $this->expectDeprecation('Fetch mode FETCH_CLASS | FETCH_CLASSTYPE is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999'); - $records = []; - $result = $this->connection->query('SELECT [classname], [name], [job] FROM {test_classtype} WHERE [age] = :age', [':age' => 26], ['fetch' => \PDO::FETCH_CLASS | \PDO::FETCH_CLASSTYPE]); - foreach ($result as $record) { - $records[] = $record; - $this->assertInstanceOf(FakeRecord::class, $record); - $this->assertSame('Kay', $record->name); - $this->assertSame('Web Developer', $record->job); - $this->assertFalse(isset($record->classname), 'Classname field not found, as intended.'); - } - - $this->assertCount(1, $records, 'There is only one record.'); - } - /** * Confirms that we can fetch a record into an indexed array explicitly. */ @@ -155,27 +131,6 @@ public function testQueryFetchNum() { $this->assertCount(1, $records, 'There is only one record'); } - /** - * Confirms that we can fetch a record into a doubly-keyed array explicitly. - * - * @group legacy - */ - public function testQueryFetchBoth() { - $this->expectDeprecation('Fetch mode FETCH_BOTH is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999'); - $records = []; - $result = $this->connection->query('SELECT [name] FROM {test} WHERE [age] = :age', [':age' => 25], ['fetch' => \PDO::FETCH_BOTH]); - foreach ($result as $record) { - $records[] = $record; - $this->assertIsArray($record); - $this->assertArrayHasKey(0, $record); - $this->assertSame('John', $record[0]); - $this->assertArrayHasKey('name', $record); - $this->assertSame('John', $record['name']); - } - - $this->assertCount(1, $records, 'There is only one record.'); - } - /** * Confirms that we can fetch all records into an array explicitly. */ diff --git a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php index 438e442bd6933bbd5aa0320ba0db23cbe897abd1..ff1ce670e29efee275cfa2c1aa5d5c8e7a4ce1a0 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php @@ -2,7 +2,6 @@ namespace Drupal\KernelTests\Core\Database; -use Drupal\Core\Database\Log; use Drupal\Core\Database\Database; /** @@ -141,197 +140,4 @@ public function testGetLoggingWrongKey() { $this->assertEquals([], $result, 'The function getLog with a wrong key returns an empty array.'); } - /** - * Tests that a log called by a custom database driver returns proper caller. - * - * @param string $driver_namespace - * The driver namespace to be tested. - * @param string $stack - * A test debug_backtrace stack. - * @param array $expected_entry - * The expected stack entry. - * - * @covers ::findCaller - * - * @dataProvider providerContribDriverLog - * - * @group legacy - */ - public function testContribDriverLog($driver_namespace, $stack, array $expected_entry) { - $this->expectDeprecation('Drupal\Core\Database\Log::findCaller() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::findCallerFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - $this->expectDeprecation('Drupal\Core\Database\Log::removeDatabaseEntries() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::removeDatabaseEntriesFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - - $mock_builder = $this->getMockBuilder(Log::class); - $log = $mock_builder - ->onlyMethods(['getDebugBacktrace']) - ->setConstructorArgs(['test']) - ->getMock(); - $log->expects($this->once()) - ->method('getDebugBacktrace') - ->willReturn($stack); - Database::addConnectionInfo('test', 'default', ['driver' => 'mysql', 'namespace' => $driver_namespace]); - - $result = $log->findCaller($stack); - $this->assertEquals($expected_entry, $result); - } - - /** - * Provides data for the testContribDriverLog test. - * - * @return array[] - * A associative array of simple arrays, each having the following elements: - * - the contrib driver PHP namespace - * - a test debug_backtrace stack - * - the stack entry expected to be returned. - * - * @see ::testContribDriverLog() - */ - public static function providerContribDriverLog() { - $stack = [ - [ - 'file' => '/var/www/core/lib/Drupal/Core/Database/Log.php', - 'line' => 125, - 'function' => 'findCaller', - 'class' => 'Drupal\\Core\\Database\\Log', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/libraries/test/lib/Statement.php', - 'line' => 264, - 'function' => 'log', - 'class' => 'Drupal\\Core\\Database\\Log', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/libraries/test/lib/Connection.php', - 'line' => 213, - 'function' => 'execute', - 'class' => 'Drupal\\Driver\\Database\\dbal\\Statement', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php', - 'line' => 23, - 'function' => 'query', - 'class' => 'Drupal\\Driver\\Database\\dbal\\Connection', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php', - 'line' => 1154, - 'function' => 'testEnableLogging', - 'class' => 'Drupal\\KernelTests\\Core\\Database\\LoggingTest', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php', - 'line' => 842, - 'function' => 'runTest', - 'class' => 'PHPUnit\\Framework\\TestCase', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestResult.php', - 'line' => 693, - 'function' => 'runBare', - 'class' => 'PHPUnit\\Framework\\TestCase', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => '/var/www/vendor/phpunit/phpunit/src/Framework/TestCase.php', - 'line' => 796, - 'function' => 'run', - 'class' => 'PHPUnit\\Framework\\TestResult', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => 'Standard input code', - 'line' => 57, - 'function' => 'run', - 'class' => 'PHPUnit\\Framework\\TestCase', - 'object' => 'test', - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - [ - 'file' => 'Standard input code', - 'line' => 111, - 'function' => '__phpunit_run_isolated_test', - 'args' => [ - 0 => 'test', - ], - ], - ]; - - return [ - // Test that if the driver namespace is in the stack trace, the first - // non-database entry is returned. - 'contrib driver namespace' => [ - 'Drupal\\Driver\\Database\\dbal', - $stack, - [ - 'class' => 'Drupal\\KernelTests\\Core\\Database\\LoggingTest', - 'function' => 'testEnableLogging', - 'file' => '/var/www/core/tests/Drupal/KernelTests/Core/Database/LoggingTest.php', - 'line' => 23, - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - ], - // Extreme case, should not happen at normal runtime - if the driver - // namespace is not in the stack trace, the first entry to a method - // in core database namespace is returned. - 'missing driver namespace' => [ - 'Drupal\\Driver\\Database\\fake', - $stack, - [ - 'class' => 'Drupal\\Driver\\Database\\dbal\\Statement', - 'function' => 'execute', - 'file' => '/var/www/libraries/test/lib/Statement.php', - 'line' => 264, - 'type' => '->', - 'args' => [ - 0 => 'test', - ], - ], - ], - ]; - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php index 853de1e2656050ad2d565db88d8ce1896220d6ed..11b2da2786051e2225b6e89aec24425a87ed20f3 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/MergeTest.php @@ -222,19 +222,4 @@ public function testMergeWithReservedWords() { $this->assertEquals('2', $person->id); } - /** - * Tests deprecation of Merge::key() with array $field argument. - * - * @group legacy - */ - public function testDeprecatedKeyArrayArgument(): void { - $this->expectDeprecation('Passing an array to the $field argument of Drupal\Core\Database\Query\Merge::key() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/2205327'); - $this->connection->merge('select') - ->key(['id' => 2]) - ->execute(); - $person = $this->connection->query('SELECT * FROM {select} WHERE [id] = :id', [':id' => 2])->fetch(); - $this->assertEquals('', $person->update); - $this->assertEquals('2', $person->id); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php b/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php deleted file mode 100644 index fcfff3b9e37be819d26214634992163c8705e4eb..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/KernelTests/Core/Database/NextIdTest.php +++ /dev/null @@ -1,57 +0,0 @@ -<?php - -namespace Drupal\KernelTests\Core\Database; - -/** - * Tests the sequences API. - * - * @group Database - * @group legacy - */ -class NextIdTest extends DatabaseTestBase { - - /** - * The modules to enable. - * - * @var array - */ - protected static $modules = ['database_test', 'system']; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - $table_specification = [ - 'description' => 'Stores IDs.', - 'fields' => [ - 'value' => [ - 'description' => 'The value of the sequence.', - 'type' => 'serial', - 'unsigned' => TRUE, - 'not null' => TRUE, - ], - ], - 'primary key' => ['value'], - ]; - $this->connection->schema()->createTable('sequences', $table_specification); - } - - /** - * Tests that the sequences API works. - */ - public function testDbNextId() { - $this->expectDeprecation('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345'); - - $first = $this->connection->nextId(); - $second = $this->connection->nextId(); - // We can test for exact increase in here because we know there is no - // other process operating on these tables -- normally we could only - // expect $second > $first. - $this->assertEquals($first + 1, $second, 'The second call from a sequence provides a number increased by one.'); - $result = $this->connection->nextId(1000); - $this->assertEquals(1001, $result, 'Sequence provides a larger number than the existing ID.'); - } - -} diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php index d5b6c9e865de86bddd5c402d7175d8baaaaa4f07..86f4e8b2c2acd0e2099803bc04aaa7c06a71684b 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php @@ -2,12 +2,8 @@ namespace Drupal\KernelTests\Core\Database; -use Drupal\Core\Database\Database; - -// cSpell:ignore aquery aprepare - /** - * Tests Drupal's extended prepared statement syntax.. + * Tests Drupal's extended prepared statement syntax. * * @coversDefaultClass \Drupal\Core\Database\Connection * @group Database @@ -165,22 +161,4 @@ public function testQuotingIdentifiers() { $this->assertEquals('Update value 1', $result->update); } - /** - * Tests deprecation of the 'return' query option. - * - * @covers ::query - * @covers ::prepareStatement - * - * @group legacy - */ - public function testReturnOptionDeprecation() { - $this->expectDeprecation('Passing "return" option to %Aquery() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520'); - $this->expectDeprecation('Passing "return" option to %AprepareStatement() is deprecated in drupal:9.4.0 and is removed in drupal:11.0.0. For data manipulation operations, use dynamic queries instead. See https://www.drupal.org/node/3185520'); - $this->assertIsInt((int) $this->connection->query('INSERT INTO {test} ([name], [age], [job]) VALUES (:name, :age, :job)', [ - ':name' => 'Magoo', - ':age' => 56, - ':job' => 'Driver', - ], ['return' => Database::RETURN_INSERT_ID])); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php index 256da561a17e7aca9cc20bc6389bf7558033ede6..dcf10f29935186514c4d48827789d7e7a44874e5 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/SelectTest.php @@ -627,18 +627,4 @@ public function testNonArrayOperatorWithArrayValueCondition($operator, $operator ->execute(); } - /** - * Tests thrown exception for non array operator conditions with array value. - * - * @dataProvider providerNonArrayOperatorWithArrayValueCondition - * @group legacy - */ - public function testNonArrayOperatorWithArrayValueConditionDeprecated($operator, $operator_in_exception_message) { - $this->expectDeprecation('Calling Drupal\Core\Database\Query\Condition::condition() without an array compatible operator is deprecated in drupal:10.1.0 and will be required in drupal:11.0.0. See https://www.drupal.org/node/3350985'); - $this->connection->select('test', 't') - ->fields('t') - ->condition('age', [26], $operator) - ->execute(); - } - } diff --git a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php index fb16e6e72b2cdbadde5a99026e9e5bc69e5125c8..d09c83d49e3745c14c1620d5fdaab74c2a15873a 100644 --- a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php +++ b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php @@ -2,6 +2,7 @@ namespace Drupal\KernelTests\Core\Database; +use Drupal\Core\Database\DatabaseExceptionWrapper; use Drupal\Core\Database\StatementInterface; /** @@ -168,8 +169,8 @@ public function testStatementRewind(): void { } // Trying to iterate through the same statement again should fail. - $this->expectError(); - $this->expectErrorMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); + $this->expectException(DatabaseExceptionWrapper::class); + $this->expectExceptionMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); foreach ($statement as $row) { $this->assertNotNull($row); } @@ -204,8 +205,8 @@ public function testStatementCountTwice(): void { $rowCount = iterator_count($statement); $this->assertSame(4, $rowCount); - $this->expectError(); - $this->expectErrorMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); + $this->expectException(DatabaseExceptionWrapper::class); + $this->expectExceptionMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); $rowCount = iterator_count($statement); } @@ -242,8 +243,8 @@ public function testStatementForeachTwice(): void { // Restart iterating through the same statement. The foreach loop will try // rewinding the statement which should fail, and the counter should not be // increased. - $this->expectError(); - $this->expectErrorMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); + $this->expectException(DatabaseExceptionWrapper::class); + $this->expectExceptionMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.'); foreach ($statement as $row) { // No-op. } diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php index 38e0f199c6896fc558ece327b238f4f0337b620b..fc3a4ddb51909adcd3a4c5fb0523dda67d10928d 100644 --- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php +++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php @@ -6,7 +6,6 @@ use Composer\Autoload\ClassLoader; use Drupal\Core\Database\Database; -use Drupal\Core\Database\StatementPrefetch; use Drupal\Core\Database\StatementPrefetchIterator; use Drupal\Tests\Core\Database\Stub\StubConnection; use Drupal\Tests\Core\Database\Stub\StubPDO; @@ -26,7 +25,7 @@ class ConnectionTest extends UnitTestCase { * @return array * Array of arrays with the following elements: * - Arguments to pass to Connection::setPrefix(). - * - Expected result from Connection::tablePrefix(). + * - Expected result from Connection::getPrefix(). */ public static function providerPrefixRoundTrip() { return [ @@ -47,7 +46,7 @@ public static function providerPrefixRoundTrip() { } /** - * Exercise setPrefix() and tablePrefix(). + * Exercise setPrefix() and getPrefix(). * * @dataProvider providerPrefixRoundTrip */ @@ -340,7 +339,7 @@ public function testGetDriverClass($expected, $namespace, $class) { 'Truncate', 'Schema', 'Condition', - 'Transaction' => $this->expectDeprecation('Calling Drupal\\Core\\Database\\Connection::getDriverClass() for \'' . $class . '\' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use standard autoloading in the methods that return database operations. See https://www.drupal.org/node/3217534'), + 'Transaction' => $this->expectExceptionMessage('Calling Drupal\\Core\\Database\\Connection::getDriverClass() for \'' . $class . '\' is not supported. Use standard autoloading in the methods that return database operations. See https://www.drupal.org/node/3217534'), default => NULL, }; $this->assertEquals($expected, $connection->getDriverClass($class)); @@ -883,32 +882,6 @@ public static function providerMockedBacktrace(): array { ]; } - /** - * Tests deprecation of the StatementWrapper class. - * - * @group legacy - */ - public function testStatementWrapperDeprecation() { - $this->expectDeprecation('\\Drupal\\Core\\Database\\StatementWrapper is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \\Drupal\\Core\\Database\\StatementWrapperIterator instead. See https://www.drupal.org/node/3265938'); - $mock_pdo = $this->createMock(StubPDO::class); - $connection = new StubConnection($mock_pdo, []); - $this->expectError(); - $connection->prepareStatement('boing', []); - } - - /** - * Tests deprecation of the StatementPrefetch class. - * - * @group legacy - */ - public function testStatementPrefetchDeprecation() { - $this->expectDeprecation('\\Drupal\\Core\\Database\\StatementPrefetch is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use \Drupal\Core\Database\StatementPrefetchIterator instead. See https://www.drupal.org/node/3265938'); - $mockPdo = $this->createMock(StubPDO::class); - $mockConnection = new StubConnection($mockPdo, []); - $statement = new StatementPrefetch($mockPdo, $mockConnection, ''); - $this->assertInstanceOf(StatementPrefetch::class, $statement); - } - /** * Provides data for testSupportedFetchModes. * @@ -942,14 +915,14 @@ public function testSupportedFetchModes(int $mode): void { } /** - * Provides data for testDeprecatedFetchModes. + * Provides data for testUnsupportedFetchModes. * * @return array * An associative array of simple arrays, each having the following * elements: * - a PDO fetch mode. */ - public static function providerDeprecatedFetchModes(): array { + public static function providerUnsupportedFetchModes(): array { return [ 'FETCH_DEFAULT' => [\PDO::FETCH_DEFAULT], 'FETCH_LAZY' => [\PDO::FETCH_LAZY], @@ -964,17 +937,13 @@ public static function providerDeprecatedFetchModes(): array { } /** - * Tests deprecated fetch modes. - * - * @todo in drupal:11.0.0, do not remove this test but convert it to expect - * exceptions instead of deprecations. - * - * @dataProvider providerDeprecatedFetchModes + * Tests unsupported fetch modes. * - * @group legacy + * @dataProvider providerUnsupportedFetchModes */ - public function testDeprecatedFetchModes(int $mode): void { - $this->expectDeprecation('Fetch mode %A is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use supported modes only. See https://www.drupal.org/node/3377999'); + public function testUnsupportedFetchModes(int $mode): void { + $this->expectException(\AssertionError::class); + $this->expectExceptionMessageMatches("/^Fetch mode FETCH_.* is not supported\\. Use supported modes only/"); $mockPdo = $this->createMock(StubPDO::class); $mockConnection = new StubConnection($mockPdo, []); $statement = new StatementPrefetchIterator($mockPdo, $mockConnection, ''); diff --git a/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php b/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php deleted file mode 100644 index 87a62f9026a21d9531f82c1cbcfb341b1d5db196..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/Database/DatabaseTest.php +++ /dev/null @@ -1,151 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\Core\Database; - -use Composer\Autoload\ClassLoader; -use Drupal\Core\Cache\NullBackend; -use Drupal\Core\Database\Database; -use Drupal\Core\Extension\DatabaseDriverList; -use Drupal\Core\Extension\Exception\UnknownExtensionException; -use Drupal\Tests\UnitTestCase; -use Symfony\Component\DependencyInjection\ContainerInterface; - -/** - * @coversDefaultClass \Drupal\Core\Database\Database - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - * - * @group Database - */ -class DatabaseTest extends UnitTestCase { - - /** - * A classloader to enable testing of contrib drivers. - * - * @var \Composer\Autoload\ClassLoader - */ - protected $additionalClassloader; - - /** - * Path to DRUPAL_ROOT. - * - * @var string - */ - protected $root; - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - - $this->additionalClassloader = new ClassLoader(); - $this->additionalClassloader->register(); - // Mock the container so we don't need to mock drupal_valid_test_ua(). - // @see \Drupal\Core\Extension\ExtensionDiscovery::scan() - $this->root = dirname(__DIR__, 6); - $databaseDriverList = new DatabaseDriverList($this->root, 'database_driver', new NullBackend('database_driver')); - $container = $this->createMock(ContainerInterface::class); - $container->expects($this->any()) - ->method('has') - ->willReturnMap([ - ['kernel', TRUE], - ['extension.list.database_driver', TRUE], - ]); - $container->expects($this->any()) - ->method('get') - ->with('extension.list.database_driver') - ->willReturn($databaseDriverList); - $container->expects($this->any()) - ->method('getParameter') - ->with('site.path') - ->willReturn(''); - \Drupal::setContainer($container); - } - - /** - * @covers ::findDriverAutoloadDirectory - * @dataProvider providerFindDriverAutoloadDirectory - * @group legacy - */ - public function testFindDriverAutoloadDirectory($expected, $namespace, $include_test_drivers) { - $this->expectDeprecation('Drupal\Core\Database\Database::findDriverAutoloadDirectory() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175'); - // The only module that provides a driver in core is a test module. - if (!$expected) { - $this->expectException(UnknownExtensionException::class); - Database::findDriverAutoloadDirectory($namespace, $this->root, $include_test_drivers); - } - else { - $this->assertSame($expected, Database::findDriverAutoloadDirectory($namespace, $this->root, $include_test_drivers)); - } - } - - /** - * Data provider for ::testFindDriverAutoloadDirectory(). - * - * @return array - */ - public static function providerFindDriverAutoloadDirectory() { - return [ - 'core mysql' => ['core/modules/mysql/src/Driver/Database/mysql/', 'Drupal\mysql\Driver\Database\mysql', FALSE], - 'D8 custom fake' => [FALSE, 'Drupal\Driver\Database\CoreFake', TRUE], - 'module mysql' => ['core/modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql/', 'Drupal\driver_test\Driver\Database\DrivertestMysql', TRUE], - ]; - } - - /** - * @covers ::findDriverAutoloadDirectory - * @dataProvider providerFindDriverAutoloadDirectoryException - * @group legacy - */ - public function testFindDriverAutoloadDirectoryException($expected_message, $namespace, $include_tests) { - $this->expectDeprecation('Drupal\Core\Database\Database::findDriverAutoloadDirectory() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Use DatabaseDriverList::getList() instead. See https://www.drupal.org/node/3258175'); - $this->expectException(UnknownExtensionException::class); - $this->expectExceptionMessage($expected_message); - Database::findDriverAutoloadDirectory($namespace, $this->root, $include_tests); - } - - /** - * Data provider for ::testFindDriverAutoloadDirectoryException(). - * - * @return array - */ - public static function providerFindDriverAutoloadDirectoryException() { - return [ - 'test module but tests not included' => [ - "The database_driver Drupal\driver_test\Driver\Database\DrivertestMysql does not exist.", - 'Drupal\driver_test\Driver\Database\DrivertestMysql', - FALSE, - ], - 'non-existent driver in test module' => [ - "The database_driver Drupal\driver_test\Driver\Database\sqlite does not exist.", - 'Drupal\driver_test\Driver\Database\sqlite', - TRUE, - ], - 'non-existent module' => [ - "The database_driver Drupal\does_not_exist\Driver\Database\mysql does not exist.", - 'Drupal\does_not_exist\Driver\Database\mysql', - TRUE, - ], - ]; - } - - /** - * Adds a database driver that uses the D8's Drupal\Driver\Database namespace. - */ - protected function addD8CustomDrivers() { - $this->additionalClassloader->addPsr4("Drupal\\Driver\\Database\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/custom/CoreFake"); - } - - /** - * Adds database drivers that are provided by modules. - */ - protected function addModuleDrivers() { - $this->additionalClassloader->addPsr4("Drupal\\driver_test\\Driver\\Database\\DrivertestMysql\\", __DIR__ . "/../../../../../modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql"); - $this->additionalClassloader->addPsr4("Drupal\\CoreFake\\Driver\\Database\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/module/core_fake/src/Driver/Database/CoreFake"); - } - -} diff --git a/core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php b/core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php deleted file mode 100644 index 85ee0d5fd7c0212d955668bdbf4a751198b0e32b..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/Database/InstallerObjectTest.php +++ /dev/null @@ -1,80 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\Core\Database; - -use Composer\Autoload\ClassLoader; -use Drupal\mysql\Driver\Database\mysql\Install\Tasks as MysqlInstallTasks; -use Drupal\Driver\Database\fake\Install\Tasks as FakeInstallTasks; -use Drupal\Driver\Database\CoreFake\Install\Tasks as CustomCoreFakeInstallTasks; -use Drupal\driver_test\Driver\Database\DrivertestMysql\Install\Tasks as DriverTestMysqlInstallTasks; -use Drupal\Tests\UnitTestCase; - -/** - * Tests the db_installer_object() function that is used during installation. - * - * These tests run in isolation to prevent the autoloader additions from - * affecting other tests. - * - * @covers ::db_installer_object - * - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - * - * @group Database - * @group legacy - */ -class InstallerObjectTest extends UnitTestCase { - - /** - * {@inheritdoc} - */ - protected function setUp(): void { - parent::setUp(); - require_once __DIR__ . '/../../../../../includes/install.inc'; - $additional_class_loader = new ClassLoader(); - $additional_class_loader->addPsr4("Drupal\\Driver\\Database\\fake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/custom/fake"); - $additional_class_loader->addPsr4("Drupal\\Core\\Database\\Driver\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/core/CoreFake"); - $additional_class_loader->addPsr4("Drupal\\Driver\\Database\\CoreFake\\", __DIR__ . "/../../../../../tests/fixtures/database_drivers/custom/CoreFake"); - $additional_class_loader->addPsr4("Drupal\\driver_test\\Driver\\Database\\DrivertestMysql\\", __DIR__ . "/../../../../../../modules/system/tests/modules/driver_test/src/Driver/Database/DrivertestMysql"); - $additional_class_loader->register(TRUE); - } - - /** - * @dataProvider providerDbInstallerObject - */ - public function testDbInstallerObject($driver, $namespace, $expected_class_name) { - $this->expectDeprecation('db_installer_object() is deprecated in drupal:10.0.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3256641'); - $object = db_installer_object($driver, $namespace); - $this->assertEquals(get_class($object), $expected_class_name); - } - - /** - * Data provider for testDbUrlToConnectionConversion(). - * - * @return array - * Array of arrays with the following elements: - * - driver: The driver name. - * - namespace: The namespace providing the driver. - * - class: The fully qualified class name of the expected install task. - */ - public static function providerDbInstallerObject() { - return [ - // A driver only in the core namespace. - ['mysql', "Drupal\\mysql\\Driver\\Database\\mysql", MysqlInstallTasks::class], - - // A driver only in the custom namespace. - // @phpstan-ignore-next-line - ['fake', "Drupal\\Driver\\Database\\fake", FakeInstallTasks::class], - - // A driver in both namespaces. The custom one takes precedence. - // @phpstan-ignore-next-line - ['CoreFake', "Drupal\\Driver\\Database\\CoreFake", CustomCoreFakeInstallTasks::class], - - // A driver from a module that has a different name as the driver. - ['DrivertestMysql', "Drupal\\driver_test\\Driver\\Database\\DrivertestMysql", DriverTestMysqlInstallTasks::class], - ]; - } - -} diff --git a/core/tests/Drupal/Tests/Core/Database/LogTest.php b/core/tests/Drupal/Tests/Core/Database/LogTest.php deleted file mode 100644 index 5d592cd48b8100a4ab5f892c9c2f8df732f0f6e1..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Tests/Core/Database/LogTest.php +++ /dev/null @@ -1,64 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Drupal\Tests\Core\Database; - -use Drupal\Core\Database\Database; -use Drupal\Core\Database\Log; -use Drupal\Tests\Core\Database\Stub\StubConnection; -use Drupal\Tests\Core\Database\Stub\StubPDO; -use Drupal\Tests\UnitTestCase; - -/** - * Tests the Log class. - * - * @group Database - * @group legacy - * @runTestsInSeparateProcesses - * @preserveGlobalState disabled - * @coversDefaultClass \Drupal\Core\Database\Log - */ -class LogTest extends UnitTestCase { - - /** - * Tests that a log called by a custom database driver returns proper caller. - * - * @covers ::findCaller - */ - public function testContribDriverLog() { - Database::addConnectionInfo('default', 'default', [ - 'driver' => 'test', - 'namespace' => 'Drupal\Tests\Core\Database\Stub', - ]); - - $this->expectDeprecation('Drupal\Core\Database\Log::findCaller() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::findCallerFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - $this->expectDeprecation('Drupal\Core\Database\Log::getDebugBacktrace() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3328053'); - $this->expectDeprecation('Drupal\Core\Database\Log::removeDatabaseEntries() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::removeDatabaseEntriesFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - $pdo = $this->prophesize(StubPDO::class)->reveal(); - $result = (new StubConnection($pdo, []))->testLogCaller(); - $this->assertSame([ - 'file' => __FILE__, - 'line' => 39, - 'function' => 'testContribDriverLog', - 'class' => 'Drupal\Tests\Core\Database\LogTest', - 'type' => '->', - 'args' => [], - ], $result); - - // Test calling the database log from outside of database code. - $this->expectDeprecation('Drupal\Core\Database\Log::findCaller() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::findCallerFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - $this->expectDeprecation('Drupal\Core\Database\Log::getDebugBacktrace() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3328053'); - $this->expectDeprecation('Drupal\Core\Database\Log::removeDatabaseEntries() is deprecated in drupal:10.1.0 and is removed from drupal:11.0.0. Use Connection::removeDatabaseEntriesFromDebugBacktrace(). See https://www.drupal.org/node/3328053'); - $result = (new Log())->findCaller(); - $this->assertSame([ - 'file' => __FILE__, - 'line' => 53, - 'function' => 'testContribDriverLog', - 'class' => 'Drupal\Tests\Core\Database\LogTest', - 'type' => '->', - 'args' => [], - ], $result); - } - -} diff --git a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php b/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php index fbc02bdb88099bb9fac1540a8d3c55bd0913de64..4b31c06c2e6711c2d92eea1932feb03eea283400 100644 --- a/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php +++ b/core/tests/Drupal/Tests/Core/Database/Stub/StubConnection.php @@ -7,14 +7,7 @@ use Drupal\Core\Database\Connection; use Drupal\Core\Database\ExceptionHandler; use Drupal\Core\Database\Log; -use Drupal\Core\Database\Query\Delete; -use Drupal\Core\Database\Query\Insert; -use Drupal\Core\Database\Query\Merge; -use Drupal\Core\Database\Query\Select; -use Drupal\Core\Database\Query\Truncate; -use Drupal\Core\Database\Query\Update; -use Drupal\Core\Database\StatementWrapper; -use Drupal\Core\Database\Transaction; +use Drupal\Core\Database\StatementWrapperIterator; use Drupal\Tests\Core\Database\Stub\Driver\Schema; /** @@ -27,7 +20,7 @@ class StubConnection extends Connection { /** * {@inheritdoc} */ - protected $statementWrapperClass = StatementWrapper::class; + protected $statementWrapperClass = StatementWrapperIterator::class; /** * Public property so we can test driver loading mechanism. @@ -92,14 +85,6 @@ public function mapConditionOperator($operator) { return NULL; } - /** - * {@inheritdoc} - */ - public function nextId($existing_id = 0) { - @trigger_error('Drupal\Core\Database\Connection::nextId() is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. Modules should use instead the keyvalue storage for the last used id. See https://www.drupal.org/node/3349345', E_USER_DEPRECATED); - return 0; - } - /** * Helper method to test database classes are not included in backtraces. * @@ -117,27 +102,6 @@ public function exceptionHandler() { return new ExceptionHandler(); } - /** - * {@inheritdoc} - */ - public function select($table, $alias = NULL, array $options = []) { - return new Select($this, $table, $alias, $options); - } - - /** - * {@inheritdoc} - */ - public function insert($table, array $options = []) { - return new Insert($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function merge($table, array $options = []) { - return new Merge($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -145,27 +109,6 @@ public function upsert($table, array $options = []) { return new StubUpsert($this, $table, $options); } - /** - * {@inheritdoc} - */ - public function update($table, array $options = []) { - return new Update($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function delete($table, array $options = []) { - return new Delete($this, $table, $options); - } - - /** - * {@inheritdoc} - */ - public function truncate($table, array $options = []) { - return new Truncate($this, $table, $options); - } - /** * {@inheritdoc} */ @@ -183,11 +126,4 @@ public function condition($conjunction) { return new StubCondition($conjunction); } - /** - * {@inheritdoc} - */ - public function startTransaction($name = '') { - return new Transaction($this, $name); - } - }