Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8b1da8e

Browse files
authored
Merge pull request #41472 from nicosomb/merge-91x-develop
Merge `9.1.x` to `develop`
2 parents c0f4566 + a3d020a commit 8b1da8e

25 files changed

Lines changed: 435 additions & 175 deletions

File tree

admin-dev/themes/default/template/controllers/cart_rules/conditions.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
<td>
239239
<p>{l s='Uncombinable cart rules' d='Admin.Catalog.Feature'}</p>
240240
<input id="cart_rule_select_1_filter" autocomplete="off" class="form-control uncombinable_search_filter" type="text" name="uncombinable_filter" placeholder="{l s='Search' d='Admin.Actions'}" value="">
241-
<select id="cart_rule_select_1" class="jscroll" multiple="">
241+
<select id="cart_rule_select_1" class="jscroll" multiple="" name="cart_rule_unselected[]">
242242
</select>
243243
<a class="jscroll-next btn btn-default btn-block clearfix" href="">{l s='Next' d='Admin.Global'}</a>
244244
<a id="cart_rule_select_add" class="btn btn-default btn-block clearfix">{l s='Add' d='Admin.Actions'} <i class="icon-arrow-right"></i></a>

admin-dev/themes/default/template/controllers/cart_rules/form.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,12 @@ $('#cart_rule_form').on('submit', () => {
241241
$(`#${restrictions[i]}_select_2 option`).each(function (i) {
242242
$(this).prop('selected', true);
243243
});
244+
245+
if (restrictions[i] === 'cart_rule') {
246+
$(`#cart_rule_select_1 option`).each(function (i) {
247+
$(this).prop('selected', true);
248+
});
249+
}
244250
}
245251

246252
$('.product_rule_toselect option').each(function (i) {

admin-dev/themes/new-theme/js/components/country-state-selection-toggler.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export default class CountryStateSelectionToggler {
5353
*/
5454
private onChange(): void {
5555
const countryId = this.$countryInput.val();
56+
const selectedStateId = this.$countryStateSelector.val();
5657

5758
if (countryId === '') {
5859
return;
@@ -71,6 +72,7 @@ export default class CountryStateSelectionToggler {
7172
this.$countryStateSelector.append(
7273
$('<option></option>')
7374
.attr('value', response.states[value])
75+
.prop('selected', String(selectedStateId) === String(response.states[value]))
7476
.text(value),
7577
);
7678
});

classes/Cart.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,6 +1680,18 @@ public function updateQty(
16801680
}
16811681

16821682
if (!Validate::isLoadedObject($product)) {
1683+
// Product may have been deleted from catalog but still exist in a cart/order; deleteProduct only needs IDs.
1684+
if ($operator === 'down') {
1685+
PrestaShopLogger::addLog(
1686+
sprintf('Cart::updateQty - Product with ID "%s" could not be loaded, removing it from cart.', $id_product),
1687+
PrestaShopLogger::LOG_SEVERITY_LEVEL_WARNING,
1688+
null,
1689+
'Cart',
1690+
(int) $this->id
1691+
);
1692+
1693+
return $this->deleteProduct($id_product, $id_product_attribute, (int) $id_customization, 0, $preserveGiftRemoval, $useOrderPrices);
1694+
}
16831695
throw new PrestaShopException(sprintf('Product with ID "%s" could not be loaded.', $id_product));
16841696
}
16851697

classes/Tools.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1926,11 +1926,11 @@ public static function createFileFromUrl($url)
19261926
if (!in_array(strtolower($scheme), ['http', 'https'], true)) {
19271927
return false;
19281928
}
1929-
$remoteFile = fopen($url, 'rb');
1929+
$remoteFile = @fopen($url, 'rb');
19301930
if (!$remoteFile) {
19311931
return false;
19321932
}
1933-
$localFile = fopen(basename($url), 'wb');
1933+
$localFile = @fopen(basename($url), 'wb');
19341934
if (!$localFile) {
19351935
return false;
19361936
}

classes/form/CustomerAddressForm.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,17 @@ public function validate()
112112
}
113113
}
114114

115+
$stateField = $this->getField('id_state');
116+
if ($stateField && $stateField->getValue() && !empty($stateField->getAvailableValues())
117+
&& !array_key_exists($stateField->getValue(), $stateField->getAvailableValues())) {
118+
$stateField->addError($this->translator->trans(
119+
'This state is not valid for the selected country.',
120+
[],
121+
'Shop.Forms.Errors'
122+
));
123+
$is_valid = false;
124+
}
125+
115126
if ($is_valid && Hook::exec('actionValidateCustomerAddressForm', ['form' => $this]) === false) {
116127
$is_valid = false;
117128
}

classes/module/Module.php

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3060,7 +3060,7 @@ public function addOverride($classname)
30603060
throw new Exception(Context::getContext()->getTranslator()->trans('The constant %1$s in the class %2$s is already defined.', [$constant, $classname], 'Admin.Modules.Notification'));
30613061
}
30623062

3063-
$module_file = preg_replace('/(const\s)\s*(\b' . $constant . '\b)/ism', "/*\n * module: " . $this->name . "\n * date: " . date('Y-m-d H:i:s') . "\n * version: " . $this->version . "\n */\n $1$2", $module_file);
3063+
$module_file = preg_replace('/((?:public|private|protected)\s+)?(?:static\s+)?(const\s)\s*(\b' . $constant . '\b)/ism', "/*\n * module: " . $this->name . "\n * date: " . date('Y-m-d H:i:s') . "\n * version: " . $this->version . "\n */\n $1$2$3", $module_file);
30643064
if ($module_file === null) {
30653065
throw new Exception(Context::getContext()->getTranslator()->trans('Failed to override constant %1$s in class %2$s.', [$constant, $classname], 'Admin.Modules.Notification'));
30663066
}
@@ -3124,7 +3124,7 @@ public function addOverride($classname)
31243124

31253125
// Same loop for constants
31263126
foreach ($module_class->getConstants() as $constant => $value) {
3127-
$module_file = preg_replace('/(const\s)\s*(\b' . $constant . '\b)/ism', "/*\n * module: " . $this->name . "\n * date: " . date('Y-m-d H:i:s') . "\n * version: " . $this->version . "\n */\n $1$2", $module_file);
3127+
$module_file = preg_replace('/((?:public|private|protected)\s+)?(?:static\s+)?(const\s)\s*(\b' . $constant . '\b)/ism', "/*\n * module: " . $this->name . "\n * date: " . date('Y-m-d H:i:s') . "\n * version: " . $this->version . "\n */\n $1$2$3", $module_file);
31283128
if ($module_file === null) {
31293129
throw new Exception(Context::getContext()->getTranslator()->trans('Failed to override constant %1$s in class %2$s.', [$constant, $classname], 'Admin.Modules.Notification'));
31303130
}
@@ -3281,34 +3281,64 @@ public function removeOverride($classname)
32813281
continue;
32823282
}
32833283

3284-
// Replace the declaration line by #--remove--#
3284+
// Replace all declaration lines by #--remove--#, tracking bracket depth
3285+
// to handle multi-line property values (e.g. arrays spanning multiple lines)
3286+
$inside_property = false;
3287+
$bracket_depth = 0;
32853288
foreach ($override_file as $line_number => &$line_content) {
3286-
if (preg_match('/(public|private|protected)\s+(static\s+)?\s*(\w+\s+)?(\$)?' . $property->getName() . '/i', $line_content)) {
3287-
if (preg_match('/\* module: (' . $this->name . ')/ism', $override_file[$line_number - 4])) {
3288-
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
3289+
if (!$inside_property) {
3290+
if (preg_match('/(public|private|protected)\s+(static\s+)?\s*(\w+\s+)?(\$)?' . $property->getName() . '/i', $line_content)) {
3291+
if (preg_match('/\* module: (' . $this->name . ')/ism', $override_file[$line_number - 4])) {
3292+
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
3293+
}
3294+
$inside_property = true;
3295+
$bracket_depth = 0;
32893296
}
3297+
}
3298+
3299+
if ($inside_property) {
3300+
$bracket_depth += substr_count($line_content, '(') - substr_count($line_content, ')');
3301+
$bracket_depth += substr_count($line_content, '[') - substr_count($line_content, ']');
3302+
$is_end = ($bracket_depth <= 0 && false !== strpos($line_content, ';'));
32903303
$line_content = '#--remove--#';
32913304

3292-
break;
3305+
if ($is_end) {
3306+
break;
3307+
}
32933308
}
32943309
}
32953310
}
32963311

3297-
// Remove properties from override file
3312+
// Remove constants from override file
32983313
foreach ($module_class->getConstants() as $constant => $value) {
32993314
if (!$override_class->hasConstant($constant)) {
33003315
continue;
33013316
}
33023317

3303-
// Replace the declaration line by #--remove--#
3318+
// Replace all declaration lines by #--remove--#, tracking bracket depth
3319+
// to handle multi-line constant values (e.g. arrays spanning multiple lines)
3320+
$inside_constant = false;
3321+
$bracket_depth = 0;
33043322
foreach ($override_file as $line_number => &$line_content) {
3305-
if (preg_match('/(const)\s+(static\s+)?(\$)?' . $constant . '/i', $line_content)) {
3306-
if (preg_match('/\* module: (' . $this->name . ')/ism', $override_file[$line_number - 4])) {
3307-
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
3323+
if (!$inside_constant) {
3324+
if (preg_match('/(const)\s+(static\s+)?(\$)?' . $constant . '/i', $line_content)) {
3325+
if (preg_match('/\* module: (' . $this->name . ')/ism', $override_file[$line_number - 4])) {
3326+
$override_file[$line_number - 5] = $override_file[$line_number - 4] = $override_file[$line_number - 3] = $override_file[$line_number - 2] = $override_file[$line_number - 1] = '#--remove--#';
3327+
}
3328+
$inside_constant = true;
3329+
$bracket_depth = 0;
33083330
}
3331+
}
3332+
3333+
if ($inside_constant) {
3334+
$bracket_depth += substr_count($line_content, '(') - substr_count($line_content, ')');
3335+
$bracket_depth += substr_count($line_content, '[') - substr_count($line_content, ']');
3336+
$is_end = ($bracket_depth <= 0 && false !== strpos($line_content, ';'));
33093337
$line_content = '#--remove--#';
33103338

3311-
break;
3339+
if ($is_end) {
3340+
break;
3341+
}
33123342
}
33133343
}
33143344
}

classes/order/OrderDetail.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -777,12 +777,14 @@ protected function create(Order $order, Cart $cart, $product, $id_order_state, $
777777
$this->id_shop = (int) $product['id_shop'];
778778

779779
// Add new entry to the table
780-
$this->save();
780+
$result = $this->save();
781781

782782
if ($use_taxes) {
783783
$this->saveTaxCalculator($order);
784784
}
785785
unset($this->tax_calculator);
786+
787+
return (bool) $result;
786788
}
787789

788790
/**
@@ -805,7 +807,11 @@ public function createList(Order $order, Cart $cart, $id_order_state, $product_l
805807
$this->outOfStock = false;
806808

807809
foreach ($product_list as $product) {
808-
$this->create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes);
810+
if (!$this->create($order, $cart, $product, $id_order_state, $id_order_invoice, $use_taxes)) {
811+
throw new PrestaShopException(
812+
sprintf('Failed to create order detail for product id %d', (int) $product['id_product'])
813+
);
814+
}
809815
}
810816

811817
unset(

classes/shop/Shop.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,11 @@ public function copyShopData($old_id, $tables_import = false, $deleted = false)
12041204
$old_id = Configuration::get('PS_SHOP_DEFAULT');
12051205
}
12061206

1207+
// Default currency import to avoid missing currency data when the option is not explicitly set.
1208+
if (!isset($tables_import['currency'])) {
1209+
$tables_import['currency'] = 'on';
1210+
}
1211+
12071212
if (isset($tables_import['carrier'])) {
12081213
$tables_import['carrier_tax_rules_group_shop'] = true;
12091214
$tables_import['carrier_lang'] = true;

0 commit comments

Comments
 (0)