-
Notifications
You must be signed in to change notification settings - Fork 179
Default Statement::bindParam $length to 0, as using null causes a deprecation with PHP8+ #613
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
Conversation
…t that correct length is used if defined
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking the time to contribute this change! Besides adding an entry to the CHANGELOG, I just have a doubt about why the current solution does not work: if you call bindParam
with up to 3 params, the array_slice
should return an empty array
, and the same thing should happen here. As a consequence of this, PHP should fallback to the default value for the $length
param 🤔
We don't run Sentry on our dev environments, and we have been unable to replicate this issue without Sentry enabled. I'm not sure why the DBAL PDOStatement is working fine but the Sentry TracingStatementv2 isn't. I haven't done any in-depth exploration, but it appears to me that the default |
@ste93cry I deleted my previous comment as it was wrong. Here's an example showing how the explicit null triggers the deprecation, but not providing the param doesn't: https://3v4l.org/biaIs#v8.1.4. I'm still not sure why the deprecation is being triggered in Sentry. |
Can we add a unit test to trigger the deprecation in our CI? Or is it already there, and then why it's not failing? |
That's the expected behaviour. If you explicitly pass |
@ste93cry My point was that the explicit null triggers the deprecation, when not using Sentry, so it's not a side-effect of the code.
that's the line that our last deprecation was triggered on, we don't tend to even use the type. |
Sorry for being silent. I reproduced the issue locally, and I found out that the problem originates from here. Basically, since the statement is wrapped by our |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took the time to finish your work, hopefully you don't mind. Thank you for your contribution, I will release the fix in the next days
When using PHP8+ with Doctrine DBALv2 and calling
PDOStatement::bindParam()
with just 2 params causes a deprecation for passing null to an int param. The default in PDO is0
, so this change defaults to 0 when calling the decorated statement.Fixes #611