Description
Environment
How do you use Sentry?
Sentry SaaS (sentry.io)
Which SDK and version?
sentry/sentry-symfony 4.2.7 with Doctrine DBAL 2.13.8
Steps to Reproduce
Call PDOStatement bindParam with only 2 params:
$statement = $this->connection->prepare('...');
$statement->bindParam(':param1', $values['param1']);
Expected Result
No exception triggered
Actual Result
ErrorException: Deprecated: PDOStatement::bindParam(): Passing null to parameter #4 ($maxLength) of type int is deprecated
PR #586 "fixed" this issue already, but it's still broken when using DBALv2.
In particular, if only 2 arguments are passed to the method, then the \array_slice(\func_get_args(), 3)
code will return an empty array, which results in null
being used for $length
as it's the default. In DBALv2, https://github.com/doctrine/dbal/blob/2.13.8/lib/Doctrine/DBAL/Driver/PDO/Statement.php simply extends PDOStatement, with no additional functionality. So there's nothing to catch the null $length
and convert it to 0 (the default in PDO), as was done in DBALv3.
The solution would be implementing a similar code change as DBALv3 does:
public function bindParam($param, &$variable, $type = ParameterType::STRING, $length = null): bool
{
return $this->decoratedStatement->bindParam($param, $variable, $type, $length ?? 0, ...\array_slice(\func_get_args(), 4));
}