From dde09f43aaff0b1ee0443fcf30c612f36b3bd733 Mon Sep 17 00:00:00 2001 From: aynsix Date: Wed, 15 Nov 2023 18:28:34 +0300 Subject: [PATCH] fic clean user never connected --- .../Phrasea/Command/Maintenance/CleanUsersCommand.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Alchemy/Phrasea/Command/Maintenance/CleanUsersCommand.php b/lib/Alchemy/Phrasea/Command/Maintenance/CleanUsersCommand.php index 76d0169a0b..7f92475738 100644 --- a/lib/Alchemy/Phrasea/Command/Maintenance/CleanUsersCommand.php +++ b/lib/Alchemy/Phrasea/Command/Maintenance/CleanUsersCommand.php @@ -93,7 +93,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output) return 1; } - $clauses[] = sprintf("`last_connection` < DATE_SUB(NOW(), INTERVAL %d day)", $inactivityPeriod); + $clauses[] = sprintf("((`last_connection` IS NULL AND `Users`.`created` < DATE_SUB(NOW(), INTERVAL %d day)) OR (`last_connection` < DATE_SUB(NOW(), INTERVAL %d day)))", $inactivityPeriod, $inactivityPeriod); $sql_where_u = 1; $sql_where_ub = 1; @@ -249,7 +249,7 @@ protected function doExecute(InputInterface $input, OutputInterface $output) $usersList[] = [ $user->getId(), $user->getLogin(), - $user->getLastConnection()->format('Y-m-d h:m:s'), + ($user->getLastConnection() == null) ? 'never connected' : $user->getLastConnection()->format('Y-m-d h:m:s'), $action ]; } @@ -280,7 +280,7 @@ private function relanceUser(User $user, $graceDuration) $mail->setLogin($user->getLogin()); $mail->setLocale($user->getLocale()); - $mail->setLastConnection($user->getLastConnection()->format('Y-m-d')); + $mail->setLastConnection(($user->getLastConnection() == null) ? 'never connected': $user->getLastConnection()->format('Y-m-d')); $mail->setDeleteDate((new \DateTime("+{$graceDuration} day"))->format('Y-m-d')); // return 0 on failure @@ -296,7 +296,7 @@ private function doDelete(User $user, UserManipulator $userManipulator, $validMa if ($validMail && !empty($maxRelances)) { $receiver = Receiver::fromUser($user); $mail = MailSuccessAccountInactifDelete::create($this->container, $receiver); - $mail->setLastConnection($user->getLastConnection()->format('Y-m-d')); + $mail->setLastConnection(($user->getLastConnection() == null) ? 'never connected' : $user->getLastConnection()->format('Y-m-d')); // if --max_relances=0 there is no inactivity email if ($user->getLastInactivityEmail() !== null) {