statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.13k stars 541 forks source link

Session blocking doesn't work in the admin panel #11190

Open simonworkhouse opened 3 days ago

simonworkhouse commented 3 days ago

Bug description

The admin panel throws an error when session blocking is enabled, see https://laravel.com/docs/11.x/session#session-blocking

[2024-11-28 09:40:33] local.ERROR: call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given {"exception":"[object] (TypeError(code: 0): call_user_func(): Argument #1 ($callback) must be a valid callback, no array or string given at /var/www/statamic-cms/statamic/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:304)

I'd suggest that some of the blame lies with Laravel as the Illuminate\Session\SessionServiceProvider is responsible for attaching a Illuminate\Contracts\Cache\Factory instance but it only does this on the Illuminate\Session\Middleware\StartSession middleware specifically (in Illuminate\Session\SessionServiceProvider and hence it's missed from Statamic\Http\Middleware\CP\StartSession.

How to reproduce

Enable session blocking with the config session.block set to true and proceed to the admin panel.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.34.2
PHP Version: 8.2.26
Composer Version: 2.8.2
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.41.0 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

duncanmcclean commented 3 days ago

Enable session blocking with the config session.block set to true and proceed to the admin panel.

I don't see the session.block config option mentioned in the docs. Where did you see it?

duncanmcclean commented 3 days ago

Anyways, I've opened a PR which should fix this for you. 👍