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
Correction of wrong parameter types in exception handling #1915
Conversation
@hajoseng, all three of the exceptions referenced in this PR extend PHP's base |
@demiankatz I've just realized the websites shows "Internal Server Error" while there's no error not within the apache log. The error within the vufind log is: 2021-04-13T13:04:46+02:00 DEBUG (7): PAIAplus\ILS\Driver\PAIA: HTTP status 403 received Having a closer look the error seems to be rather a wrong parameter (empty string instead of long integer als second parameter) than a wrong parameter count. So the default - having no error code - shouldn't be '' but rather a number (probably 0). |
PS: Ignore PAIAplus; it's only a wrapper for our special PAIA setting. |
Yes, @hajoseng, I believe you are right, and it's the default value that is causing the problem. If you revert to the original code, and then change In any case, thanks for finding this issue! |
@demiankatz Yes this fixes the issue; I've just committet an update. I'm using php 7.4. I'm going to search for more of these issues and come back with my results. |
Thanks, @hajoseng, I have renamed this PR to reflect the slight change in the solution to the problem. Is it safe to assume that $array['code'] will always contain an integer, or should we add the In any case, please let me know when you are ready for me to merge this. For now, I will wait until I hear back from you, in case you decide to add more fixes to this PR. Thanks again! |
I've looked through the entire code; there are only two other objects passing a second parameter to the Exception Object. One using a hardcoded 0 the other one passing an original http status code. I think there's nothing more to do and the pr can be merged. |
@hajoseng, I really appreciate the help reviewing the code! I've made one minor edit to add parentheses around the expression being typecast. In PHP, typecasting has a higher precedence than null coalescing, so without the extra parentheses, you would probably get error messages in situations where 'code' was not set. I'm pretty confident it's safe to merge now, so I'm going to go ahead -- but please let me know if I've somehow introduced a problem. |
I've also backported this to the release-7.1 branch, since it qualifies as a bug fix. |
In three cases an exception is thrown by using two parameters while the exception object accepts only one. This causes an internal server error when one of these exceptions is thrown.