Skip to content

Commit b7766ef

Browse files
authored
Merge branch 'master' into storage-listeners
2 parents 5e0153c + c32f52c commit b7766ef

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

src/Bootstrappers/FilesystemTenancyBootstrapper.php

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

55
namespace Stancl\Tenancy\Bootstrappers;
66

7+
use Exception;
78
use Illuminate\Foundation\Application;
89
use Illuminate\Session\FileSessionHandler;
910
use Illuminate\Support\Facades\Storage;
@@ -75,8 +76,13 @@ protected function storagePath(string|false $suffix): void
7576
: $this->originalStoragePath . '/framework/cache';
7677

7778
if (! is_dir($path)) {
78-
// Create tenant framework/cache directory if it does not exist
79-
mkdir($path, 0750, true);
79+
// Create tenant framework/cache directory if it does not exist.
80+
// We ignore errors due to TOCTOU race conditions, instead we check for success below.
81+
@mkdir($path, 0750, true);
82+
83+
if (! is_dir($path)) {
84+
throw new Exception("Unable to create tenant storage directory [{$path}].");
85+
}
8086
}
8187

8288
if ($suffix === false) {
@@ -222,8 +228,13 @@ public function scopeSessions(string|false $suffix): void
222228
: $this->originalStoragePath . '/framework/sessions';
223229

224230
if (! is_dir($path)) {
225-
// Create tenant framework/sessions directory if it does not exist
226-
mkdir($path, 0750, true);
231+
// Create tenant framework/sessions directory if it does not exist.
232+
// We ignore errors due to TOCTOU race conditions, instead we check for success below.
233+
@mkdir($path, 0750, true);
234+
235+
if (! is_dir($path)) {
236+
throw new Exception("Unable to create tenant session directory [{$path}].");
237+
}
227238
}
228239

229240
$this->app['config']['session.files'] = $path;

src/Database/Concerns/PendingScope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Database\Eloquent\Scope;
1010

11+
/** @implements Scope<Model> */
1112
class PendingScope implements Scope
1213
{
1314
/**

src/Database/ParentModelScope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Illuminate\Database\Eloquent\Model;
99
use Illuminate\Database\Eloquent\Scope;
1010

11+
/** @implements Scope<Model> */
1112
class ParentModelScope implements Scope
1213
{
1314
/**

src/Database/TenantScope.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Illuminate\Database\Eloquent\Scope;
1010
use Stancl\Tenancy\Tenancy;
1111

12+
/** @implements Scope<Model> */
1213
class TenantScope implements Scope
1314
{
1415
/**

0 commit comments

Comments
 (0)