From 0a8a8ecd72d7f41a634c9713f6a0341e80a05591 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 10 Mar 2023 13:48:27 +0100 Subject: [PATCH 1/3] save function --- core/class/jsondb/JsonDb.class.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index 5e87d359..b9dbfd78 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -142,17 +142,18 @@ class JsonDb extends \Prowebcraft\Dot */ public function save() { - $lenght = strlen(json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | LOCK_EX)); - $try = 0; - while ($try < 5) { - $written = file_put_contents($this->db, json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | LOCK_EX)); // Multi user get a locker - if ($written == $lenght) { + $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | LOCK_EX); + $l = strlen($v); + $t = 0; + while ($t < 5) { + $w = file_put_contents($this->db, $v); // Multi user get a locker + if ($w == $l) { break; } $try++; sleep(1); } - if ($written !== $lenght) { + if ($w !== $l) { exit('Erreur d\'écriture, les données n\'ont pas été sauvegardées'); } From 508ec87c96b22bd02d0c0981bc58567a139603f9 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 10 Mar 2023 13:59:46 +0100 Subject: [PATCH 2/3] better json save --- core/class/jsondb/JsonDb.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index b9dbfd78..7d5332a5 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -142,7 +142,7 @@ class JsonDb extends \Prowebcraft\Dot */ public function save() { - $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | LOCK_EX); + $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | LOCK_EX); $l = strlen($v); $t = 0; while ($t < 5) { From 7669918abbd3dbb0b8429059724514efa809d192 Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Fri, 10 Mar 2023 14:10:31 +0100 Subject: [PATCH 3/3] bug font edit --- CHANGES.md | 1 + core/module/theme/theme.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 9daaf08d..7bc8c21c 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ - Mauvais affichage du script ou du CSS déclarés dans une page. - Choix de la langue dans TinyMCE et CodeMirror. - Mauvaise application des fontes dans l'administration du thème. +- Corrige une mauvaise lecture du type de fonte éditée. - Correction de petits bugs. ### Nouveautés : - Remplacement du sélecteur de date Flatpickr par le sélecteur HTML 5 qui autorise les formats suivants : date, time, week, month, datetime-local. diff --git a/core/module/theme/theme.php b/core/module/theme/theme.php index eccf0691..ae8a834b 100644 --- a/core/module/theme/theme.php +++ b/core/module/theme/theme.php @@ -657,7 +657,7 @@ class theme extends common // Soumission du formulaire if ($this->isPost()) { // Type d'import en ligne ou local - $type = $this->getInput('fontAddFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; + $type = $this->getInput('fontAddUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $typeFlip = $type === 'files' ? 'imported' : 'files'; $ressource = $type === 'imported' ? $this->getInput('fontAddUrl', null) : $this->getInput('fontAddFile', null); if (!empty($ressource)) { @@ -723,8 +723,7 @@ class theme extends common // Soumission du formulaire if ($this->isPost()) { // Type d'import en ligne ou local - $type = $this->getInput('fontEditFontImported', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; - $typeFlip = $type === 'files' ? 'imported' : 'files'; + $type = $this->getInput('fontEditUrl', helper::FILTER_BOOLEAN) ? 'imported' : 'files'; $ressource = $type === 'imported' ? $this->getInput('fontEditUrl', null) : $this->getInput('fontEditFile', null); $fontId = $this->getInput('fontEditFontId', null, true); $fontName = $this->getInput('fontEditFontName', null, true); @@ -734,9 +733,10 @@ class theme extends common $fontFamilyName = str_replace('"', '\'', $fontFamilyName); // Supprime la fonte si elle existe dans le type inverse - if (is_array($this->getData(['fonts', $typeFlip, $fontId]))) { - $this->deleteData(['fonts', $typeFlip, $fontId]); + if (is_array($this->getData(['fonts', $type, $fontId]))) { + $this->deleteData(['fonts', $type, $fontId]); } + // Stocker les fontes $this->setData([ 'fonts',