Skip to content

Commit

Permalink
Merge pull request #2950 from Majkl578/remove-quirks
Browse files Browse the repository at this point in the history
Removed pre-7.1 quirks
  • Loading branch information
Ocramius committed Dec 24, 2017
2 parents 5e9cdb4 + 3366dfd commit 0c74527
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 79 deletions.
11 changes: 1 addition & 10 deletions lib/Doctrine/DBAL/DriverManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,16 +244,7 @@ private static function parseDatabaseUrl(array $params): array

// (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid
$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) {
throw new DBALException('Malformed parameter "url".');
Expand Down
42 changes: 1 addition & 41 deletions lib/Doctrine/DBAL/Types/JsonType.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function convertToDatabaseValue($value, AbstractPlatform $platform)
$encoded = json_encode($value);

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;
Expand Down Expand Up @@ -92,44 +92,4 @@ public function requiresSQLCommentHint(AbstractPlatform $platform)
{
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';
}
}
}
4 changes: 0 additions & 4 deletions tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,6 @@ public function testTransactionalWithException()

public function testTransactionalWithThrowable()
{
if (version_compare(PHP_VERSION, '7.0', '<')) {
$this->markTestSkipped('Only for PHP 7.0 and above.');
}

try {
$this->_conn->transactional(function($conn) {
/* @var $conn \Doctrine\DBAL\Connection */
Expand Down
24 changes: 0 additions & 24 deletions tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ protected function tearDown()
{
if ($this->running) {
$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();
Expand Down Expand Up @@ -71,12 +65,6 @@ public function testBooleanConversionBoolParamEmulatedPrepares()
{
$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();

$stmt = $this->_conn->prepare('INSERT INTO dbal630 (bool_col) VALUES(?)');
Expand All @@ -101,12 +89,6 @@ public function testBooleanConversionNullParamEmulatedPrepares(
) {
$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();

$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
Expand All @@ -131,12 +113,6 @@ public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInB
) {
$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();

$stmt = $this->_conn->prepare('INSERT INTO dbal630_allow_nulls (bool_col) VALUES(?)');
Expand Down

0 comments on commit 0c74527

Please sign in to comment.