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/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); } } diff --git a/classes/Tools.php b/classes/Tools.php index 1b157e4a9..f898c10e8 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); } @@ -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')) { @@ -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'; } diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index 5d2667be3..d0bcaffbc 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2824,6 +2824,9 @@ 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; } $this->helper = $helper; diff --git a/classes/controller/Controller.php b/classes/controller/Controller.php index 2fdbc5aab..7804f781f 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/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) diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 1fc8ee2cf..f27cab407 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/admin/AdminTranslationsController.php b/controllers/admin/AdminTranslationsController.php index 6e1d2f823..1232fb59e 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)) { 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']]; 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;