Skip to content

Commit

Permalink
Merge pull request #148 from silinternational/develop
Browse files Browse the repository at this point in the history
Release 4.4.0 Create one error message for all update-failed users
  • Loading branch information
Baggerone authored Jun 12, 2023
2 parents faa0e78 + 8daf6c4 commit e0638eb
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions application/common/sync/Synchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,32 @@ protected function activateAndUpdateUser(User $user)
*/
protected function activateAndUpdateUsers(array $usersToUpdateAndActivate)
{
$usersWithErrors = [];
$lastError = null;

$employeeIdsOfUsersUpdated = [];
foreach ($usersToUpdateAndActivate as $userToUpdateAndActivate) {
foreach ($usersToUpdateAndActivate as $nextUser) {
try {
$this->activateAndUpdateUser($userToUpdateAndActivate);
$employeeIdsOfUsersUpdated[] = $userToUpdateAndActivate->getEmployeeId();
$this->activateAndUpdateUser($nextUser);
$employeeIdsOfUsersUpdated[] = $nextUser->getEmployeeId();
} catch (Exception $e) {
$this->logger->error(sprintf(
'Failed to update/activate user in the ID Broker (%s). Error %s: %s. [%s]',
$userToUpdateAndActivate->getStringForLogMessage(),
$e->getCode(),
$e->getMessage(),
1494360119
));
$usersWithErrors[] = $nextUser->getStringForLogMessage();
$lastError = $e;
}
}

if ($lastError !== null) {
$this->logger->error(sprintf(
'Failed to update/activate user(s) in the ID Broker. Last error %s: %s. [%s].'
. ' Failed for %s users, including: %s',
$lastError->getCode(),
$lastError->getMessage(),
1494360119,
count($usersWithErrors),
join(', ', array_slice($usersWithErrors, -6)) // last six users
));
}

$this->logger->notice([
'action' => 'update',
'attempted' => count($usersToUpdateAndActivate),
Expand Down

0 comments on commit e0638eb

Please sign in to comment.