Add check for empty search result
Fixes array accessor error for #2721
Does not fix the underlying issue of empty contacts when social data should be accessible.
Codecov Report
Merging #2736 (3a0b600) into main (53390f4) will increase coverage by
0.07%. The diff coverage is100.00%.
@@ Coverage Diff @@
## main #2736 +/- ##
============================================
+ Coverage 18.04% 18.12% +0.07%
Complexity 247 247
============================================
Files 97 97
Lines 3170 3173 +3
Branches 439 439
============================================
+ Hits 572 575 +3
Misses 2405 2405
Partials 193 193
| Impacted Files | Coverage Ξ | |
|---|---|---|
| lib/Service/SocialApiService.php | 90.72% <100.00%> (+0.18%) |
:arrow_up: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Ξ = absolute <relative> (impact),ΓΈ = not affected,? = missing dataPowered by Codecov. Last update 53390f4...3a0b600. Read the comment docs.
Hi @miaulalala and thank you so much for helping out! Concerning your proposal, I am afraid suppressing the error messages is only fighting the symptoms. We need to find out why the update is not working for some users anymore.
As stated above, I am not happy with this solution.
Can we find a compromise to at least print out a dedicated warning message when the UID is not found?
When a user wishes to update a contact and the function returns a precondition failed, it is not good. It just hides the problem, as a precondition failed in this function means that the contact does not have any social data. But in fact, this seems to be triggered for all contacts in certain setups and makes the update for all disfunctional. At best, I would like to find out how this can ever happen and eliminate the root of the issue.
As stated above, I am not happy with this solution. Can we find a compromise to at least print out a dedicated warning message when the UID is not found? When a user wishes to update a contact and the function returns a
precondition failed, it is not good. It just hides the problem, as aprecondition failedin this function means that the contact does not have any social data. But in fact, this seems to be triggered for all contacts in certain setups and makes the update for all disfunctional. At best, I would like to find out how this can ever happen and eliminate the root of the issue.
Right, I agree, if there is an underlying problem with the social API this of course should also be fixed. Doesn't change the fact that using an array accessor without checking if the array isn't empty is bad practice and should be avoided. I can add some logging to inform the user :v:
Superseded by https://github.com/nextcloud/contacts/pull/2869