Skip to content
Snippets Groups Projects
Commit 800e6381 authored by Beakerboy's avatar Beakerboy
Browse files

Issue #3210240: Fatal error: Uncaught Error: Non-static method PDO::__construct()

parent 9e8e2aef
No related branches found
Tags 7.x-2.7
No related merge requests found
......@@ -141,8 +141,12 @@ class DatabaseConnection_sqlsrv extends DatabaseConnection {
// Initialize and prepare the connection prefix.
$this->setPrefix(isset($this->connectionOptions['prefix']) ? $this->connectionOptions['prefix'] : '');
// Call PDO::__construct and PDO::setAttribute.
PDO::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
// Drupal 7.79 removed PDO as the parent of DatabaseConnection
if (VERSION <= 7.78) {
PDO::__construct($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
} else {
$this->connection = new PDO($dsn, $connection_options['username'], $connection_options['password'], $connection_options['pdo']);
}
}
/**
......@@ -777,7 +781,12 @@ class DatabaseConnection_sqlsrv extends DatabaseConnection {
$rolled_back_other_active_savepoints = TRUE;
}
}
\PDO::rollBack();
// Drupal 7.79 removed PDO as the parent of DatabaseConnection
if (VERSION <= 7.78) {
PDO::rollback();
} else {
$this->connection->rollback();
}
// Restore original transaction isolation level
if ($level = static::DefaultTransactionIsolationLevelInStatement()) {
if($savepoint['settings']->Get_IsolationLevel() != DatabaseTransactionIsolationLevel::Ignore()) {
......@@ -840,7 +849,12 @@ class DatabaseConnection_sqlsrv extends DatabaseConnection {
foreach($this->statement_cache as $statement) {
$statement->closeCursor();
}
\PDO::beginTransaction();
// Drupal 7.79 removed PDO as the parent of DatabaseConnection
if (VERSION <= 7.78) {
PDO::beginTransaction();
} else {
$this->connection->beginTransaction();
}
}
// Store the name and settings in the stack.
$this->transactionLayers[$name] = array('settings' => $settings, 'active' => TRUE, 'name' => $name, 'started' => $started);
......@@ -893,7 +907,13 @@ class DatabaseConnection_sqlsrv extends DatabaseConnection {
if (empty($this->transactionLayers)) {
try {
// PDO::commit() can either return FALSE or throw an exception itself
if (!PDO::commit()) {
// Drupal 7.79 removed PDO as the parent of DatabaseConnection
if (VERSION <= 7.78) {
$commit_check = PDO::commit();
} else {
$commit_check = $this->connection->commit();
}
if (!$commit_check) {
throw new DatabaseTransactionCommitFailedException();
}
}
......@@ -1106,4 +1126,4 @@ class DatabaseStatement_sqlsrv extends DatabaseStatementBase implements Database
/**
* @} End of "ingroup database".
*/
\ No newline at end of file
*/
......@@ -3,7 +3,7 @@
include_once 'fastcache.inc';
/**
* @filefe
* @file
* Database schema code for Microsoft SQL Server database servers.
*/
......@@ -137,7 +137,9 @@ class DatabaseSchema_sqlsrv extends DatabaseSchema {
// No worry for the tableExists() check, results
// are cached.
if (empty($table) || !$this->tableExists($table)) {
// This fails with drupal > v7.78
//if (empty($table) || !$this->tableExists($table)) {
if (!$this->tableExists($table)) {
throw new DatabaseSchemaObjectDoesNotExistException("The table '{$table}' does not exist.");
}
......@@ -378,6 +380,9 @@ class DatabaseSchema_sqlsrv extends DatabaseSchema {
* True if the table exists, false otherwise.
*/
public function tableExists($table, $reset = FALSE) {
if (empty($table)) {
return FALSE;
}
// Do not cache temporary tables (#)
if (!$reset && $table[0] != '#' && $cache = fastcache::cache_get($table, 'tableExists')) {
return $cache->data;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment