Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore PDOStatement::quote() for backward compatibility #4287

Merged
merged 1 commit into from
Sep 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/Doctrine/DBAL/Driver/PDOConnection.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Doctrine\DBAL\Driver\Connection as ConnectionInterface;
use Doctrine\DBAL\Driver\PDO\Exception;
use Doctrine\DBAL\Driver\PDO\Statement;
use Doctrine\DBAL\ParameterType;
use PDO;
use PDOException;
use PDOStatement;
Expand Down Expand Up @@ -101,6 +102,14 @@ public function query()
}
}

/**
* {@inheritdoc}
*/
public function quote($value, $type = ParameterType::STRING)
{
return parent::quote($value, $type);
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 5 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@
<exclude-pattern>lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php</exclude-pattern>
</rule>

<!-- The override opts out the caller from the strict mode for backward compatibility -->
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod.Found">
<exclude-pattern>lib/Doctrine/DBAL/Driver/PDOConnection.php</exclude-pattern>
</rule>

<!-- See https://github.com/slevomat/coding-standard/issues/770 -->
<rule ref="SlevomatCodingStandard.Namespaces.UnusedUses">
<exclude-pattern>lib/Doctrine/DBAL/Driver/ExceptionConverterDriver.php</exclude-pattern>
Expand Down
10 changes: 10 additions & 0 deletions tests/Doctrine/Tests/DBAL/Functional/Driver/PDO/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace Doctrine\Tests\DBAL\Functional\Driver\PDO;

use Doctrine\DBAL\Driver\PDO\Connection;
Expand Down Expand Up @@ -100,4 +102,12 @@ public function testThrowsWrappedExceptionOnQuery(): void

$this->driverConnection->query('foo');
}

/**
* This test ensures backward compatibility with DBAL 2.x and should be removed in 3.0.
*/
public function testQuoteInteger(): void
{
self::assertSame("'1'", $this->connection->getWrappedConnection()->quote(1));
}
}