Updated controllers, install and modules for PHP 8.x compatibility

This commit is contained in:
vishalsingh.qlo325
2025-05-23 15:08:00 +05:30
parent b9dbc449fe
commit 2f9c64d0fb
173 changed files with 688 additions and 939 deletions

View File

@@ -601,7 +601,7 @@ class AdminImportControllerCore extends AdminController
$html .= '</tr></thead><tbody>';
AdminImportController::setLocale();
for ($current_line = 0; $current_line < 10 && $line = fgetcsv($handle, MAX_LINE_SIZE, $glue); $current_line++) {
for ($current_line = 0; $current_line < 10 && $line = fgetcsv($handle, MAX_LINE_SIZE, $glue, escape: ""); $current_line++) {
/* UTF-8 conversion */
if (Tools::getValue('convert')) {
$line = $this->utf8EncodeArray($line);
@@ -695,7 +695,7 @@ class AdminImportControllerCore extends AdminController
$tab = '';
if (!empty($uniqid_path)) {
$fd = fopen($uniqid_path, 'r');
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator);
$tab = fgetcsv($fd, MAX_LINE_SIZE, $separator, escape: "");
fclose($fd);
if (file_exists($uniqid_path)) {
@unlink($uniqid_path);
@@ -864,7 +864,7 @@ class AdminImportControllerCore extends AdminController
* @param bool $regenerate
* @return bool
*/
protected static function copyImg($id_entity, $id_image = null, $url, $entity = 'products', $regenerate = true)
protected static function copyImg($id_entity, $id_image = null, $url = '', $entity = 'products', $regenerate = true)
{
$tmpfile = tempnam(_PS_TMP_IMG_DIR_, 'ps_import');
$watermark_types = explode(',', Configuration::get('WATERMARK_TYPES'));
@@ -997,7 +997,7 @@ class AdminImportControllerCore extends AdminController
Configuration::get('PS_LOCATIONS_CATEGORY'),
);
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -1079,7 +1079,7 @@ class AdminImportControllerCore extends AdminController
) {
$cat_moved[$category->id] = (int) $category_already_created['id_category'];
$category->id = (int)$category_already_created['id_category'];
if (Validate::isDate($category_already_created['date_add'])) {
if ($category_already_created['date_add'] && Validate::isDate($category_already_created['date_add'])) {
$category->date_add = $category_already_created['date_add'];
}
}
@@ -1163,7 +1163,7 @@ class AdminImportControllerCore extends AdminController
$force_ids = Tools::getValue('forceIDs');
$regenerate = Tools::getValue('regenerate');
$objHotelImage = new HotelImage();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -1349,17 +1349,34 @@ class AdminImportControllerCore extends AdminController
}
$country = Country::getNameById($idLangDefault, $info['id_country']);
if ($catCountry = $objHotelBranch->addCategory($country, false, $groupIds)) {
if ($catCountry = $objHotelBranch->addCategory(
array (
'name' => $country,
'group_ids' => $groupIds,
'parent_category' => false
)
)) {
if ($info['id_state']) {
$objState = new State();
$stateName = $objState->getNameById($info['id_state']);
$catState = $objHotelBranch->addCategory($stateName, $catCountry, $groupIds);
} else {
$catState = $objHotelBranch->addCategory($info['city'], $catCountry, $groupIds);
$stateName = $info['city'];
}
if ($catState) {
if ($catCity = $objHotelBranch->addCategory($info['city'], $catState, $groupIds)) {
if ($catState = $objHotelBranch->addCategory(
array (
'name' => $stateName,
'group_ids' => $groupIds,
'parent_category' => $catCountry
)
)) {
if ($catCity = $objHotelBranch->addCategory(
array (
'name' => $info['city'],
'group_ids' => $groupIds,
'parent_category' => $catState
)
)) {
if ($objHotelBranch->id_category) {
$objCategory = new Category($objHotelBranch->id_category);
$objCategory->name = $objHotelBranch->hotel_name;
@@ -1372,7 +1389,14 @@ class AdminImportControllerCore extends AdminController
Category::regenerateEntireNtree();
} else {
if ($catHotel = $objHotelBranch->addCategory(
$objHotelBranch->hotel_name, $catCity, $groupIds, 1, $objHotelBranch->id, $linkRewriteArray
array (
'name' => $objHotelBranch->hotel_name,
'group_ids' => $groupIds,
'parent_category' => $catCity,
'is_hotel' => 1,
'id_hotel' => $objHotelBranch->id,
'link_rewrite' => $linkRewriteArray
)
)) {
$objHotelBranch = new HotelBranchInformation($objHotelBranch->id);
$objHotelBranch->id_category = $catHotel;
@@ -1474,7 +1498,7 @@ class AdminImportControllerCore extends AdminController
Module::setBatchMode(true);
$objRoomType = new HotelRoomType();
$objAdvancePayment = new HotelAdvancedPayment();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -1958,7 +1982,7 @@ class AdminImportControllerCore extends AdminController
$objHotelRoomType = new HotelRoomType();
$objHotelRoomInformation = new HotelRoomInformation();
$statuses = array_column($objHotelRoomInformation->getAllRoomStatus(), 'id');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -2072,7 +2096,7 @@ class AdminImportControllerCore extends AdminController
$regenerate = Tools::getValue('regenerate');
$shop_is_feature_active = Shop::isFeatureActive();
Module::setBatchMode(true);
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -2412,7 +2436,7 @@ class AdminImportControllerCore extends AdminController
$ordersRow = array();
$hotelRoomTypeInfo = array();
$orderInfo = array();
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -2713,7 +2737,7 @@ class AdminImportControllerCore extends AdminController
$phoneRequired = true;
}
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -2899,7 +2923,7 @@ class AdminImportControllerCore extends AdminController
$convert = Tools::getValue('convert');
$force_ids = Tools::getValue('forceIDs');
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); $current_line++) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); $current_line++) {
if ($convert) {
$line = $this->utf8EncodeArray($line);
}
@@ -2966,7 +2990,7 @@ class AdminImportControllerCore extends AdminController
$force_ids = Tools::getValue('forceIDs');
// main loop, for each supply orders to import
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); ++$current_line) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); ++$current_line) {
// if convert requested
if ($convert) {
$line = $this->utf8EncodeArray($line);
@@ -3082,7 +3106,7 @@ class AdminImportControllerCore extends AdminController
$force_ids = Tools::getValue('forceIDs');
// main loop, for each supply orders details to import
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator); ++$current_line) {
for ($current_line = 0; $line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: ""); ++$current_line) {
// if convert requested
if ($convert) {
$line = $this->utf8EncodeArray($line);
@@ -3190,7 +3214,7 @@ class AdminImportControllerCore extends AdminController
public function utf8EncodeArray($array)
{
return (is_array($array) ? array_map('utf8_encode', $array) : utf8_encode($array));
return (is_array($array) ? array_map('utf8_encode', $array) : mb_convert_encoding($array, 'UTF-8', 'ISO-8859-1'));
}
protected function getNbrColumn($handle, $glue)
@@ -3198,7 +3222,7 @@ class AdminImportControllerCore extends AdminController
if (!is_resource($handle)) {
return false;
}
$tmp = fgetcsv($handle, MAX_LINE_SIZE, $glue);
$tmp = fgetcsv($handle, MAX_LINE_SIZE, $glue, escape: "");
AdminImportController::rewindBomAware($handle);
return count($tmp);
}
@@ -3226,7 +3250,7 @@ class AdminImportControllerCore extends AdminController
AdminImportController::rewindBomAware($handle);
for ($i = 0; $i < (int)Tools::getValue('skip'); ++$i) {
$line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator);
$line = fgetcsv($handle, MAX_LINE_SIZE, $this->separator, escape: "");
}
return $handle;
}