Skip to content

Commit

Permalink
Allow using PDO-only fetch modes for now
Browse files Browse the repository at this point in the history
Other drivers (including the cache) never supported fetch modes that are
not listed in `FetchMode`. Converting between the contants is only done
for PDO, so BC only needs to be restored here. PDO will validate the
fetch mode, we don’t have to.
  • Loading branch information
corphi authored and Majkl578 committed Apr 7, 2018
1 parent 9beff5e commit 78abf39
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/Doctrine/DBAL/Driver/PDOStatement.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType;
use PDO;
use const E_USER_DEPRECATED;
use function sprintf;
use function trigger_error;

/**
* The PDO implementation of the Statement interface.
Expand Down Expand Up @@ -231,7 +234,14 @@ private function convertFetchMode(?int $fetchMode) : ?int
}

if (! isset(self::FETCH_MODE_MAP[$fetchMode])) {
throw new \InvalidArgumentException('Invalid fetch mode: ' . $fetchMode);
// TODO: next major: throw an exception
@trigger_error(sprintf(
'Using a PDO fetch mode or their combination (%d given)' .
' is deprecated and will cause an error in Doctrine 3.0',
$fetchMode
), E_USER_DEPRECATED);

return $fetchMode;
}

return self::FETCH_MODE_MAP[$fetchMode];
Expand Down

0 comments on commit 78abf39

Please sign in to comment.