From 9aa3f278560491ef2099672e29587cc3eb0c3887 Mon Sep 17 00:00:00 2001 From: Git'Fellow Date: Fri, 1 Apr 2022 14:54:47 +0200 Subject: [PATCH 1/4] Try to fix Incorrect format detection Should fix #829 --- lib/Model/Circle.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Model/Circle.php b/lib/Model/Circle.php index 03c54e394..ceebeb6f6 100644 --- a/lib/Model/Circle.php +++ b/lib/Model/Circle.php @@ -912,7 +912,8 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow ->setDescription($this->get($prefix . 'description', $data)); $creation = $this->get($prefix . 'creation', $data); - $this->setCreation(DateTime::createFromFormat('Y-m-d H:i:s', $creation)->getTimestamp()); + $timestamp = DateTime::createFromFormat('Y-m-d H:i:s', $creation)->getTimestamp() ?? (int) strtotime('Y-m-d H:i:s', $creation); + $this->setCreation($timestamp); $this->setPopulation($this->getInt('population', $this->getSettings())); $this->setPopulationInherited($this->getInt('populationInherited', $this->getSettings())); From ee2b7938773d3be08c362e7cefd6c2ad6348aec3 Mon Sep 17 00:00:00 2001 From: Git'Fellow Date: Fri, 1 Apr 2022 18:07:16 +0200 Subject: [PATCH 2/4] Move to ternary operator --- lib/Model/Circle.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Model/Circle.php b/lib/Model/Circle.php index ceebeb6f6..1fb8f12fb 100644 --- a/lib/Model/Circle.php +++ b/lib/Model/Circle.php @@ -912,8 +912,8 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow ->setDescription($this->get($prefix . 'description', $data)); $creation = $this->get($prefix . 'creation', $data); - $timestamp = DateTime::createFromFormat('Y-m-d H:i:s', $creation)->getTimestamp() ?? (int) strtotime('Y-m-d H:i:s', $creation); - $this->setCreation($timestamp); + $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $creation); + $timestamp = $dateTime ? $dateTime->getTimestamp() : (int) strtotime('Y-m-d H:i:s', $creation); $this->setPopulation($this->getInt('population', $this->getSettings())); $this->setPopulationInherited($this->getInt('populationInherited', $this->getSettings())); From 3b2b73e0e59c821beacfe9b0bf3587ed0068a264 Mon Sep 17 00:00:00 2001 From: Git'Fellow Date: Fri, 1 Apr 2022 18:46:26 +0200 Subject: [PATCH 3/4] Oups --- lib/Model/Circle.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Model/Circle.php b/lib/Model/Circle.php index 1fb8f12fb..c1f026f5e 100644 --- a/lib/Model/Circle.php +++ b/lib/Model/Circle.php @@ -914,6 +914,7 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow $creation = $this->get($prefix . 'creation', $data); $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $creation); $timestamp = $dateTime ? $dateTime->getTimestamp() : (int) strtotime('Y-m-d H:i:s', $creation); + $this->setCreation($timestamp); $this->setPopulation($this->getInt('population', $this->getSettings())); $this->setPopulationInherited($this->getInt('populationInherited', $this->getSettings())); From 5cd28c51e70312c7a370330afc0c4a9fde1a80c6 Mon Sep 17 00:00:00 2001 From: Git'Fellow Date: Fri, 1 Apr 2022 14:54:47 +0200 Subject: [PATCH 4/4] Try to fix Incorrect format detection --- lib/Model/Circle.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Model/Circle.php b/lib/Model/Circle.php index 03c54e394..c1f026f5e 100644 --- a/lib/Model/Circle.php +++ b/lib/Model/Circle.php @@ -912,7 +912,9 @@ public function importFromDatabase(array $data, string $prefix = ''): IQueryRow ->setDescription($this->get($prefix . 'description', $data)); $creation = $this->get($prefix . 'creation', $data); - $this->setCreation(DateTime::createFromFormat('Y-m-d H:i:s', $creation)->getTimestamp()); + $dateTime = DateTime::createFromFormat('Y-m-d H:i:s', $creation); + $timestamp = $dateTime ? $dateTime->getTimestamp() : (int) strtotime('Y-m-d H:i:s', $creation); + $this->setCreation($timestamp); $this->setPopulation($this->getInt('population', $this->getSettings())); $this->setPopulationInherited($this->getInt('populationInherited', $this->getSettings()));