Skip to content

Commit a137056

Browse files
committed
Fix unable to reload secret key
1 parent f61f12c commit a137056

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/AsyncTask.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
use function Opis\Closure\init;
1717
use function Opis\Closure\serialize;
18+
use function Opis\Closure\set_security_provider;
1819
use function Opis\Closure\unserialize;
1920

2021
/**
@@ -134,7 +135,7 @@ public function __unserialize($data): void
134135
}
135136

136137
/**
137-
* Loads the secret key used by this library.
138+
* Loads (or reloads) the secret key used by this library.
138139
*
139140
* Normally, this function does not need to be called by linrary users.
140141
* @return void
@@ -143,9 +144,13 @@ public static function loadSecretKey(): void
143144
{
144145
// read from the env file for the secret key (if exists) to verify our identity
145146
$secretKey = env("PROCESS_ASYNC_SECRET_KEY");
147+
init(null);
146148
if ($secretKey != null && strlen($secretKey) > 0) {
147149
// we can set the secret key
148-
init($secretKey);
150+
set_security_provider($secretKey);
151+
} else {
152+
// no secret key given, clear the security
153+
set_security_provider(null);
149154
}
150155
}
151156

0 commit comments

Comments
 (0)