PHP 8.x bug ? PR-4.3-dev Pending

User tests: Successful: Unsuccessful:

avatar MacJoom
MacJoom
16 May 2023

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

avatar joomla-cms-bot joomla-cms-bot - change - 16 May 2023
Category Administration com_fields
avatar MacJoom MacJoom - open - 16 May 2023
avatar MacJoom MacJoom - change - 16 May 2023
Status New Pending
avatar MacJoom MacJoom - change - 16 May 2023
Labels Added: PR-4.3-dev
avatar MacJoom MacJoom - change - 16 May 2023
Title
Fix for TypeError: count() when running PHP 8.x
Fix for TypeError: count() in webservices when running PHP 8.x
avatar MacJoom MacJoom - edited - 16 May 2023
avatar MacJoom
MacJoom - comment - 16 May 2023

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

avatar MacJoom MacJoom - change - 16 May 2023
The description was changed
avatar MacJoom MacJoom - edited - 16 May 2023
avatar alikon
alikon - comment - 19 May 2023

i've got a different error with postman without your PR

PHP Warning: Trying to access array offset on value of type null in /joomla-cms/administrator/components/com_fields/src/Model/GroupModel.php on line 244

image

avatar alikon
alikon - comment - 19 May 2023

btw applying the pr no more error

image

avatar alikon
alikon - comment - 19 May 2023

tested fields/groups/contacts/contact too

avatar alikon alikon - test_item - 19 May 2023 - Tested successfully
avatar alikon
alikon - comment - 19 May 2023

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.

avatar richard67
richard67 - comment - 21 May 2023

@wilsonge Could you check and if ok add an approval with the review button so GitHub doesn’t show the unresolved review anymore? As far as I can see @MacJoom has solved your concerns.

avatar MacJoom MacJoom - change - 22 May 2023
Labels Added: PHP 8.x bug ?
avatar laoneo
laoneo - comment - 22 May 2023

The change looks ok, but I'm wondering why the context there is null?

avatar obuisard obuisard - change - 20 Jul 2023
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2023-07-20 14:04:55
Closed_By obuisard
avatar obuisard obuisard - close - 20 Jul 2023
avatar obuisard obuisard - merge - 20 Jul 2023
avatar obuisard
obuisard - comment - 20 Jul 2023

Thank you Martin @MacJoom for the PR!

Add a Comment

Login with GitHub to post a comment