From af5de05a31cdd5f6d204033f8b75a5d35361e0a1 Mon Sep 17 00:00:00 2001 From: "gael.langlais" Date: Fri, 22 May 2020 17:42:06 +0200 Subject: [PATCH 1/4] Change some curly braces #13929 --- htdocs/contact/list.php | 11 +++++------ htdocs/core/antispamimage.php | 2 +- htdocs/core/class/lessc.class.php | 6 +++--- htdocs/core/lib/security2.lib.php | 16 ++++++++-------- 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 9e7485d189f..7eee6d797e7 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -76,7 +76,7 @@ $search_no_email = GETPOST("search_no_email", 'int'); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_{$key} = GETPOST("search_".$key, 'alpha'); + $search_[$key] = GETPOST("search_".$key, 'alpha'); } } } @@ -253,7 +253,7 @@ if (empty($reshook)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_{$key} = ""; + $search_[$key] = ""; } } } @@ -357,9 +357,8 @@ if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $se if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if ($value['active'] && strlen($search_{$key})) { - //$sql.= natural_search("p.socialnetworks->'$.".$key."'", $search_{$key}); - $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; + if ($value['active'] && strlen($search_[$key])) { + $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_[$key].'%\''; } } } @@ -669,7 +668,7 @@ if (!empty($conf->socialnetworks->enabled)) { if (!empty($arrayfields['p.'.$key]['checked'])) { print ''; - print ''; + print ''; print ''; } } diff --git a/htdocs/core/antispamimage.php b/htdocs/core/antispamimage.php index 68e585c3ea0..7d6512a64a9 100644 --- a/htdocs/core/antispamimage.php +++ b/htdocs/core/antispamimage.php @@ -43,7 +43,7 @@ $number = strlen($letters); $string = ''; for ($i = 0; $i < $length; $i++) { - $string .= $letters{mt_rand(0, $number - 1)}; + $string .= $letters[mt_rand(0, $number - 1)]; } //print $string; diff --git a/htdocs/core/class/lessc.class.php b/htdocs/core/class/lessc.class.php index 210c3d3c29d..8ab9e58aa58 100644 --- a/htdocs/core/class/lessc.class.php +++ b/htdocs/core/class/lessc.class.php @@ -1966,7 +1966,7 @@ class Lessc { $this->pushEnv(); $parser = new lessc_parser($this, __METHOD__); foreach ($args as $name => $strValue) { - if ($name{0} !== '@') { + if ($name[0] !== '@') { $name = '@'.$name; } $parser->count = 0; @@ -2638,7 +2638,7 @@ class lessc_parser { $hidden = true; if (!isset($block->args)) { foreach ($block->tags as $tag) { - if (!is_string($tag) || $tag{0} != $this->lessc->mPrefix) { + if (!is_string($tag) || $tag[0] != $this->lessc->mPrefix) { $hidden = false; break; } @@ -2692,7 +2692,7 @@ class lessc_parser { protected function fixTags($tags) { // move @ tags out of variable namespace foreach ($tags as &$tag) { - if ($tag{0} == $this->lessc->vPrefix) + if ($tag[0] == $this->lessc->vPrefix) $tag[0] = $this->lessc->mPrefix; } return $tags; diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index 04d16084365..c7f5a7b7330 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -463,15 +463,15 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len { $max = strlen($lowercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $lowercase{random_int(0, $max)}; + $randomCode .= $lowercase[random_int(0, $max)]; } $max = strlen($uppercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $uppercase{random_int(0, $max)}; + $randomCode .= $uppercase[random_int(0, $max)]; } $max = strlen($numbers) - 1; for ($x = 0; $x < $nbofcharlast; $x++) { - $randomCode .= $numbers{random_int(0, $max)}; + $randomCode .= $numbers[random_int(0, $max)]; } $generated_password = str_shuffle($randomCode); @@ -480,15 +480,15 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len { $max = strlen($lowercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $lowercase{mt_rand(0, $max)}; + $randomCode .= $lowercase[mt_rand(0, $max)]; } $max = strlen($uppercase) - 1; for ($x = 0; $x < $nbofchar; $x++) { - $randomCode .= $uppercase{mt_rand(0, $max)}; + $randomCode .= $uppercase[mt_rand(0, $max)]; } $max = strlen($numbers) - 1; for ($x = 0; $x < $nbofcharlast; $x++) { - $randomCode .= $numbers{mt_rand(0, $max)}; + $randomCode .= $numbers[mt_rand(0, $max)]; } $generated_password = str_shuffle($randomCode); @@ -512,11 +512,11 @@ function getRandomPassword($generic = false, $replaceambiguouschars = null, $len $max = strlen($numbers) - 1; if (function_exists('random_int')) // Cryptographic random { - $generated_password = str_replace($replaceambiguouschars, $numbers{random_int(0, $max)}, $generated_password); + $generated_password = str_replace($replaceambiguouschars, $numbers[random_int(0, $max)], $generated_password); } else { - $generated_password = str_replace($replaceambiguouschars, $numbers{mt_rand(0, $max)}, $generated_password); + $generated_password = str_replace($replaceambiguouschars, $numbers[mt_rand(0, $max)], $generated_password); } } From 15de6194c4b61c3b73f30aab91aca5680eea0e10 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 13:36:02 +0200 Subject: [PATCH 2/4] Update list.php --- htdocs/contact/list.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 7eee6d797e7..8ee51ca815e 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -76,7 +76,7 @@ $search_no_email = GETPOST("search_no_email", 'int'); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_[$key] = GETPOST("search_".$key, 'alpha'); + $search_{$key} = GETPOST("search_".$key, 'alpha'); } } } @@ -253,7 +253,7 @@ if (empty($reshook)) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active']) { - $search_[$key] = ""; + $search_{$key} = ""; } } } @@ -358,7 +358,7 @@ if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax) if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { if ($value['active'] && strlen($search_[$key])) { - $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_[$key].'%\''; + $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; } } } From 493becde8b06a830a5dba611dea008058a16cdb5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 13:36:39 +0200 Subject: [PATCH 3/4] Update list.php --- htdocs/contact/list.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index 8ee51ca815e..781daacd030 100644 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -357,7 +357,7 @@ if (strlen($search_phone_mobile)) $sql .= natural_search('p.phone_mobile', $se if (strlen($search_fax)) $sql .= natural_search('p.fax', $search_fax); if (!empty($conf->socialnetworks->enabled)) { foreach ($socialnetworks as $key => $value) { - if ($value['active'] && strlen($search_[$key])) { + if ($value['active'] && strlen($search_{$key})) { $sql .= ' AND p.socialnetworks LIKE \'%"'.$key.'":"'.$search_{$key}.'%\''; } } @@ -668,7 +668,7 @@ if (!empty($conf->socialnetworks->enabled)) { if (!empty($arrayfields['p.'.$key]['checked'])) { print ''; - print ''; + print ''; print ''; } } From 83ecbef9bc3ec4449262b4b6b8e8ae7371e11617 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 23 May 2020 13:46:37 +0200 Subject: [PATCH 4/4] FIX #13911 #13940 --- htdocs/variants/class/ProductCombination.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index f19c81960db..128c1974c77 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -327,7 +327,10 @@ class ProductCombination $child = new Product($this->db); $child->fetch($this->fk_product_child); $child->price_autogen = $parent->price_autogen; - $child->weight = $parent->weight + $this->variation_weight; + $child->weight = $parent->weight; + if ($this->variation_weight) { // If we must add a delta on weight + $child->weight = ($child->weight ? $child->weight : 0) + $this->variation_weight; + } $child->weight_units = $parent->weight_units; $varlabel = $this->getCombinationLabel($this->fk_product_child); $child->label = $parent->label.$varlabel;