openprovider / Openprovider-WHMCS-domains

Openprovider WHMCS Domain Module
43 stars 31 forks source link

[BUG] PHP 8.1 bug. TypeError: count(): Argument #1 ($value) must be of type Countable|array. #313

Closed GARMTECH closed 6 months ago

GARMTECH commented 6 months ago

Describe the bug After upgrade to Openprovider module v5.8-beta in PHP 8.1 environment the cron.php executes with such error:

[WHMCS Application] ERROR: TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /var/www/html/modules/registrars/openprovider/Models/Domain.php:25 Stack trace: #0 /var/www/html/modules/registrars/openprovider/Models/Domain.php(25): count() #1 /var/www/html/modules/registrars/openprovider/Controllers/System/TransferSyncController.php(63): OpenProvider\WhmcsRegistrar\Models\Domain->check_renew_domain_setting_upon_completed_transfer() #2 /var/www/html/modules/addons/openprovider/vendor/wedevelopcoffee/wpower/src/Core/Instance.php(47): OpenProvider\WhmcsRegistrar\Controllers\System\TransferSyncController->sync() #3 /var/www/html/modules/addons/openprovider/vendor/wedevelopcoffee/wpower/src/Core/Launch.php(54): WeDevelopCoffee\wPower\Core\Instance->execute() #4 /var/www/html/modules/registrars/openprovider/openprovider.php(353): WeDevelopCoffee\wPower\Core\Launch->output() #5 /var/www/html/modules/registrars/openprovider/openprovider.php(262): openprov
ider_registrar_launch_decorator() #6 [internal function]: openprovider_TransferSync() #7 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/AbstractModule.php(0): call_user_func() #8 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/Registrar.php(0): WHMCS\Module\AbstractModule->call() #9 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Task/DomainTransferSync.php(0): WHMCS\Module\Registrar->call() #10 [internal function]: WHMCS\Cron\Task\DomainTransferSync->__invoke() #11 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Scheduling/Task/AbstractTask.php(0): call_user_func_array() #12 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Scheduling/Task/AbstractTask.php(0): WHMCS\Scheduling\Task\AbstractTask->execute() #13 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Console/Command/AbstractCronCommand.php(0): WHMCS\Scheduling\Task\AbstractTask->run() #14 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Console/Command/AbstractCronCommand.php(0): WHMCS\Cron\Console\
Command\AbstractCronCommand->executeCollecti!
on() #15 /var/www/html/vendor/symfony/console/Command/Command.php(298): WHMCS\Cron\Console\Command\AbstractCronCommand->execute() #16 /var/www/html/vendor/symfony/console/Application.php(1028): Symfony\Component\Console\Command\Command->run() #17 /var/www/html/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand() #18 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun() #19 /var/www/crons/cron.php(0): Symfony\Component\Console\Application->run() #20 {main} {"exception":"[object] (TypeError(code: 0): count(): Argument #1 ($value) must be of type Countable|array, string given at /var/www/html/modules/registrars/openprovider/Models/Domain.php:25)"} []
TypeError: count(): Argument #1 ($value) must be of type Countable|array, string given in /var/www/html/modules/registrars/openprovider/Models/Domain.php:25

