Fix for TypeError: count() in webservices when running PHP 8.x #40610
Merged
obuisard merged 8 commits intojoomla:4.3-devfrom Jul 20, 2023
Merged
Fix for TypeError: count() in webservices when running PHP 8.x #40610obuisard merged 8 commits intojoomla:4.3-devfrom
obuisard merged 8 commits intojoomla:4.3-devfrom
Conversation
Occurs when using webservices API calls involving groups
wilsonge
requested changes
May 16, 2023
Contributor
wilsonge
left a comment
There was a problem hiding this comment.
Something looks wrong here. We call count within that function (unless we return null from the early bail
)But in that case we should be checking for parts being null. because getting the 0th element on the line 244 of null also makes no sense
Contributor
Author
|
Yes OK - then we do not need to do a count again. I was just focusing on the part throwing the error... - and the section is not optional but mandatory |
… into WebservicesGroupIssue
Contributor
Contributor
Contributor
|
tested |
Contributor
|
I have tested this item ✅ successfully on 0110c19 This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/40610. |
Member
wilsonge
approved these changes
May 22, 2023
Member
|
The change looks ok, but I'm wondering why the context there is null? |
wilsonge
reviewed
May 23, 2023
Contributor
|
Thank you Martin @MacJoom for the PR! |
GeraintEdwards
pushed a commit
to GeraintEdwards/joomla-cms
that referenced
this pull request
Aug 14, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


The error occurs when doing webservices API POST call to /fields/groups/contacts/contact or /fields/groups/content/articles
Pull Request for Issue # .
Summary of Changes
Is_array test before doing count() - not needed FieldsHelper::extract returns null if there are not two parts
Testing Instructions
Code review -
or do test the webservices test with Postman and the collection from here:
https://github.com/alexandreelise/j4x-api-collection
Actual result BEFORE applying this Pull Request
TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/clients/client2/web3/web/joomla-cms/administrator/components/com_fields/src/Model/GroupModel.php:247 etc.
Expected result AFTER applying this Pull Request
No Error, Item is added
Link to documentations
Please select:
Documentation link for docs.joomla.org:
[x ] No documentation changes for docs.joomla.org needed
Pull Request link for manual.joomla.org:
[x ] No documentation changes for manual.joomla.org needed