-
Notifications
You must be signed in to change notification settings - Fork 78
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
Deprecated: preg_match() Passing null in getClientIp() #177
Comments
Thank you. It looks like It needs to skip the regex check if the IP address is already null, or is not a string. |
Strange thing is, this wasn't the result of running tests. This happened in production. |
Just checked the core and I completely forgot that it is the application that supplies the IP address. I'm guessing your application isn't providing the client IP. A quick workaround would be to pass in anything that is not a valid IPv4 and not a null. An empty string would work.
Just for some background, what the regex does, is to make sure the IP address is IPv4, and blanks it out if it isn't. Sage Pay would error (last I checked) if the IP was not in the The error is a PHP 8.1 deprecation warning being converted into an exception in your application (or maybe these are just beig displayed as warnings?). Another workaround would be to catch and log those, but not convert them into an exception (or not display the warnings). Laravel can do this with the deprecation log (very handy) and your framework may do something similar. |
Not sure if relevant, but I'm using the server integration and ClientIPAddress isn't a thing so I would have no need to set this. I think my PR still stands. |
Yeah, PR looks good. It was PHP 8.1 that has brought this deprecation notice - what you are [not] setting is good too. I was just trying to think of a quick workaround that would fix the problem for you. |
Also if |
I don't think I can assist with refactoring that. I believe a lot of the Server code extends the Direct code? There is a lot that's set in |
np - thanks again - I've merged and made a patch release. |
I'm seeing this on PHP 8.1 using v4:
Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated
Coming from here (
omnipay/sagepay/src/Message/DirectAuthorizeRequest.php in Omnipay\SagePay\Message\DirectAuthorizeRequest::getClientIp at line 138
)I'm not sure why the IP can be
null
at that point, but here we are.The text was updated successfully, but these errors were encountered: