Skip to content

Commit bd8b708

Browse files
committed
[L6] Update cache methods to use defined times and not ints
1 parent 2c0503c commit bd8b708

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

app/Http/Controllers/Admin/NodesController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
namespace Pterodactyl\Http\Controllers\Admin;
1111

1212
use Javascript;
13+
use Cake\Chronos\Chronos;
1314
use Illuminate\Http\Request;
1415
use Pterodactyl\Models\Node;
1516
use Illuminate\Http\Response;
@@ -396,7 +397,7 @@ public function delete($node)
396397
public function setToken(Node $node)
397398
{
398399
$token = bin2hex(random_bytes(16));
399-
$this->cache->put('Node:Configuration:' . $token, $node->id, 5);
400+
$this->cache->put('Node:Configuration:' . $token, $node->id, Chronos::now()->addMinutes(5));
400401

401402
return response()->json(['token' => $token]);
402403
}

app/Http/Controllers/Auth/LoginController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Http\Controllers\Auth;
44

5+
use Cake\Chronos\Chronos;
56
use Illuminate\Support\Str;
67
use Illuminate\Http\Request;
78
use Illuminate\Auth\AuthManager;
@@ -100,7 +101,7 @@ public function login(Request $request): JsonResponse
100101

101102
if ($user->use_totp) {
102103
$token = Str::random(64);
103-
$this->cache->put($token, $user->id, 5);
104+
$this->cache->put($token, $user->id, Chronos::now()->addMinutes(5));
104105

105106
return JsonResponse::create([
106107
'data' => [

app/Services/Helpers/AssetHashService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Pterodactyl\Services\Helpers;
44

5+
use Cake\Chronos\Chronos;
56
use Illuminate\Filesystem\FilesystemManager;
67
use Illuminate\Contracts\Foundation\Application;
78
use Illuminate\Contracts\Cache\Repository as CacheRepository;
@@ -134,7 +135,7 @@ protected function manifest(): array
134135
}
135136

136137
$contents = json_decode($this->filesystem->get(self::MANIFEST_PATH), true);
137-
$this->cache->put('Core:AssetManifest', $contents, 1440);
138+
$this->cache->put('Core:AssetManifest', $contents, Chronos::now()->addMinutes(1440));
138139

139140
return self::$manifest = $contents;
140141
}

app/Services/Helpers/SoftwareVersionService.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use stdClass;
1313
use Exception;
1414
use GuzzleHttp\Client;
15+
use Cake\Chronos\Chronos;
1516
use Illuminate\Contracts\Cache\Repository as CacheRepository;
1617
use Illuminate\Contracts\Config\Repository as ConfigRepository;
1718
use Pterodactyl\Exceptions\Service\Helper\CdnVersionFetchingException;
@@ -118,7 +119,7 @@ public function isLatestDaemon($version)
118119
*/
119120
protected function cacheVersionData()
120121
{
121-
$this->cache->remember(self::VERSION_CACHE_KEY, $this->config->get('pterodactyl.cdn.cache_time'), function () {
122+
$this->cache->remember(self::VERSION_CACHE_KEY, Chronos::now()->addMinutes(config('pterodactyl.cdn.cache_time')), function () {
122123
try {
123124
$response = $this->client->request('GET', $this->config->get('pterodactyl.cdn.url'));
124125

0 commit comments

Comments
 (0)