Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Improve ability to configure and extend c5 session #7258
New configuration / extension improvements
Prior to this PR we only supported two session handlers:
Now with this PR, we support three session handlers by default:
Now if you configure
New memcached session handler
This doesn't require a new dependency, we already have it available in the core with symfony's session handler package.
You can enable the memcached session handler and manage the servers yourself if you like, just create a new
NOTE: The memcached extension keeps servers around even across requests! An easy way to avoid issues is to just not add servers if the memcached instance already has some
concrete5 will manage the memcached sessions for you though, just configure the
return [ 'session' => [ 'handler' => 'memcached', 'servers' => [ ['host' => 'some.host.com'], // Defaults: Port = 11211, weight = 0 ['host' => 'some.other.host.com', 'port' => 5050, 'weight' = 2] ] ] ]
Oh, now I'm going to have to change around #7206
Though I will say, are you sure that just Binding the class works? because previously I used to just bind the interface and that worked but since 8.4.0 I have to overwrite the session singleton.
Also you should put in a check to see if the class memcached exists, if it doesnt get the default storage
It'd depend on when you override the class. If you override it after the singleton is resolved, then yes, you have to clear that singleton. That said, I'm not sure that clearing the singleton is enough since the session would've already been started with the wrong handler.
Since the core binds
I don't think it should fall back to the default in any case, right now you will get an error complaining that the class doesn't exist. I don't like the idea of falling back the default in that case, but I agree we could make that error better and say something like "The memcached extension is required for the memcached session handler".