Skip to content

Commit 0e255d2

Browse files
committed
Fix sharp context between requests
1 parent eca6789 commit 0e255d2

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

src/SharpInternalServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,10 @@ public function register()
132132
});
133133

134134
$this->app->register(InertiaServiceProvider::class);
135+
136+
$this->app->rebinding('request', function ($app, $request) {
137+
$this->app->get(SharpUtil::class)->reset();
138+
});
135139
}
136140

137141
protected function declareMiddleware(): void
@@ -244,7 +248,7 @@ private function resetSharp()
244248
$this->app->get(SharpMenuManager::class)->reset();
245249
$this->app->get(SharpAuthorizationManager::class)->reset();
246250
$this->app->get(SharpUploadManager::class)->reset();
247-
$this->app->get(SharpUtil::class)->__construct();
251+
$this->app->get(SharpUtil::class)->reset();
248252
$this->app->get(SharpImageManager::class)->__construct();
249253
$this->app->get(AddLinkHeadersForPreloadedRequests::class)->reset();
250254
}

src/Utils/SharpUtil.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,12 @@ public function context(): SharpContext
2424
{
2525
return $this->context;
2626
}
27+
28+
/**
29+
* @internal
30+
*/
31+
public function reset()
32+
{
33+
$this->context = app(SharpContext::class);
34+
}
2735
}

0 commit comments

Comments
 (0)