From 1b30f7e0ea1e5585dfed449b7045304e3cb12f78 Mon Sep 17 00:00:00 2001 From: stephan Date: Sat, 27 Jun 2026 14:57:01 -0400 Subject: [PATCH] Refactor cookie consent management to improve label handling This commit updates the `fxEnsureLegalPage` function to utilize the `fxLegalLabelIsDraft` function for checking and updating French and English labels. This change enhances the clarity and maintainability of the code by ensuring that labels are only updated when they are in draft status, aligning with the overall improvements in cookie consent management. --- php/inc_cookie_consent.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/php/inc_cookie_consent.php b/php/inc_cookie_consent.php index ea38c7d..f4a4a87 100644 --- a/php/inc_cookie_consent.php +++ b/php/inc_cookie_consent.php @@ -576,11 +576,19 @@ function fxEnsureLegalPage(string $code, string $labelFr, string $labelEn, strin $updates[] = "pag_texte_en = '" . $objDatabase->fxEscape($textEn) . "'"; } - if (trim((string) $row['pag_titre_fr']) === '') { + if (fxLegalLabelIsDraft((string) $row['pag_label_fr'])) { + $updates[] = "pag_label_fr = '" . $objDatabase->fxEscape($labelFr) . "'"; + } + + if (fxLegalLabelIsDraft((string) $row['pag_label_en'])) { + $updates[] = "pag_label_en = '" . $objDatabase->fxEscape($labelEn) . "'"; + } + + if (fxLegalLabelIsDraft((string) $row['pag_titre_fr'])) { $updates[] = "pag_titre_fr = '" . $objDatabase->fxEscape($titleFr) . "'"; } - if (trim((string) $row['pag_titre_en']) === '') { + if (fxLegalLabelIsDraft((string) $row['pag_titre_en'])) { $updates[] = "pag_titre_en = '" . $objDatabase->fxEscape($titleEn) . "'"; }