NEW: Deprecated PDO in favour of native drivers (#9052)

NEW: Deprecated PDO in favour of native drivers
This commit is contained in:
Guy Marriott 2019-07-08 12:41:13 +12:00 committed by GitHub
commit ec66d366d2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 19 deletions

View File

@ -4,24 +4,6 @@
use SilverStripe\Dev\Install\DatabaseAdapterRegistry;
use SilverStripe\Dev\Install\MySQLDatabaseConfigurationHelper;
// Register MySQL PDO as a database adapter (listed as first option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register(
array(
/** @skipUpgrade */
'class' => 'MySQLPDODatabase',
'module' => 'framework',
'title' => 'MySQL 5.0+ (using PDO)',
'helperPath' => __DIR__ . '/src/Dev/Install/MySQLDatabaseConfigurationHelper.php',
'helperClass' => MySQLDatabaseConfigurationHelper::class,
'supported' => (class_exists('PDO') && in_array('mysql', PDO::getAvailableDrivers())),
'missingExtensionText' =>
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">MySQL PDO Driver</a>
are unavailable. Please install or enable these and refresh this page.'
)
);
// Register MySQLi as a database adapter (listed as second option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register(
array(
@ -37,3 +19,20 @@ DatabaseAdapterRegistry::register(
PHP extension is not available. Please install or enable it and refresh this page.'
)
);
// Register MySQL PDO as a database adapter (listed as first option in Dev/Install/config-form.html)
DatabaseAdapterRegistry::register(
array(
/** @skipUpgrade */
'class' => 'MySQLPDODatabase',
'module' => 'framework',
'title' => 'MySQL 5.0+ (using PDO) - <b>not recommended</b>',
'helperPath' => __DIR__ . '/src/Dev/Install/MySQLDatabaseConfigurationHelper.php',
'helperClass' => MySQLDatabaseConfigurationHelper::class,
'supported' => (class_exists('PDO') && in_array('mysql', PDO::getAvailableDrivers())),
'missingExtensionText' =>
'Either the <a href="http://www.php.net/manual/en/book.pdo.php">PDO Extension</a> or
the <a href="http://www.php.net/manual/en/ref.pdo-mysql.php">MySQL PDO Driver</a>
are unavailable. Please install or enable these and refresh this page.'
)
);

View File

@ -20,8 +20,8 @@ class InstallConfig
* @var array
*/
protected $preferredDatabases = [
'MySQLPDODatabase',
'MySQLDatabase',
'MySQLPDODatabase',
];
public function __construct($basePath = null)

View File

@ -3,6 +3,7 @@
namespace SilverStripe\ORM\Connect;
use SilverStripe\Core\Config\Config;
use SilverStripe\Dev\Deprecation;
use PDO;
use PDOStatement;
use InvalidArgumentException;
@ -135,6 +136,9 @@ class PDOConnector extends DBConnector implements TransactionManager
public function connect($parameters, $selectDB = false)
{
Deprecation::notice('4.5', 'Use native database drivers in favour of PDO. '
. 'https://github.com/silverstripe/silverstripe-framework/issues/8598');
$this->flushStatements();
// Note that we don't select the database here until explicitly