hluaces / virtualname-whmcs

Mirror (under git version control) of the original Virtualname WHMCS module

Home Page:https://whmcs.virtualname.net/descargas/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

PR6316 - Problems on WHMCS 7.10

hluaces opened this issue · comments

Virtualname TCPanel version 1.2.0 introduced a new error caused by a version comparison that shows the following error upon trying to access the "Contacts" section on the client area:

[07-May-2020 09:44:50 Europe/Madrid] [WHMCS Application] ERROR: ArgumentCountError: Too few arguments to function WHMCS\View\Client\Menu\MenuRepository::addContext(), 0 passed in /home/whmcs/public/vendor/illuminate/support/Facades/Facade.php on line 215 and exactly 2 expected in /home/whmcs/public/vendor/whmcs/whmcs-foundation/lib/View/Client/Menu/MenuRepository.php:0 Stack trace: #0 /home/whmcs/public/vendor/illuminate/support/Facades/Facade.php(215): WHMCS\View\Client\Menu\MenuRepository->addContext() #1 /home/whmcs/public/clientareadata.php(45): Illuminate\Support\Facades\Facade::__callStatic('addContext', Array) #2 {main} {"exception":"[object] (ArgumentCountError(code: 0): Too few arguments to function WHMCS\View\Client\Menu\MenuRepository::addContext(), 0 passed in /home/whmcs/public/vendor/illuminate/support/Facades/Facade.php on line 215 and exactly 2 expected at /home/whmcs/public/vendor/whmcs/whmcs-foundation/lib/View/Client/Menu/MenuRepository.php:0)"} []

Upon review I've found out that it all comes to this check, which is being used more than once on the module's code:

$whmcs_version = virtualname_get_whmcs_version();
if(in_array($whmcs_version, array('7.0.', '7.1.', '7.2.', '7.3.', '7.4.', '7.0', '7.1', '7.2', '7.3', '7.4'))) {

The problem with the comparison arises when $whmcs_version is '7.10', which is validated as being into the array because of PHP's default loose type checks, as illustrated below:

$ php -a
Interactive mode enabled

php > $whmcs_version='7.10';
php > var_dump(in_array($whmcs_version, array('7.0.', '7.1.', '7.2.', '7.3.', '7.4.', '7.0', '7.1', '7.2', '7.3', '7.4')));
bool(true)

This error doesn't occur if we use true as the third parameter for in_array, which enforces strict type checking:

$ php -a
Interactive mode enabled

php > $whmcs_version='7.10';
php > var_dump(in_array($whmcs_version, array('7.0.', '7.1.', '7.2.', '7.3.', '7.4.', '7.0', '7.1', '7.2', '7.3', '7.4'), true));
bool(false)

As of now the following files have been identified to have this same error: