Unverified Commit 0c74527d authored by Marco Pivetta's avatar Marco Pivetta Committed by GitHub

Merge pull request #2950 from Majkl578/remove-quirks

Removed pre-7.1 quirks
parents 5e9cdb40 3366dfd4
...@@ -244,16 +244,7 @@ final class DriverManager ...@@ -244,16 +244,7 @@ final class DriverManager
// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
$url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']); $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']);
// PHP < 5.4.8 doesn't parse schemeless urls properly.
// See: https://php.net/parse-url#refsect1-function.parse-url-changelog
if (PHP_VERSION_ID < 50408 && strpos($url, '//') === 0) {
$url = parse_url('fake:' . $url);
unset($url['scheme']);
} else {
$url = parse_url($url); $url = parse_url($url);
}
if ($url === false) { if ($url === false) {
throw new DBALException('Malformed parameter "url".'); throw new DBALException('Malformed parameter "url".');
......
...@@ -49,7 +49,7 @@ class JsonType extends Type ...@@ -49,7 +49,7 @@ class JsonType extends Type
$encoded = json_encode($value); $encoded = json_encode($value);
if (JSON_ERROR_NONE !== json_last_error()) { if (JSON_ERROR_NONE !== json_last_error()) {
throw ConversionException::conversionFailedSerialization($value, 'json', $this->getLastErrorMessage()); throw ConversionException::conversionFailedSerialization($value, 'json', json_last_error_msg());
} }
return $encoded; return $encoded;
...@@ -92,44 +92,4 @@ class JsonType extends Type ...@@ -92,44 +92,4 @@ class JsonType extends Type
{ {
return ! $platform->hasNativeJsonType(); return ! $platform->hasNativeJsonType();
} }
/**
* Get the latest json error message
*
* This method declaration has been extracted from symfony's php 5.5 polyfill
*
* @link https://github.com/symfony/polyfill-php55/blob/master/Php55.php
* @link http://nl1.php.net/manual/en/function.json-last-error-msg.php
*
* @return string
*/
private function getLastErrorMessage()
{
if (function_exists('json_last_error_msg')) {
return json_last_error_msg();
}
switch (json_last_error()) {
case JSON_ERROR_NONE:
return 'No error';
case JSON_ERROR_DEPTH:
return 'Maximum stack depth exceeded';
case JSON_ERROR_STATE_MISMATCH:
return 'State mismatch (invalid or malformed JSON)';
case JSON_ERROR_CTRL_CHAR:
return 'Control character error, possibly incorrectly encoded';
case JSON_ERROR_SYNTAX:
return 'Syntax error';
case JSON_ERROR_UTF8:
return 'Malformed UTF-8 characters, possibly incorrectly encoded';
default:
return 'Unknown error';
}
}
} }
...@@ -206,10 +206,6 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -206,10 +206,6 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testTransactionalWithThrowable() public function testTransactionalWithThrowable()
{ {
if (version_compare(PHP_VERSION, '7.0', '<')) {
$this->markTestSkipped('Only for PHP 7.0 and above.');
}
try { try {
$this->_conn->transactional(function($conn) { $this->_conn->transactional(function($conn) {
/* @var $conn \Doctrine\DBAL\Connection */ /* @var $conn \Doctrine\DBAL\Connection */
......
...@@ -34,12 +34,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -34,12 +34,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
if ($this->running) { if ($this->running) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should
// be used instead. so should only it be set when it is supported.
if (PHP_VERSION_ID < 50600) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, false);
}
} }
parent::tearDown(); parent::tearDown();
...@@ -71,12 +65,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -71,12 +65,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should
// be used instead. so should only it be set when it is supported.
if (PHP_VERSION_ID < 50600) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true);
}
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
$stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)'); $stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)');
...@@ -101,12 +89,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -101,12 +89,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
) { ) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should
// be used instead. so should only it be set when it is supported.
if (PHP_VERSION_ID < 50600) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true);
}
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)'); $stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
...@@ -131,12 +113,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -131,12 +113,6 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
) { ) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true); $this->_conn->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
// PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT is deprecated in php 5.6. PDO::ATTR_EMULATE_PREPARES should
// be used instead. so should only it be set when it is supported.
if (PHP_VERSION_ID < 50600) {
$this->_conn->getWrappedConnection()->setAttribute(PDO::PGSQL_ATTR_DISABLE_NATIVE_PREPARED_STATEMENT, true);
}
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)'); $stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment