Issue #3200708 by Taran2L, mcdruid, Fabianx: [PHP 8] Error: User-supplied statement does not accept constructor arguments in PDO->prepare()

merge-requests/361/head
mcdruid 2021-03-30 13:41:10 +01:00
parent 0f08b887c3
commit da838de720
2 changed files with 13 additions and 3 deletions

View File

@ -1744,12 +1744,16 @@ abstract class Database {
*
* @param $key
* The connection key.
* @param $close
* Whether to close the connection.
* @return
* TRUE in case of success, FALSE otherwise.
*/
final public static function removeConnection($key) {
final public static function removeConnection($key, $close = TRUE) {
if (isset(self::$databaseInfo[$key])) {
self::closeConnection(NULL, $key);
if ($close) {
self::closeConnection(NULL, $key);
}
unset(self::$databaseInfo[$key]);
return TRUE;
}

View File

@ -1690,8 +1690,14 @@ class DrupalWebTestCase extends DrupalTestCase {
$this->fail('Failed to drop all prefixed tables.');
}
// In PHP 8 some tests encounter problems when shutdown code tries to
// access the database connection after it's been explicitly closed, for
// example the destructor of DrupalCacheArray. We avoid this by not fully
// destroying the test database connection.
$close = \PHP_VERSION_ID < 80000;
// Get back to the original connection.
Database::removeConnection('default');
Database::removeConnection('default', $close);
Database::renameConnection('simpletest_original_default', 'default');
// Restore original shutdown callbacks array to prevent original