From da49d2e2624ced95ffcc7d5cfd89517b3dba22d2 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 16:18:16 +0530 Subject: [PATCH] Fixed PHP 8 compatibility issues --- classes/Tools.php | 4 ++-- classes/controller/AdminController.php | 5 +++++ classes/controller/Controller.php | 1 + classes/helper/HelperList.php | 5 ----- controllers/admin/AdminNormalProductsController.php | 9 +++++---- controllers/front/AuthController.php | 4 +++- controllers/front/CartController.php | 4 ++-- modules/blockcart/blockcart.php | 5 +++-- .../classes/HotelBranchInformation.php | 4 +--- 9 files changed, 22 insertions(+), 19 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index 1b157e4a9..fad6b092e 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1107,12 +1107,12 @@ class ToolsCore * * @see error_log() * @param mixed $object - * @param int|null $message_type + * @param int $message_type * @param string|null $destination * @param string|null $extra_headers * @return bool */ - public static function error_log($object, $message_type = null, $destination = null, $extra_headers = null) + public static function error_log($object, $message_type = 0, $destination = null, $extra_headers = null) { return error_log(print_r($object, true), $message_type, $destination, $extra_headers); } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 0bb460e70..b1128b9ee 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2826,6 +2826,11 @@ class AdminControllerCore extends Controller $helper->actions = $this->actions; } + // For each action, try to add the corresponding skip elements listAdd commentMore actions + $helper->list_skip_actions = $this->list_skip_actions; + $helper->orderBy = $this->_orderBy; + $helper->orderWay = $this->_orderWay; + $this->helper = $helper; } diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 31e93ec73..a83afd4fc 100644 --- a/classes/controller/Controller.php +++ b/classes/controller/Controller.php @@ -28,6 +28,7 @@ * @TODO Move undeclared variables and methods to this (base) class: $errors, $layout, checkLiveEditAccess, etc. * @since 1.5.0 */ +#[\AllowDynamicProperties] abstract class ControllerCore { /** @var Context */ diff --git a/classes/helper/HelperList.php b/classes/helper/HelperList.php index b738c55b7..5e0a4e76f 100644 --- a/classes/helper/HelperList.php +++ b/classes/helper/HelperList.php @@ -602,11 +602,6 @@ class HelperListCore extends Helper $total_pages = max(1, ceil($this->listTotal / $pagination)); $identifier = Tools::getIsset($this->identifier) ? '&'.$this->identifier.'='.(int)Tools::getValue($this->identifier) : ''; - $order = ''; - if (Tools::getIsset($this->table.'Orderby')) { - $order = '&'.$this->table.'Orderby='.urlencode($this->orderBy).'&'.$this->table.'Orderway='.urlencode(strtolower($this->orderWay)); - } - $action = $this->currentIndex.$identifier.'&token='.$token.'#'.$this->list_id; /* Determine current page number */ diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 811de34be..f638e2ddc 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -2964,7 +2964,7 @@ class AdminNormalProductsControllerCore extends AdminController $allAssociations = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product->id); if (Product::SELLING_PREFERENCE_WITH_ROOM_TYPE == $product->selling_preference_type) { $associatedRoomTypes = $allAssociations['room_type']; - $selectedRoomTypes = Tools::getValue('room_type_box'); + $selectedRoomTypes = Tools::getValue('room_type_box', array()); // Generate list of new associations $newRoomTypes = array(); @@ -3005,7 +3005,7 @@ class AdminNormalProductsControllerCore extends AdminController ); } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE == $product->selling_preference_type) { $associatedHotels = $allAssociations['hotel']; - $selectedHotel = Tools::getValue('hotel_box'); + $selectedHotel = Tools::getValue('hotel_box', array()); // Generate list of new associations $newHotels = array(); foreach ($selectedHotel as $selectedRoomType) { @@ -3046,7 +3046,7 @@ class AdminNormalProductsControllerCore extends AdminController } elseif (Product::SELLING_PREFERENCE_HOTEL_STANDALONE_AND_WITH_ROOM_TYPE == $product->selling_preference_type) { // Add room types linking $associatedRoomTypes = $allAssociations['room_type']; - $selectedRoomTypes = Tools::getValue('room_type_box'); + $selectedRoomTypes = Tools::getValue('room_type_box', array()); // Generate list of new associations $newRoomTypes = array(); foreach ($selectedRoomTypes as $selectedRoomType) { @@ -3083,7 +3083,7 @@ class AdminNormalProductsControllerCore extends AdminController // Add hotels linking $associatedHotels = $allAssociations['hotel']; - $selectedHotel = Tools::getValue('hotel_box'); + $selectedHotel = Tools::getValue('hotel_box', array()); // Generate list of new associations $newHotels = array(); foreach ($selectedHotel as $selectedRoomType) { @@ -3407,6 +3407,7 @@ class AdminNormalProductsControllerCore extends AdminController // Get all id_product_attribute $attributes = $obj->getAttributesResume($this->context->language->id); if (empty($attributes)) { + $attributes = array(); $attributes[] = array( 'id_product_attribute' => 0, 'attribute_designation' => '' diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 13ba9de8d..91b583007 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -570,7 +570,9 @@ class AuthControllerCore extends FrontController } } } - if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) && !(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '')) { + if (!(Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') + && !@checkdate((int) Tools::getValue('months'), (int) Tools::getValue('days'), (int) Tools::getValue('years')) + ) { $this->errors[] = Tools::displayError('Invalid date of birth'); } diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index c91e46111..b11c0e54a 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -61,8 +61,8 @@ class CartControllerCore extends FrontController $this->id_product = (int)Tools::getValue('id_product', null); $this->id_product_attribute = (int)Tools::getValue('id_product_attribute', Tools::getValue('ipa')); $this->customization_id = (int)Tools::getValue('id_customization'); - $this->qty = abs(Tools::getValue('qty', 1)); - $this->id_hotel = abs(Tools::getValue('id_hotel', null)); + $this->qty = abs((int) Tools::getValue('qty', 1)); + $this->id_hotel = abs((int) Tools::getValue('id_hotel', 0)); $this->id_address_delivery = (int)Tools::getValue('id_address_delivery'); } diff --git a/modules/blockcart/blockcart.php b/modules/blockcart/blockcart.php index 8fd804e22..976bbc4f4 100644 --- a/modules/blockcart/blockcart.php +++ b/modules/blockcart/blockcart.php @@ -286,8 +286,9 @@ class Blockcart extends Module null, $this->context->cart->id_shop ); - $image = Product::getCover($objProduct->id); - $image['id_product'] = $objProduct->id; + if ($image = Product::getCover($objProduct->id)) { + $image['id_product'] = $objProduct->id; + } // Product::defineProductImage(array(Product::getCover($objProduct->id)['id_image']/), $this->id_lang) $addedProduct['image'] = $this->context->link->getImageLink( $objProduct->link_rewrite, diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php index 375b148d8..71933a53c 100644 --- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php +++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php @@ -746,9 +746,7 @@ class HotelBranchInformation extends ObjectModel $catName = $name; } $category->name[$lang['id_lang']] = $catName; - $category->description[$lang['id_lang']] = $this->moduleInstance->l( - 'Hotel Branch Category', 'HotelBranchInformation' - ); + $category->description[$lang['id_lang']] = $this->moduleInstance->l('Hotel Branch Category', 'HotelBranchInformation'); if (is_array($link_rewrite)) { $category->link_rewrite[$lang['id_lang']] = $link_rewrite[$lang['id_lang']];