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) {