Skip to content

Commit bfa85b8

Browse files
roxikartemdriesvints
authored
[10.x] Fix file race condition after view:cache and artisan up (#48368)
* fix file race condition after view:cache and artisan up * revert spaces in docblock * Update src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php Co-authored-by: Dries Vints <[email protected]> * code review changes --------- Co-authored-by: artem <[email protected]> Co-authored-by: Dries Vints <[email protected]>
1 parent 0429a6f commit bfa85b8

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Illuminate\Foundation\Http\Middleware;
44

55
use Closure;
6+
use ErrorException;
67
use Illuminate\Contracts\Foundation\Application;
78
use Illuminate\Foundation\Http\MaintenanceModeBypassCookie;
89
use Symfony\Component\HttpKernel\Exception\HttpException;
@@ -42,6 +43,7 @@ public function __construct(Application $app)
4243
* @return mixed
4344
*
4445
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
46+
* @throws \ErrorException
4547
*/
4648
public function handle($request, Closure $next)
4749
{
@@ -50,7 +52,15 @@ public function handle($request, Closure $next)
5052
}
5153

5254
if ($this->app->maintenanceMode()->active()) {
53-
$data = $this->app->maintenanceMode()->data();
55+
try {
56+
$data = $this->app->maintenanceMode()->data();
57+
} catch (ErrorException $exception) {
58+
if (! $this->app->maintenanceMode()->active()) {
59+
return $next($request);
60+
}
61+
62+
throw $exception;
63+
}
5464

5565
if (isset($data['secret']) && $request->path() === $data['secret']) {
5666
return $this->bypassResponse($data['secret']);

src/Illuminate/View/Compilers/Compiler.php

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

33
namespace Illuminate\View\Compilers;
44

5+
use ErrorException;
56
use Illuminate\Filesystem\Filesystem;
67
use Illuminate\Support\Str;
78
use InvalidArgumentException;
@@ -89,6 +90,8 @@ public function getCompiledPath($path)
8990
*
9091
* @param string $path
9192
* @return bool
93+
*
94+
* @throws \ErrorException
9295
*/
9396
public function isExpired($path)
9497
{
@@ -105,8 +108,16 @@ public function isExpired($path)
105108
return true;
106109
}
107110

108-
return $this->files->lastModified($path) >=
109-
$this->files->lastModified($compiled);
111+
try {
112+
return $this->files->lastModified($path) >=
113+
$this->files->lastModified($compiled);
114+
} catch (ErrorException $exception) {
115+
if (! $this->files->exists($compiled)) {
116+
return true;
117+
}
118+
119+
throw $exception;
120+
}
110121
}
111122

112123
/**

0 commit comments

Comments
 (0)