Json vérif
This commit is contained in:
parent
4e174124fe
commit
14683133c8
@ -130,8 +130,8 @@ class JsonDb extends \Prowebcraft\Dot
|
|||||||
}
|
}
|
||||||
$this->data = json_decode(file_get_contents($this->db), true);
|
$this->data = json_decode(file_get_contents($this->db), true);
|
||||||
if (!$this->data === null && json_last_error() !== JSON_ERROR_NONE) {
|
if (!$this->data === null && json_last_error() !== JSON_ERROR_NONE) {
|
||||||
throw new \InvalidArgumentException('Database file ' . $this->db
|
throw new \InvalidArgumentException('Le fichier ' . $this->db
|
||||||
. ' contains invalid json object. Please validate or remove file');
|
. ' contient des données invalides.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $this->data;
|
return $this->data;
|
||||||
@ -146,6 +146,10 @@ class JsonDb extends \Prowebcraft\Dot
|
|||||||
// $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
// $v = json_encode($this->data, JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT);
|
||||||
$l = strlen($v);
|
$l = strlen($v);
|
||||||
$t = 0;
|
$t = 0;
|
||||||
|
if ($v === false) {
|
||||||
|
error_log('Erreur d\'encodage JSON : ' . json_last_error_msg());
|
||||||
|
exit ('Erreur d\'encodage JSON : ' . json_last_error_msg());
|
||||||
|
}
|
||||||
while ($t < 5) {
|
while ($t < 5) {
|
||||||
$w = file_put_contents($this->db, $v); // Multi user get a locker
|
$w = file_put_contents($this->db, $v); // Multi user get a locker
|
||||||
if ($w == $l) {
|
if ($w == $l) {
|
||||||
|
Loading…
Reference in New Issue
Block a user