-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Fix persistent procedural ODBC connections not getting closed #12096
Conversation
FWIW it seems this was broken in f4cfaf3, which refactored |
Can you please add a test as well? |
Looking at it, I'm not sure how to test it. When you do |
I think it's enough to only restrict yourself to MS SQL, since that's the only driver we test in CI. I recently added many tests for ext/odbc, and I managed to come up with this skipif for MSSQL specific tests:
But of course However, I'm wondering if you could exploit the bug by inserting a new connection into the same hash key (https://github.com/php/php-src/blob/master/ext/odbc/php_odbc.c#L2205) as a closed one used to have, in which case, ODBC tries to reuse the connection. Is this behavior possible to make use of? |
I'm writing a test with SQL Server's
I'm not sure here. FWIW finding this bug was motivated by if you have a wedged persistent connection, |
Just note as this is a bug fix it should target the PHP-8.1 branch |
f6f6c25
to
da7a66d
Compare
Incredibly great. I rebased and force pushed and now GitHub thinks there's no changes at all and automatically closed the PR. |
I think you should set the target branch to PHP-8.1 too |
Never mind, the rebase didn't happen on my local 8.1 based branch, after manually cherry picking, GH-12132 should be this PR, but for 8.1. I still have no idea why this PR is fouled up even after pushing the original branch back to it, but the new PR is targetting the right branch for a bug fix, so 🤷 |
Like oci8, procedural ODBC uses an apply function on the hash list to enumerate persistent connections and close the specific one. However, this function take zvals, not resources. However, it was getting casted as such, causing it to interpret the pointer incorrectly. This could have caused other issues, but mostly manifested as failing to close the connection even fi it matched.
The function now takes a zval and gets the resource from that. In addition, it also removes the cast of the function pointer and moves casting to the function body, to avoid possible confusion like this in refactors again. It also cleans up style and uses constants in the function body.