From 459f55081cad9818a0390cdeef41e068d4b6117a Mon Sep 17 00:00:00 2001 From: Fred Tempez Date: Tue, 3 Nov 2020 07:48:56 +0100 Subject: [PATCH] warning primo installation --- CHANGES.md | 1 + core/class/jsondb/JsonDb.class.php | 27 +++++++-------------------- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index a8183c40..3e8871ab 100755 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,7 @@ - Thème : import d'un thème, nettoyage du dossier tmp. - Thème administration : modification de l'appel du code CSS permettant une mise à jour du thème sans vider le cache. - Thème du menu : alignement inopérant ; arrière-plan semi-transparent non uniforme. + - Supprime les warning lors d'une primo installation. - Amélioration : - Thème menu : couleurs du sous menu. - Mise en page du corps des mails de notification. diff --git a/core/class/jsondb/JsonDb.class.php b/core/class/jsondb/JsonDb.class.php index 1dc7cbbd..3e9ce04c 100644 --- a/core/class/jsondb/JsonDb.class.php +++ b/core/class/jsondb/JsonDb.class.php @@ -102,29 +102,16 @@ class JsonDb extends \Prowebcraft\Dot if ($this->data === null || $reload) { // $this->db = $this->config['dir'] . DIRECTORY_SEPARATOR . $this->config['name']; $this->db = $this->config['dir'] . $this->config['name']; - /* - if (!file_exists($this->db)) { - $templateFile = $this->config['template']; - if (file_exists($templateFile)) { - copy($templateFile, $this->db); - } else { - file_put_contents($this->db, '{}'); - } - } else { - if ($this->config['backup']) { - try { - //todo make backup of database - } catch (\Exception $e) { - } + if (!file_exists($this->db)) { + return null; + } else { + $this->data = json_decode(file_get_contents($this->db), true); + if (!$this->data === null) { + throw new \InvalidArgumentException('Database file ' . $this->db + . ' contains invalid json object. Please validate or remove file'); } } - */ - $this->data = json_decode(file_get_contents($this->db), true); - if (!$this->data === null) { - throw new \InvalidArgumentException('Database file ' . $this->db - . ' contains invalid json object. Please validate or remove file'); - } } return $this->data; }