Skip to content

Commit

Permalink
ENH Don't use deprecated method (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
GuySartorelli authored Sep 19, 2024
1 parent a954c0e commit fe1f4c5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/Tasks/LDAPGroupSyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public function run($request)
$group = new Group();
$group->GUID = $data['objectguid'];

Deprecation::withNoReplacement(function () use ($data) {
Deprecation::withSuppressedNotice(function () use ($data) {
$this->log(sprintf(
'Creating new Group (GUID: %s, sAMAccountName: %s)',
$data['objectguid'],
Expand All @@ -94,7 +94,7 @@ public function run($request)
});
$created++;
} else {
Deprecation::withNoReplacement(function () use ($group, $data) {
Deprecation::withSuppressedNotice(function () use ($group, $data) {
$this->log(sprintf(
'Updating existing Group "%s" (ID: %s, GUID: %s, sAMAccountName: %s)',
$group->getTitle(),
Expand All @@ -109,7 +109,7 @@ public function run($request)
try {
$this->ldapService->updateGroupFromLDAP($group, $data);
} catch (Exception $e) {
Deprecation::withNoReplacement(fn() => $this->log($e->getMessage()));
Deprecation::withSuppressedNotice(fn() => $this->log($e->getMessage()));
continue;
}
}
Expand All @@ -121,7 +121,7 @@ public function run($request)
if (!isset($ldapGroups[$record['GUID']])) {
$group = Group::get()->byId($record['ID']);

Deprecation::withNoReplacement(function () use ($group) {
Deprecation::withSuppressedNotice(function () use ($group) {
$this->log(sprintf(
'Removing Group "%s" (GUID: %s) that no longer exists in LDAP.',
$group->Title,
Expand All @@ -136,7 +136,7 @@ public function run($request)
}
$group->delete();
} catch (Exception $e) {
Deprecation::withNoReplacement(fn() => $this->log($e->getMessage()));
Deprecation::withSuppressedNotice(fn() => $this->log($e->getMessage()));
continue;
}

Expand All @@ -149,7 +149,7 @@ public function run($request)

$end = time() - $start;

Deprecation::withNoReplacement(function () use ($created, $updated, $deleted, $end) {
Deprecation::withSuppressedNotice(function () use ($created, $updated, $deleted, $end) {
$this->log(sprintf(
'Done. Created %s records. Updated %s records. Deleted %s records. Duration: %s seconds',
$created,
Expand Down
8 changes: 4 additions & 4 deletions src/Tasks/LDAPMemberSyncOneTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function run($request)

// If member exists already, we're updating - otherwise we're creating
if ($member->exists()) {
Deprecation::withNoReplacement(function () use ($user, $member) {
Deprecation::withSuppressedNotice(function () use ($user, $member) {
$this->log(sprintf(
'Updating existing Member %s: "%s" (ID: %s, SAM Account Name: %s)',
$user['objectguid'],
Expand All @@ -86,16 +86,16 @@ public function run($request)
));
}

Deprecation::withNoReplacement(function () use ($user) {
Deprecation::withSuppressedNotice(function () use ($user) {
$this->log('User data returned from LDAP follows:');
$this->log(var_export($user));
});

try {
$this->ldapService->updateMemberFromLDAP($member, $user);
Deprecation::withNoReplacement(fn() => $this->log('Done!'));
Deprecation::withSuppressedNotice(fn() => $this->log('Done!'));
} catch (Exception $e) {
Deprecation::withNoReplacement(fn() => $this->log($e->getMessage()));
Deprecation::withSuppressedNotice(fn() => $this->log($e->getMessage()));
}
}

Expand Down
12 changes: 6 additions & 6 deletions src/Tasks/LDAPMemberSyncTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function run($request)
// If member exists already, we're updating - otherwise we're creating
if ($member->exists()) {
$updated++;
Deprecation::withNoReplacement(function () use ($data, $member) {
Deprecation::withSuppressedNotice(function () use ($data, $member) {
$this->log(sprintf(
'Updating existing Member %s: "%s" (ID: %s, SAM Account Name: %s)',
$data['objectguid'],
Expand All @@ -94,7 +94,7 @@ public function run($request)
});
} else {
$created++;
Deprecation::withNoReplacement(function () use ($data) {
Deprecation::withSuppressedNotice(function () use ($data) {
$this->log(sprintf(
'Creating new Member %s: "%s" (SAM Account Name: %s)',
$data['objectguid'],
Expand All @@ -109,7 +109,7 @@ public function run($request)
try {
$this->ldapService->updateMemberFromLDAP($member, $data);
} catch (Exception $e) {
Deprecation::withNoReplacement(fn() => $this->log($e->getMessage()));
Deprecation::withSuppressedNotice(fn() => $this->log($e->getMessage()));
continue;
}
}
Expand All @@ -121,7 +121,7 @@ public function run($request)
$member = Member::get()->byId($record['ID']);

if (!isset($users[$record['GUID']])) {
Deprecation::withNoReplacement(function () use ($member) {
Deprecation::withSuppressedNotice(function () use ($member) {
$this->log(sprintf(
'Removing Member "%s" (GUID: %s) that no longer exists in LDAP.',
$member->getName(),
Expand All @@ -132,7 +132,7 @@ public function run($request)
try {
$member->delete();
} catch (Exception $e) {
Deprecation::withNoReplacement(fn() => $this->log($e->getMessage()));
Deprecation::withSuppressedNotice(fn() => $this->log($e->getMessage()));
continue;
}

Expand All @@ -145,7 +145,7 @@ public function run($request)

$end = time() - $start;

Deprecation::withNoReplacement(function () use ($created, $updated, $deleted, $end) {
Deprecation::withSuppressedNotice(function () use ($created, $updated, $deleted, $end) {
$this->log(sprintf(
'Done. Created %s records. Updated %s records. Deleted %s records. Duration: %s seconds',
$created,
Expand Down
4 changes: 2 additions & 2 deletions src/Tasks/LDAPMigrateExistingMembersTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function run($request)

$count++;

Deprecation::withNoReplacement(function () use ($member) {
Deprecation::withSuppressedNotice(function () use ($member) {
$this->log(sprintf(
'Migrated Member %s (ID: %s, Email: %s)',
$member->getName(),
Expand All @@ -86,7 +86,7 @@ public function run($request)

$end = time() - $start;

Deprecation::withNoReplacement(function () use ($count, $end) {
Deprecation::withSuppressedNotice(function () use ($count, $end) {
$this->log(sprintf('Done. Migrated %s Member records. Duration: %s seconds', $count, round($end ?? 0.0, 0)));
});
}
Expand Down

0 comments on commit fe1f4c5

Please sign in to comment.