diff --git a/app/Livewire/Project/Application/Previews.php b/app/Livewire/Project/Application/Previews.php index b1ba035dc..d42bf03d7 100644 --- a/app/Livewire/Project/Application/Previews.php +++ b/app/Livewire/Project/Application/Previews.php @@ -5,6 +5,7 @@ namespace App\Livewire\Project\Application; use App\Actions\Docker\GetContainersStatus; use App\Models\Application; use App\Models\ApplicationPreview; +use Carbon\Carbon; use Illuminate\Process\InvokedProcess; use Illuminate\Support\Collection; use Illuminate\Support\Facades\Process; @@ -239,7 +240,7 @@ class Previews extends Component $processes[$containerName] = $this->stopContainer($containerName, $timeout); } - $startTime = time(); + $startTime = Carbon::now()->getTimestamp(); while (count($processes) > 0) { $finishedProcesses = array_filter($processes, function ($process) { return ! $process->running(); @@ -249,7 +250,7 @@ class Previews extends Component $this->removeContainer($containerName, $server); } - if (time() - $startTime >= $timeout) { + if (Carbon::now()->getTimestamp() - $startTime >= $timeout) { $this->forceStopRemainingContainers(array_keys($processes), $server); break; } diff --git a/app/Livewire/Server/Proxy/Deploy.php b/app/Livewire/Server/Proxy/Deploy.php index eaa312663..8fcff85d6 100644 --- a/app/Livewire/Server/Proxy/Deploy.php +++ b/app/Livewire/Server/Proxy/Deploy.php @@ -6,6 +6,7 @@ use App\Actions\Proxy\CheckProxy; use App\Actions\Proxy\StartProxy; use App\Events\ProxyStatusChanged; use App\Models\Server; +use Carbon\Carbon; use Illuminate\Process\InvokedProcess; use Illuminate\Support\Facades\Process; use Livewire\Component; @@ -102,9 +103,9 @@ class Deploy extends Component $process = $this->stopContainer($containerName, $timeout); - $startTime = time(); + $startTime = Carbon::now()->getTimestamp(); while ($process->running()) { - if (time() - $startTime >= $timeout) { + if (Carbon::now()->getTimestamp() - $startTime >= $timeout) { $this->forceStopContainer($containerName); break; } diff --git a/bootstrap/helpers/github.php b/bootstrap/helpers/github.php index b1ac9178c..fee7cb8bf 100644 --- a/bootstrap/helpers/github.php +++ b/bootstrap/helpers/github.php @@ -3,6 +3,7 @@ use App\Models\GithubApp; use App\Models\GitlabApp; use Carbon\Carbon; +use Carbon\CarbonImmutable; use Illuminate\Support\Facades\Http; use Illuminate\Support\Str; use Lcobucci\JWT\Encoding\ChainedFormatter; @@ -16,7 +17,7 @@ function generate_github_installation_token(GithubApp $source) $signingKey = InMemory::plainText($source->privateKey->private_key); $algorithm = new Sha256; $tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default())); - $now = new DateTimeImmutable; + $now = CarbonImmutable::now(); $now = $now->setTime($now->format('H'), $now->format('i')); $issuedToken = $tokenBuilder ->issuedBy($source->app_id) @@ -40,7 +41,7 @@ function generate_github_jwt_token(GithubApp $source) $signingKey = InMemory::plainText($source->privateKey->private_key); $algorithm = new Sha256; $tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default())); - $now = new DateTimeImmutable; + $now = CarbonImmutable::now(); $now = $now->setTime($now->format('H'), $now->format('i')); $issuedToken = $tokenBuilder ->issuedBy($source->app_id) diff --git a/bootstrap/helpers/shared.php b/bootstrap/helpers/shared.php index e260491ba..67ce353d2 100644 --- a/bootstrap/helpers/shared.php +++ b/bootstrap/helpers/shared.php @@ -28,6 +28,7 @@ use App\Notifications\Channels\DiscordChannel; use App\Notifications\Channels\EmailChannel; use App\Notifications\Channels\TelegramChannel; use App\Notifications\Internal\GeneralNotification; +use Carbon\CarbonImmutable; use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; use Illuminate\Database\UniqueConstraintViolationException; use Illuminate\Mail\Message; @@ -949,7 +950,7 @@ function generateEnvValue(string $command, Service|Application|null $service = n $key = InMemory::plainText($signingKey); $algorithm = new Sha256; $tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default())); - $now = new DateTimeImmutable; + $now = CarbonImmutable::now(); $now = $now->setTime($now->format('H'), $now->format('i')); $token = $tokenBuilder ->issuedBy('supabase') @@ -969,7 +970,7 @@ function generateEnvValue(string $command, Service|Application|null $service = n $key = InMemory::plainText($signingKey); $algorithm = new Sha256; $tokenBuilder = (new Builder(new JoseEncoder, ChainedFormatter::default())); - $now = new DateTimeImmutable; + $now = CarbonImmutable::now(); $now = $now->setTime($now->format('H'), $now->format('i')); $token = $tokenBuilder ->issuedBy('supabase')