From da49d2e2624ced95ffcc7d5cfd89517b3dba22d2 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 16:18:16 +0530 Subject: [PATCH 1/8] 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']]; From aca1067b5472c417c72ce4fb806e2b462a28225c Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 16:25:31 +0530 Subject: [PATCH 2/8] Fixed: fatal error occuring while deleting a language --- classes/Language.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/classes/Language.php b/classes/Language.php index 976b4ec79..0963279bb 100644 --- a/classes/Language.php +++ b/classes/Language.php @@ -541,15 +541,17 @@ class LanguageCore extends ObjectModel $modList = scandir(_PS_MODULE_DIR_); foreach ($modList as $mod) { Language::recurseDeleteDir(_PS_MODULE_DIR_.$mod.'/mails/'.$this->iso_code); - $files = @scandir(_PS_MODULE_DIR_.$mod.'/mails/'); - if (count($files) <= 2) { + if (($files = @scandir(_PS_MODULE_DIR_.$mod.'/mails/')) + && (count($files) <= 2) + ) { Language::recurseDeleteDir(_PS_MODULE_DIR_.$mod.'/mails/'); } if (file_exists(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php')) { unlink(_PS_MODULE_DIR_.$mod.'/'.$this->iso_code.'.php'); - $files = @scandir(_PS_MODULE_DIR_.$mod); - if (count($files) <= 2) { + if (($files = @scandir(_PS_MODULE_DIR_.$mod)) + && (count($files) <= 2) + ) { Language::recurseDeleteDir(_PS_MODULE_DIR_.$mod); } } From d007ed202d457ec90ea1523d205b706df19fa68b Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 16:45:06 +0530 Subject: [PATCH 3/8] Fixed: issues caused due to null in strtolower in admin translation controller --- classes/Tools.php | 6 +++--- controllers/admin/AdminTranslationsController.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/classes/Tools.php b/classes/Tools.php index fad6b092e..09916a166 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1734,7 +1734,7 @@ class ToolsCore public static function strtolower($str) { - if (is_array($str)) { + if (is_array($str) || is_null($str)) { return false; } if (function_exists('mb_strtolower')) { @@ -1766,7 +1766,7 @@ class ToolsCore public static function strtoupper($str) { - if (is_array($str)) { + if (is_array($str) || is_null($str)) { return false; } if (function_exists('mb_strtoupper')) { @@ -1777,7 +1777,7 @@ class ToolsCore public static function substr($str, $start, $length = false, $encoding = 'utf-8') { - if (is_array($str)) { + if (is_array($str) || is_null($str)) return false; } if (function_exists('mb_substr')) { diff --git a/controllers/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 36b5eca29..3d25592c4 100644 --- a/controllers/admin/AdminTranslationsController.php +++ b/controllers/admin/AdminTranslationsController.php @@ -1112,7 +1112,7 @@ class AdminTranslationsControllerCore extends AdminController foreach ($matches as $key) { $md5_key = md5($key); - $module_key = '<{'.Tools::strtolower($module_name).'}'.strtolower($theme_name).'>'.Tools::strtolower($template_name).'_'.$md5_key; + $module_key = '<{'.Tools::strtolower($module_name).'}'.Tools::strtolower($theme_name).'>'.Tools::strtolower($template_name).'_'.$md5_key; $default_key = '<{'.Tools::strtolower($module_name).'}prestashop>'.Tools::strtolower($template_name).'_'.$md5_key; // to avoid duplicate entry if (!in_array($module_key, $array_check_duplicate)) { From 9eceacf655a39520d2d0a8aaee08cdf0d552de5d Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 17:03:20 +0530 Subject: [PATCH 4/8] Fixed: notices occured while creating tax rule group --- classes/tax/TaxRulesGroup.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/classes/tax/TaxRulesGroup.php b/classes/tax/TaxRulesGroup.php index 0f5d3e4f0..fda98ba26 100644 --- a/classes/tax/TaxRulesGroup.php +++ b/classes/tax/TaxRulesGroup.php @@ -117,20 +117,22 @@ class TaxRulesGroupCore extends ObjectModel public function getIdTaxRuleGroupFromHistorizedId($id_tax_rule) { - $params = Db::getInstance()->getRow(' - SELECT id_country, id_state, zipcode_from, zipcode_to, id_tax, behavior - FROM '._DB_PREFIX_.'tax_rule - WHERE id_tax_rule='.(int)$id_tax_rule - ); + if ($params = Db::getInstance()->getRow(' + SELECT id_country, id_state, zipcode_from, zipcode_to, id_tax, behavior + FROM '._DB_PREFIX_.'tax_rule + WHERE id_tax_rule='.(int)$id_tax_rule + )) { + return Db::getInstance()->getValue(' + SELECT id_tax_rule + FROM '._DB_PREFIX_.'tax_rule + WHERE + id_tax_rules_group = '.(int)$this->id.' AND + id_country='.(int)$params['id_country'].' AND id_state='.(int)$params['id_state'].' AND id_tax='.(int)$params['id_tax'].' AND + zipcode_from=\''.pSQL($params['zipcode_from']).'\' AND zipcode_to=\''.pSQL($params['zipcode_to']).'\' AND behavior='.(int)$params['behavior'] + ); + } - return Db::getInstance()->getValue(' - SELECT id_tax_rule - FROM '._DB_PREFIX_.'tax_rule - WHERE - id_tax_rules_group = '.(int)$this->id.' AND - id_country='.(int)$params['id_country'].' AND id_state='.(int)$params['id_state'].' AND id_tax='.(int)$params['id_tax'].' AND - zipcode_from=\''.pSQL($params['zipcode_from']).'\' AND zipcode_to=\''.pSQL($params['zipcode_to']).'\' AND behavior='.(int)$params['behavior'] - ); + return false; } public static function getTaxRulesGroups($only_active = true) From 0a3cc12a271f56abf97412b5b336ff0cf8402a3c Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 17:05:22 +0530 Subject: [PATCH 5/8] Fixed: syntax error --- classes/Tools.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/Tools.php b/classes/Tools.php index 09916a166..660bd9578 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -1777,7 +1777,7 @@ class ToolsCore public static function substr($str, $start, $length = false, $encoding = 'utf-8') { - if (is_array($str) || is_null($str)) + if (is_array($str) || is_null($str)) { return false; } if (function_exists('mb_substr')) { From 5d1258f60733dc884cae4dbf4dfc1d24090992e3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 19:11:34 +0530 Subject: [PATCH 6/8] Fixed: notices for DateTime in case the date is null --- modules/hotelreservationsystem/classes/HotelHelper.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 597143379..0bb2d3f4e 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -2682,6 +2682,10 @@ class HotelHelper public static function getNumberOfDays($dateFrom, $dateTo) { + if (empty($dateFrom) || empty($dateTo)) { + return 0; + } + $startDate = new DateTime($dateFrom); $endDate = new DateTime($dateTo); $daysDifference = $startDate->diff($endDate)->days; From 0db3b0731a03d36674ca30b889c8ec228728dad3 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 3 Jun 2025 19:28:52 +0530 Subject: [PATCH 7/8] Fixed: notices on order view page after order stauts is deleted --- .../template/controllers/orders/helpers/view/view.tpl | 6 +++--- classes/Tools.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl index ef5ee9e9e..816ffbc0d 100644 --- a/admin/themes/default/template/controllers/orders/helpers/view/view.tpl +++ b/admin/themes/default/template/controllers/orders/helpers/view/view.tpl @@ -217,8 +217,8 @@ {foreach from=$history item=row key=key} {if ($key == 0)} - {$row['ostate_name']|stripslashes} {* by webkul to get media link *} - {$row['ostate_name']|stripslashes} + {if !empty($row['ostate_name'])}{$row['ostate_name']|stripslashes}{/if} {* by webkul to get media link *} + {if !empty($row['ostate_name'])}{$row['ostate_name']|stripslashes}{/if} {if $row['employee_lastname']}{$row['employee_firstname']|stripslashes} {$row['employee_lastname']|stripslashes}{/if} {dateFormat date=$row['date_add'] full=true} @@ -236,7 +236,7 @@ {else} - {$row['ostate_name']|stripslashes} + {if !empty($row['ostate_name'])}{$row['ostate_name']|stripslashes}{/if} {if $row['employee_lastname']}{$row['employee_firstname']|stripslashes} {$row['employee_lastname']|stripslashes}{else} {/if} {dateFormat date=$row['date_add'] full=true} {if $can_edit} diff --git a/classes/Tools.php b/classes/Tools.php index 660bd9578..f898c10e8 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -2151,7 +2151,7 @@ class ToolsCore public static function getBrightness($hex) { - if (Tools::strtolower($hex) == 'transparent') { + if (Tools::strtolower($hex) == 'transparent' || empty($hex)) { return '129'; } From 92e1339980cdeecdcf25a1492861c138e6fa15b1 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Wed, 4 Jun 2025 11:03:05 +0530 Subject: [PATCH 8/8] optmized the changes related to the helper list issue --- classes/controller/AdminController.php | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index b1128b9ee..59dd7b083 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2824,13 +2824,11 @@ class AdminControllerCore extends Controller $helper->simple_header = $this->list_simple_header; $helper->bulk_actions = $this->bulk_actions; $helper->actions = $this->actions; + $helper->list_skip_actions = $this->list_skip_actions; + $helper->orderBy = $this->_orderBy; + $helper->orderWay = $this->_orderWay; } - // 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; }