J'ai créé un nouveau sondage de test pour reproduire le problème : https://date.chapril.org/egXUtKJIvasP9HlCZESYkzUw/admin
Le plantage est causé parce qu'on essaye d'enregistrer une chaine vide dans le champ end_date
.
[Sun Mar 26 10:41:00.659797 2023] [php7:error] [pid 2414035] [client 109.190.213.58:0] PHP Fatal error: Uncaught PDOException: SQLSTATE[22007]: Invalid datetime format: 1292
Incorrect datetime value: '' for column `date_chapril_org_db`.`fd_poll`.`end_date`
at row 1 in /var/www/date.chapril.org/app/classes/Framadate/Repositories/PollRepository.php:60
Stack trace:
#0 /var/www/date.chapril.org/app/classes/Framadate/Repositories/PollRepository.php(60): PDOStatement->execute()
#1 /var/www/date.chapril.org/app/classes/Framadate/Services/AdminPollService.php(46): Framadate\\Repositories\\PollRepository->update()
#2 /var/www/date.chapril.org/adminstuds.php(200): Framadate\\Services\\AdminPollService->updatePoll()
#3 {main}\n thrown in /var/www/date.chapril.org/app/classes/Framadate/Repositories/PollRepository.php on line 60,
referer: https://date.chapril.org/egXUtKJIvasP9HlCZESYkzUw/admin
Dans l'immédiat, j'ai mis en commentaire le code fautif et ça débloque la situation.
diff --git a/app/classes/Framadate/Services/AdminPollService.php b/app/classes/Framadate/Services/AdminPollService.php
index f8482ae..4d45064 100644
--- a/app/classes/Framadate/Services/AdminPollService.php
+++ b/app/classes/Framadate/Services/AdminPollService.php
@@ -37,11 +37,11 @@ class AdminPollService {
$end_date = strtotime($poll->end_date);
- if ($end_date < strtotime($poll->creation_date)) {
- $poll->end_date = $poll->creation_date;
- } elseif ($end_date > $this->pollService->maxExpiryDate()) {
- $poll->end_date = utf8_encode(strftime('%Y-%m-%d', $this->pollService->maxExpiryDate()));
- }
+// if ($end_date < strtotime($poll->creation_date)) {
+// $poll->end_date = $poll->creation_date;
+// } elseif ($end_date > $this->pollService->maxExpiryDate()) {
+// $poll->end_date = utf8_encode(strftime('%Y-%m-%d', $this->pollService->maxExpiryDate()));
+// }
return $this->pollRepository->update($poll);
}
Je cherche maintenant un correctif plus propre.