centralnicgroup-opensource / rtldev-middleware-whmcs

CentralNic's WHMCS Software Bundle
https://centralnicreseller.com
Other
35 stars 15 forks source link

WHMCS-IBS module error on empty support departments #250

Closed tonnyorg closed 1 year ago

tonnyorg commented 1 year ago

Describe the bug Current code at ibs.php:648-650:

$results = localAPI("GetSupportDepartments", []);
$departments = ["-"];
if ($results && count($results) && count($results["departments"])) {

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:

  1. Setup brand new WHMCS installation
  2. Copy the ibs module's content into the WHMCS folder
  3. Go to /admin/configregistrars.php
  4. 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):

KaiSchwarz-cnic commented 1 year ago

Thanks @TonnyORG for addressing. Patched - the new version v3.0.1 of the IBS Integration is available here.

HTH!

tonnyorg commented 1 year ago

Tyvm @KaiSchwarz-cnic !