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 PHP deprecation errors - Issue #13270 #13615
Conversation
Thanks for the PR @markusVJH and welcome to the community! I've just set the tests running 🚀 |
@markusVJH could you check out the failing tests please, let us know if you need any help! |
Thank you! I will check the failing tests today. |
Added the change for the CS Fixer job 👍 For the codecov test I am not sure what to do. Based on Slack messages I found it looks like re-running the job might fix it? |
Thanks @markusVJH - we have had some issues with Codecov as they deprecated an older version which we were running in favour of the GitHub app - should be all fixed now I've merged in the latest changes. Would you be able to rebase this onto the 5.x branch if possible? We're about to release 5.1 so we should be able to get this into that, or the next patch release. |
Thank you for the reply, I did later find that a lot of PRs were having the same issue 🙏 I will try to do the rebase 👍 |
Rebased to 5.x! Thank you @escopecz for the advice Hopefully the tests will pass |
The tests don't want to kick off. I'll close and reopen the PR. It usually fixes it. |
Co-authored-by: John Linhart <jan@linhart.email>
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.
Thanks! The code change looks good to me 👍
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 5.x #13615 +/- ##
============================================
- Coverage 61.50% 61.50% -0.01%
- Complexity 34067 34068 +1
============================================
Files 2241 2241
Lines 101850 101852 +2
============================================
Hits 62646 62646
- Misses 39204 39206 +2
|
Hi @markusVJH I am trying to reproduce this before testing the PR but I am struggling - neither locally with DDEV or on Gitpod can I see those errors. I see plenty of other deprecation warnings in my DDEV logs, but not this one. Any chance it was fixed somewhere else? |
Hi @RCheesley ! Sorry the late reply, I was away :s We had this error showing up in the logs after a new Mautic installation for production. I was asked if I wanted to try to make a pr that would fix it from happening. I struggled to repeat the error locally, but I added that testing guidance where $origin can be forced to be null in order test the errors coming up like we had in the production, and then test how the fix would remove them even if $origin were to be null. Is this ok? |
If @escopecz thinks it's a good addition then it's fine with me - I just wasn't able to do the user testing as I couldn't reproduce the bug in the first place ;) |
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.
This cannot hurt anything. It happens only if the Origin
header in the request is missing.
My previous suggestion to change return false
to return null
was wrong as it's in a callback function, not the return of the method itself. But null
is evaluated by PHP as false so it has no functional effect. So let's keep it as is.
Description:
When visiting the login page, the logs could have these deprecation notices:
This PR implements a simple fix proposed by @J-Wick4, where the variable $origin (which is passed as parameter 2 mentioned in the error message) is checked whether it is null before calling fnmatch(). If $origin is null, false is returned, and the function continues as before. This fixes the error messages.
Steps to test this PR:
If testing locally with docker, you can keep eyes on the logs through Docker.
If testing on GitPod through browser, you can check the 'Problems' tab to see if the deprecated notice is there (expected string, found null).
If testing with GitPod but not through browser, you can run
ddev logs
in the ide terminal to see the logs.If you want to first see the error messages, and then see the effect of the solution:
Open this PR on Gitpod or pull down for testing locally (see docs on testing PRs here)
Replace function getAllowOriginHeaderValue(Request $request) with the following version. It makes sure the $origin is null and that the fnmatch is called in order to replicate the situation people were having with the deprecation notices in logs. in CORSMiddleware.php:
Add the previous test code, go to the log in page, and refresh the page. Now the error messages should show in the logs (Either the 'Problems' tab in the GitPod browser,
ddev logs
result in ide terminal or logs through Docker).Then to see the error messages fixed with the new solution, add the following code, refresh the log in page and check that the deprecation notice no longer appears: