prevent a couple of cycles by not resolving the excluded middleware on each middleware items

This commit is contained in:
Daniel Klabbers 2021-07-13 00:44:27 +02:00
parent 274dac123f
commit 7562878325

View File

@ -119,8 +119,10 @@ class ApiServiceProvider extends AbstractServiceProvider
$this->container->singleton(Client::class, function ($container) {
$pipe = new MiddlewarePipe;
$middlewareStack = array_filter($container->make('flarum.api.middleware'), function ($middlewareClass) use ($container) {
return ! in_array($middlewareClass, $container->make('flarum.api_client.exclude_middleware'));
$exclude = $container->make('flarum.api_client.exclude_middleware');
$middlewareStack = array_filter($container->make('flarum.api.middleware'), function ($middlewareClass) use ($exclude) {
return ! in_array($middlewareClass, $exclude);
});
foreach ($middlewareStack as $middleware) {