Skip to content

Commit

Permalink
Merge pull request #4287 from morozov/issues/4281
Browse files Browse the repository at this point in the history
Restore PDOStatement::quote() for backward compatibility
  • Loading branch information
greg0ire authored Sep 24, 2020
2 parents b9cb735 + 8557a32 commit 6ff72e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
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));
}
}

0 comments on commit 6ff72e4

Please sign in to comment.