-
Notifications
You must be signed in to change notification settings - Fork 347
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
Properly fix "Trying to access array offset on value of type bool" #1319
Properly fix "Trying to access array offset on value of type bool" #1319
Conversation
Since php74, we must properly ensure that array is not null/false before checking any of its column ranges This properly fixes the "Trying to access array offset on value of type bool" when no time range is specified to filter our calendar events. It also preserves the accurate filtering query when time range is specified
This should properly fix the error caused by more strict php code checks on null/false arrays
It fixes the root cause of the error: ensure $timeRange != NULL before checking I tested it and sync is now properly working when no time range was specified to filter calendar events |
Codecov Report
@@ Coverage Diff @@
## master #1319 +/- ##
=========================================
Coverage 97.12% 97.12%
- Complexity 2775 2784 +9
=========================================
Files 174 174
Lines 8025 8038 +13
=========================================
+ Hits 7794 7807 +13
Misses 231 231
Continue to review full report at Codecov.
|
@PhilZ-cwm6 thanks for this. It is good to have someone who has tested this in "real life". It would be good to also have unit tests that cover combinations of time-range specifications. See 8eb1f08 Can you cherry-pick that commit into your PR? (or add unit tests yourself) |
@phil-davis
I was confident as these settings worked properly in php prior to 7.4. So I knew, the core code was working on these time ranges. The patch I committed is a proper php syntax fix that should be merged in anycase. It just ensures $timeRange is not null/false before checking its array columns. This is now enforced since php74 it seems About test unit: I can try it. However, can you just point me on how to test it in a non production environement/calendar ? Please provide a step by step command line tests you want me to do so that they are reproductible for you and I am sure I properly test the situations you want Best regards |
In your local git clone you can get the code in my fork also:
Then you will have local access to my commit that has the unit tests, and can cherry-pick that:
And just push up to GitHub, where the full suite of tests will run:
I fully expect that those will pass with your code. In my PR I made a slightly different approach to the logic, but your fix is fine and has the same effect. |
As I said, the change I did should be merged whatever is the test unit result. It is a code syntax error fix. It restores the original behavior of advanced filters when time ranges are specified as it was before php74. It was just a missing null check on the array. I will push to the test unit in 1-2 days hopefully best regards |
634fe06
to
b04269f
Compare
I agree that the code change is "a good thing". It is nice to get the related unit tests merged in the same PR. I added the unit tests and they had some fails. I added some more code to check if Now the tests are failing further down the code in I can keep chasing those in a while. |
Thank you, I see better now your patch Exp: Wired because it works with php74, so I guess php8 enforces further null checks or just my real life tests di not reach that part of the code In anycase, it looks easier to fix with your test unit as I cannot reproduce in real life |
@staabm @ByteHamster in this PR we are in the rabbit-hole finding all the places that make reference to the time-range The other approach was in PR #1275 - If Which approach do you want to take - one of these, or something else? |
I understand. Sorry, pushed a commit that was just a sample to explain my thinking, not a mature code I did not write php since years, so I have to rebuild a local debug environment before starting to submit more complex changes to test them before pushing. Not sure I have time for it right now. |
The latest change looks good - it clearly handles processing "start" and "end" in CalendarQueryValidator. The unit tests might cover cases that "ordinary" calendar clients do not actually send in real life, but are theoretically possible to receive. It is a bit hard to test every case in real-life! CI is passing 🚀 I requested a few reviewers. It would be good to get some fix merged and a patch release "real soon" (tm) |
Oh, nice, I really pushed it on a hurry and couldn't compile it locally |
I committed another check for the prop-filters |
Looking at the sources using search in code for all However, what do you think about using
Edited: |
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.
I have no relevant opinion on this change, as I don't know the details involved.
Phil, please decide at the best of your knowledge.
About my last suggestion: Since the tests pass, the code doesn't cause issue now, so maybe it can be merged if reviewed ok. |
For this fix we just want to avoid PHP 7.4 and 8.0 complaining about trying to access an array key that does not exist. If someone sends the empty string, or So I agree that we can merge this to fix the actual problem with some real-life clients. |
Sorry, I just missed the merge by a few seconds :) Looks good to me (and more clean than #1275). Thanks for fixing! |
Since php74, we must properly ensure that array is not null/false before checking any of its column ranges
This properly fixes the "Trying to access array offset on value of type bool" when no time range is specified to filter our calendar events. It also preserves the accurate filtering query when time range is specified