Closed ckubitza closed 5 years ago
Not sure it is the right solution to change a boolean value to integer.. The problem is the cast I think.
Another possibility would be to fix it not in the module but in the function which uses the hook. So here https://github.com/PrestaShop/PrestaShop/blob/da467fbb8b5fcbb26f98c87041a8fcf23fe9c374/classes/form/CustomerAddressForm.php#L123-L125 the Hook::exec() call should have another two parameters to enable the array_return and then iterate over them instead of checking for the string. Maybe something like this:
$hookModuleReturns = Hook::exec('actionValidateCustomerAddressForm', array('form' => $this), null, true);
if (count($hookModuleReturns) > 0) {`
$hookReturn = true;
foreach ($hookModuleReturns as $hookModuleReturn) {
$hookReturn &= (bool) $hookModuleReturn;
}
$is_valid &= $hookReturn;
}
I think it's where we must fix it and not here. You're right we must have a check where the hook is called.
I just realized that there are already changes made which address this problem: https://github.com/PrestaShop/PrestaShop/blob/335851e5523b19aac49a65e5173414cfbc7df083/classes/form/CustomerAddressForm.php#L123 (it's the strict string comaprison).
…, because boolean false is casted to empty string like when no hook is executed. Should fix: https://github.com/PrestaShop/PrestaShop/issues/9884