-
Notifications
You must be signed in to change notification settings - Fork 11k
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
[10.x] Ignore MSSQL exception about PDO::ATTR_STRINGIFY_FETCHES #48158
Conversation
I just noticed there's a draft PR from @crynobone to ignore the MSSQL suite temporarily. That might be a better approach than changing the connector code here... |
It is better to let @taylorotwell decide on this. There are pros and cons to both solutions |
Can someone explain the pros / cons? 😅 Mark as ready for review when done. |
From what I understand reading the threads linked, a change was made in This should be handled in the next release/hotfix of the Perhaps @SakiTakamachi can add more context to this. I couldn't find the commit in |
Hi. I'm probably one of the most knowledgeable on this subject. First, let me explain how this issue came about. Last month I made a modification in php-src, including PDO Core, to fix mysql behavior. As for the C language, the change was to pass the The PDO driver just returns false on failure of However, only PDO SQLSRV, managed outside of php-src, was implemented with its own design that instead throws an exception when it should return false. Of the 16 PDO drivers provided by PECL, only SQLSRV causes problems. I submitted a monchy patch to PDO SQLSRV and it was merged into the development branch. But the PDO SQLSRV lead didn't want to solve this problem on the PDO SQLSRV side. We are currently urging Microsoft to release the hotfix as soon as possible, but the lead has not yet responded and there is no change in the situation. |
Now let's talk technically about the problem. The error is on the driver side of SQLSRV. After the PDO core accepts the attribute value, it passes it to the SQLSRV driver. The SQLSRV driver should have returned false, but it throws an error. This error is triggered by receiving an unsupported attribute value, so you can safely ignore it by swallowing it with a try catch. Alternatively, you can set PDO's error mode to silent mode just before calling |
In any case, I can assure you that the error is not caused by something broken internally and can be safely ignored. |
Thanks for the context @SakiTakamachi. Marking this as ready for review so @taylorotwell can check it again. |
For your reference. Changes of PDO Core: Where the exception occurs in PDO SQLSRV: At first glance, it looks like the exception is caught, but actually this code is executed before that and the exception is raised: |
I have read the contents of this PR. Adopting this PR will allow Laravel's CI to PASS, allowing users to avoid errors caused by SQLSRV in later versions of Laravel. If you adopt another PR, Laravel's CI tests will pass. No monkey patches remain in the source code. |
Originally, I planned to submit a PR to Laravel for the contents of this Laravel library. https://github.com/SakiTakamachi/laravel-sqlsrv-err-avoid However, since the content is nothing more than a temporary adhesive bandage, there is a history of providing it as a library. |
If you provide a temporary bandage, the problem arises of when to remove the bandage, if a hotfix for SQLSRV is released. My library explicitly states that the repository will be deleted 6 months after a hotfix release. I personally think that if Laravel itself provides a bandage, it should be carefully considered when to remove it. |
I wrote a lot of long sentences, but that's it. |
@SakiTakamachi when the MSSQL PDO driver releases the hotfix, we should be able to remove the changes here, no? Or do you mean we may need to keep the changes if we want to support the affected versions of |
This means that not everyone updates their drivers immediately after they are released. On the other hand, in most environments you should be able to update Laravel freely even if you can't update the driver freely. Then there will be users who use Laravel with the bandage removed, even though the drivers are still outdated. There is an option to not change versions of Laravel, but when critical security updates are made, not being able to use the new version is a disadvantage for users. On the other hand, I don't think it's a good idea to leave the bandage on forever, so what I wanted to say is to discuss how to remove the bandage in advance. |
Also, while we know exactly what the issue is, we can't expect everyone to have the same level of understanding. If this PR is adopted and ostensibly solves the problem, many users may mistake it for a permanent solution. In that sense, it is only a temporary measure, and I think it would be better if there was some way to encourage drivers to update as soon as they are released. Otherwise, ignorance can damage Laravel's reputation. |
If there is a third option, it is to provide functions like my library as a separate repository/package like However, I don't know much about Laravel's policy, so I'm sorry if this is an irrelevant suggestion. |
Yeah, I understand what you mean. I don't usually add external packages to fix core issues. In this case, the problem is at the extension level, which is odd. I don't think we should merge this anymore. At this point, I'd recommend folks patching their apps internally until the fix is released at the extension. The I am closing this PR for now. But feel free to re-open it and merge if y'all think it's worth it. |
Hi. I would like to inform you that a hotfix has been released! |
@SakiTakamachi Thank you for the heads up. Not sure why, but the tests are still failing. Maybe the GitHub action doesn't have the hotfix yet? #48343 |
Looking at the execution log of github actions, it seems that it's using PDO SQLSRV The one it should use is The My prediction was correct. |
shivammathur/setup-php#766 should fix that. |
setup-php v2.26.0 now loads the latests version of the extension on supported PHP versions. |
Fixed
PDO::ATTR_STRINGIFY_FETCHES
. Something changed in the extension and this attribute now triggers an exception. This wasn't the case before, so I think we can ignore the exception when setting that attribute until there's a release/hotfix.Here's the comment I left in another PR for context:
An alternative solution would be to remove that attribute from the list of
$options
in theSqlServerConnector
class.Hat tip to @SakiTakamachi for the implementation here.