openprovider / Openprovider-WHMCS-domains

Openprovider WHMCS Domain Module
43 stars 31 forks source link

[BUG] DownloadTldPrices.php - TypeError: array_merge(): Argument #1 must be of type array, null given in openprovider.php:344 #256

Closed Falscher42 closed 1 year ago

Falscher42 commented 1 year ago

Hello all,

I´m having an issue with the DownloadTldPrices.php on a new WHMCS installation, and I hope you can point me in the right direction!

Describe the bug While running "DownloadTldPrices.php" I get the following error: TypeError: array_merge(): Argument #1 must be of type array, null given in /var/www/html/modules/registrars/openprovider/openprovider.php:344

I executed it both via cron & SSH as described here: https://github.com/openprovider/Openprovider-WHMCS-domains/blob/master/docs/TLD_Pricing_sync_Utility.md

To Reproduce Steps to reproduce the behavior: Run "DownloadTldPrices.php" via ssh or corn, or just open the file in a browser. I uploaded the files as described in the readme.md, enabled the registrar, and added API credentials.

Full Error (SSH)

[WHMCS Application] ERROR: TypeError: array_merge(): Argument #1 must be of type array, null given in /var/www/html/modules/registrars/openprovider/openprovider.php:344 Stack trace:

0 /var/www/html/modules/registrars/openprovider/openprovider.php(344): array_merge(NULL, Array) #1 /var/www/html/modules/registrars/openprovider/cron/DownloadTldPrices.php(13): openprovider_registrar_launch_decorator('DownloadTldPric...') #2 {main} {"exception":"[object] (TypeError(code: 0): array_merge(): Argument #1 must be of type array, null given at /var/www/html/modules/registrars/openprovider/openprovider.php:344)"} []

TypeError: array_merge(): Argument #1 must be of type array, null given in /var/www/html/modules/registrars/openprovider/openprovider.php:344

0 /var/www/html/modules/registrars/openprovider/openprovider.php(344): array_merge(NULL, Array)

1 /var/www/html/modules/registrars/openprovider/cron/DownloadTldPrices.php(13): openprovider_registrar_launch_decorator('DownloadTldPric...')

2 {main}

Server info:

Thank you for your help!

sapillai commented 1 year ago

Hi @Falscher42,

Thank you for reporting the issue.

I tested the script 'DownloadTldPrices.php' in PHP 8.1 and I was able to replicate the problem. As a temporary work-around, you can try the following fix:

Comment out line 344 in file modules/registrars/openprovider/openprovider.php

/**    $modifiedParams['original'] = array_merge($params['original'], Configuration::getParams());
*/

And replace it with following code:

    if (isset($params['original'])) {
    $modifiedParams['original'] = array_merge($params['original'], Configuration::getParams());
} else {
    $modifiedParams['original'] = Configuration::getParams();
}

I tested the fix in PHP 8.1.13 and the script successfully imported domain prices using searchExtensionRequest.

Falscher42 commented 1 year ago

Thanks @sapillai That worked perfectly!

Sadly now I am experiencing a different error; I joined thread #252 as it´s pretty similar (if not the same).