Skip to content

Commit

Permalink
Fix key management routine.
Browse files Browse the repository at this point in the history
  • Loading branch information
dasgarner committed Dec 12, 2024
1 parent 8e66e5e commit 4be42ab
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/Entity/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,19 +181,17 @@ public function authKey(string $providedKey): bool
public function expireKeys(): void
{
// Expire keys within each instance
foreach ($this->instances as $instance) {
for ($i = 0; $i < count($instance['keys']); $i++) {
foreach ($this->instances as $instanceKey => $instance) {
foreach ($instance['keys'] as $key => $value) {
// Expire any keys which are no longer in date.
if (time() >= $instance['keys'][$i]['expires']) {
unset($instance['keys'][$i]);
if (time() >= $value['expires']) {
unset($instance['keys'][$key]);
}
}
}

// Remove instances with no keys
for ($j = 0; $j < count($this->instances); $j++) {
if (count($this->instances[$j]['keys']) <= 0) {
unset($this->instances[$j]);
// Remove instances with no keys
if (count($instance['keys']) <= 0) {
unset($this->instances[$instanceKey]);
}
}
}
Expand Down

0 comments on commit 4be42ab

Please sign in to comment.