The problem is, when you don't have any support department, the $results value returned by localAPI is:
[
'result' => 'success',
'totalresults' => 0,
]
Then, count($results["departments"]) will throw an error because count() expects a Contable|array type and null/undefined is given instead.
I've fixed this on my end just replacing that with && !empty($results["departments"]).
To Reproduce
Steps to reproduce the behavior:
Setup brand new WHMCS installation
Copy the ibs module's content into the WHMCS folder
Go to /admin/configregistrars.php
See error
Expected behavior
No error, handle empty departments softly.
Screenshots
No screens but the output instead:
Oops!
Something went wrong and we couldn't process your request.
Please go back to the previous page and try again.
For additional assistance, please reference the [WHMCS TroubleShooting Guide »](https://docs.whmcs.com/Troubleshooting_Guide)
TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /var/www/html/modules/registrars/ibs/ibs.php:650
Stack trace:
#0 [internal function]: ibs_getConfigArray(Array)
#1 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/AbstractModule.php(0): call_user_func('ibs_getConfigAr...', Array)
#2 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/Registrar.php(0): WHMCS\Module\AbstractModule->call('getConfigArray', Array)
#3 /var/www/html/admin/configregistrars.php(0): WHMCS\Module\Registrar->call('getConfigArray')
#4 {main}
Context (please complete the following information):
Device: Desktop
OS: Docker/Ubuntu
Browser Chrome
WHMCS Version: 8.7
PHP Version: 8.1
IBS Registrar Module Version: latest from main branch
Describe the bug Current code at
ibs.php:648-650
:The problem is, when you don't have any support department, the
$results
value returned bylocalAPI
is:Then,
count($results["departments"])
will throw an error becausecount()
expects aContable|array
type and null/undefined is given instead.I've fixed this on my end just replacing that with
&& !empty($results["departments"])
.To Reproduce Steps to reproduce the behavior:
/admin/configregistrars.php
Expected behavior No error, handle empty departments softly.
Screenshots No screens but the output instead:
Context (please complete the following information):