From 367173a4d160e61ca034cf275d67245ce56f8ba1 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sat, 4 Jan 2025 08:20:18 +0100 Subject: [PATCH 01/10] FIX clean unique extrafields when create product combination --- htdocs/core/class/commonobject.class.php | 6 ++++++ htdocs/variants/class/ProductCombination.class.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 5c8fb1cfebf..66ea879552f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6558,6 +6558,12 @@ abstract class CommonObject $new_array_options[$key] = null; } + // If we create product combination, we have to clean unique extrafields to prevent duplicates. + // This behaviour can be prevented by external code by changing $this->context['createproductcombination'] value in hook + if (!empty($this->context['createproductcombination']) && $this->context['createproductcombination'] == 'createproductcombination' && !empty($attributeUnique)) { + $new_array_options[$key] = null; + } + // Similar code than into insertExtraFields if ($attributeRequired) { $v = $this->array_options[$key]; diff --git a/htdocs/variants/class/ProductCombination.class.php b/htdocs/variants/class/ProductCombination.class.php index 228dc347c42..339e9f84934 100644 --- a/htdocs/variants/class/ProductCombination.class.php +++ b/htdocs/variants/class/ProductCombination.class.php @@ -783,6 +783,9 @@ class ProductCombination $newproduct = clone $product; } + // To avoid warning with unique extrafields values + $newproduct->context['createproductcombination'] = 'createproductcombination'; + //Final weight impact $weight_impact = (float) $forced_weightvar; // If false, return 0 From 91b90d7409b4a206998972327d2bd9b741573edb Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 15:41:29 +0100 Subject: [PATCH 02/10] FIX avoid phan error --- htdocs/commande/class/commande.class.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index eeaadca9ada..16bffa5f448 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4465,6 +4465,7 @@ class OrderLine extends CommonOrderLine { $error = 0; + // @phpstan-ignore-next-line @phan-suppress-next-line PhanTypeMismatchProperty $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. $this->pa_ht = (float) $this->pa_ht; // convert to float after check if empty value From d42c8ba012496cefcfdca1f4b546158cde86a7f8 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 15:50:09 +0100 Subject: [PATCH 03/10] FIX quelle perte de temps --- htdocs/commande/class/commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 16bffa5f448..e6b0dac13ed 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1535,6 +1535,7 @@ class Commande extends CommonOrder $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); $pu_ttc = price2num($pu_ttc); + // @phpstan-ignore-next-line @phan-suppress-next-line PhanTypeMismatchProperty $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring if (!preg_match('/\((.*)\)/', (string) $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' @@ -4465,7 +4466,6 @@ class OrderLine extends CommonOrderLine { $error = 0; - // @phpstan-ignore-next-line @phan-suppress-next-line PhanTypeMismatchProperty $pa_ht_isemptystring = (empty($this->pa_ht) && $this->pa_ht == ''); // If true, we can use a default value. If this->pa_ht = '0', we must use '0'. $this->pa_ht = (float) $this->pa_ht; // convert to float after check if empty value From 22ed2d6a259178fd46e93639e5c5d89dbe0744c7 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 16:02:23 +0100 Subject: [PATCH 04/10] FIX tic tac tic tac --- htdocs/commande/class/commande.class.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index e6b0dac13ed..cf754586c9f 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1535,7 +1535,6 @@ class Commande extends CommonOrder $pu_ht = price2num($pu_ht); $pu_ht_devise = price2num($pu_ht_devise); $pu_ttc = price2num($pu_ttc); - // @phpstan-ignore-next-line @phan-suppress-next-line PhanTypeMismatchProperty $pa_ht = price2num($pa_ht); // do not convert to float here, it breaks the functioning of $pa_ht_isemptystring if (!preg_match('/\((.*)\)/', (string) $txtva)) { $txtva = price2num($txtva); // $txtva can have format '5,1' or '5.1' or '5.1(XXX)', we must clean only if '5,1' @@ -4248,7 +4247,7 @@ class OrderLine extends CommonOrderLine /** * Buy price without taxes - * @var float + * @var float|null */ public $pa_ht; public $marge_tx; From 56e03c5d19b76a8f9e720f459c1aa14364d911d0 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 5 Jan 2025 16:09:03 +0100 Subject: [PATCH 05/10] FIX on the road again --- htdocs/commande/class/commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index cf754586c9f..26bb1125cbf 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -4247,7 +4247,7 @@ class OrderLine extends CommonOrderLine /** * Buy price without taxes - * @var float|null + * @var float|string|null */ public $pa_ht; public $marge_tx; From 9ecc88230f20985bf8de2c5175e42d12e22683c8 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:08:02 +0100 Subject: [PATCH 06/10] Test pr action --- .github/workflows/test.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 5a41c986098..97f218fce4d 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -3,8 +3,7 @@ on: workflow_dispatch: pull_request: types: [opened, reopened, synchronize] - branches: - - "18.0" + push: env: ENVGHT: ${{ secrets.GITHUB_TOKEN }} From 1866713082e5014be36e0c2be5fc4239f0e41143 Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:10:00 +0100 Subject: [PATCH 07/10] Avoid error --- .github/workflows/pr-18.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-18.yaml b/.github/workflows/pr-18.yaml index f3ffa3a2e24..04b4b0ff35e 100644 --- a/.github/workflows/pr-18.yaml +++ b/.github/workflows/pr-18.yaml @@ -32,7 +32,7 @@ jobs: run: | gh pr edit "$url" --add-assignee rycks --add-reviewer rycks gh pr merge "$url" --merge --auto - + continue-on-error: true - name: Assign reviewer method 2 env: From 8805b8cac42be762a16478705e59c1600d173a4d Mon Sep 17 00:00:00 2001 From: "Laurent Destailleur (aka Eldy)" Date: Sun, 5 Jan 2025 17:22:30 +0100 Subject: [PATCH 08/10] Exclude test files --- .pre-commit-config.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3296110422c..82eb45c1d0b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -81,6 +81,8 @@ repos: ] pass_filenames: false # Run on all files - id: php-lint + exclude: + (?x)^(htdocs/includes/symfony/var-dumper/Tests/.*)$ - id: php-stan stages: [manual] files: \.(php)$ From eb4e05968360383d98b993e7ec5a7a4016110132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20France?= Date: Sat, 4 Jan 2025 16:24:17 +0100 Subject: [PATCH 09/10] fix --- .../includes/tecnickcom/tcpdf/include/barcodes/pdf417.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php b/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php index 3b1774eaae4..9a58a21f673 100644 --- a/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php +++ b/htdocs/includes/tecnickcom/tcpdf/include/barcodes/pdf417.php @@ -878,7 +878,7 @@ class PDF417 { $txtarr = array(); // array of characters and sub-mode switching characters $codelen = strlen($code); for ($i = 0; $i < $codelen; ++$i) { - $chval = ord($code{$i}); + $chval = ord($code[$i]); if (($k = array_search($chval, $this->textsubmodes[$submode])) !== false) { // we are on the same sub-mode $txtarr[] = $k; @@ -888,7 +888,7 @@ class PDF417 { // search new sub-mode if (($s != $submode) AND (($k = array_search($chval, $this->textsubmodes[$s])) !== false)) { // $s is the new submode - if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code{($i + 1)}), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { + if (((($i + 1) == $codelen) OR ((($i + 1) < $codelen) AND (array_search(ord($code[($i + 1)]), $this->textsubmodes[$submode]) !== false))) AND (($s == 3) OR (($s == 0) AND ($submode == 1)))) { // shift (temporary change only for this char) if ($s == 3) { // shift to puntuaction @@ -952,7 +952,7 @@ class PDF417 { $cw = array_merge($cw, $cw6); } else { for ($i = 0; $i < $sublen; ++$i) { - $cw[] = ord($code{$i}); + $cw[] = ord($code[$i]); } } $code = $rest; From b3c286a673f23cc2b955a2cee80ccb2e2f02f720 Mon Sep 17 00:00:00 2001 From: Erik van Berkum Date: Sun, 5 Jan 2025 16:44:41 +0900 Subject: [PATCH 10/10] FIX units product solves issue #32495: current Empty testing for 0 results in TRUE and makes it an empty string. Testing for is_null solves the issue. this issue is connected with pull FIX #32496 --- htdocs/product/class/product.class.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 7db4a3480b3..5264b2a1667 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1092,19 +1092,19 @@ class Product extends CommonObject $this->note_private = (isset($this->note_private) ? trim($this->note_private) : null); $this->note_public = (isset($this->note_public) ? trim($this->note_public) : null); $this->net_measure = price2num($this->net_measure); - $this->net_measure_units = (empty($this->net_measure_units) ? '' : trim($this->net_measure_units)); + $this->net_measure_units = (is_null($this->net_measure_units) ? '' : trim((string) $this->net_measure_units)); $this->weight = price2num($this->weight); - $this->weight_units = (empty($this->weight_units) ? '' : trim($this->weight_units)); + $this->weight_units = (is_null($this->weight_units) ? '' : trim((string) $this->weight_units)); $this->length = price2num($this->length); - $this->length_units = (empty($this->length_units) ? '' : trim($this->length_units)); + $this->length_units = (is_null($this->length_units) ? '' : trim((string) $this->length_units)); $this->width = price2num($this->width); - $this->width_units = (empty($this->width_units) ? '' : trim($this->width_units)); + $this->width_units = (is_null($this->width_units) ? '' : trim((string) $this->width_units)); $this->height = price2num($this->height); - $this->height_units = (empty($this->height_units) ? '' : trim($this->height_units)); + $this->height_units = (is_null($this->height_units) ? '' : trim((string) $this->height_units)); $this->surface = price2num($this->surface); - $this->surface_units = (empty($this->surface_units) ? '' : trim($this->surface_units)); + $this->surface_units = (is_null($this->surface_units) ? '' : trim((string) $this->surface_units)); $this->volume = price2num($this->volume); - $this->volume_units = (empty($this->volume_units) ? '' : trim($this->volume_units)); + $this->volume_units = (is_null($this->volume_units) ? '' : trim((string) $this->volume_units)); // set unit not defined if (is_numeric($this->length_units)) {