#0 /var/www/html/modules/registrars/openprovider/Models/Domain.php(25): count()
#1 /var/www/html/modules/registrars/openprovider/Controllers/System/TransferSyncController.php(63): OpenProvider\WhmcsRegistrar\Models\Domain->check_renew_domain_setting_upon_completed_transfer()
#2 /var/www/html/modules/addons/openprovider/vendor/wedevelopcoffee/wpower/src/Core/Instance.php(47): OpenProvider\WhmcsRegistrar\Controllers\System\TransferSyncController->sync()
#3 /var/www/html/modules/addons/openprovider/vendor/wedevelopcoffee/wpower/src/Core/Launch.php(54): WeDevelopCoffee\wPower\Core\Instance->execute()
#4 /var/www/html/modules/registrars/openprovider/openprovider.php(353): WeDevelopCoffee\wPower\Core\Launch->output()
#5 /var/www/html/modules/registrars/openprovider/openprovider.php(262): openprovider_registrar_launch_decorator()
#6 [internal function]: openprovider_TransferSync()
#7 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/AbstractModule.php(0): call_user_func()
#8 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Module/Registrar.php(0): WHMCS\Module\AbstractModule->call()
#9 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Task/DomainTransferSync.php(0): WHMCS\Module\Registrar->call()
#10 [internal function]: WHMCS\Cron\Task\DomainTransferSync->__invoke()
#11 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Scheduling/Task/AbstractTask.php(0): call_user_func_array()
#12 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Scheduling/Task/AbstractTask.php(0): WHMCS\Scheduling\Task\AbstractTask->execute()
#13 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Console/Command/AbstractCronCommand.php(0): WHMCS\Scheduling\Task\AbstractTask->run()
#14 /var/www/html/vendor/whmcs/whmcs-foundation/lib/Cron/Console/Command/AbstractCronCommand.php(0): WHMCS\Cron\Console\Command\AbstractCronCommand->executeCollection()
#15 /var/www/html/vendor/symfony/console/Command/Command.php(298): WHMCS\Cron\Console\Command\AbstractCronCommand->execute()
#16 /var/www/html/vendor/symfony/console/Application.php(1028): Symfony\Component\Console\Command\Command->run()
#17 /var/www/html/vendor/symfony/console/Application.php(299): Symfony\Component\Console\Application->doRunCommand()
#18 /var/www/html/vendor/symfony/console/Application.php(171): Symfony\Component\Console\Application->doRun()
#19 /var/www/crons/cron.php(0): Symfony\Component\Console\Application->run()
#20 {main}

To Reproduce Steps to reproduce the behavior:

  1. Upload new version
  2. Wait for a cron run

Expected behavior No errors on cron run.

Server info:

BenMeesters commented 6 months ago

Same error i got

cron for /modules/registrars/openprovider/cron/DownloadTldPrices.php [WHMCS Application] ERROR: TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /modules/registrars/openprovider/cron/BaseCron.php:37 Stack trace: #0 /var/www/clients/client1/web5/web/account/modules/registrars/openprovider/cron/BaseCron.php(7): is_cli() #1 /var/www/clients/client1/web5/web/account/modules/registrars/openprovider/cron/DownloadTldPrices.php(8): include('...') #2 {main} {"exception":"[object] (TypeError(code: 0): count(): Argument #1 ($value) must be of type Countable|array, null given at /var/www/clients/client1/web5/web/account/modules/registrars/openprovider/cron/BaseCron.php:37)"} [] TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /modules/registrars/openprovider/cron/BaseCron.php:37

/modules/registrars/openprovider/cron/BaseCron.php(7): is_cli() /modules/registrars/openprovider/cron/DownloadTldPrices.php(8): include('...')

sapillai commented 6 months ago

Hi @GARMTECH,

Thank you for reporting the issue. A fix was added for this specific error in version 5.8.0. So it is strange that you are still encountering the error. Can you please get in touch with our support team and share following details so that we can investigate this further:

image

@BenMeesters please create a new issue as your case is different from 'cron.php' error reported in the initial post. Please include module logs, version details of WHMCS, Openprovider module, PHP and web server.

sapillai commented 6 months ago

Hi @GARMTECH,

I reviewed the stack trace with the help of our developers and confirmed that the file 'modules/registrars/openprovider/Models/Domain.php' in v5.8-beta no longer uses count() function (it was changed a couple of months ago to fix this specific error).

image

So it appears the error is occurring due to Domain.php file from a previous version. Please review your Openprovider module installation and ensure that Openprovider module files are replaced with new ones from v5.8-beta package.