Closed
Description
Symfony version(s) affected: 4.0.4
Description
A database (MongoDB) session storage was enabled as described in docs (http://symfony.com/doc/current/doctrine/mongodb_session_storage.html). It works. I can log in and it stores the session in the database. However, if you browse to a page where the session is used, following error is logged:
request.CRITICAL: Uncaught PHP Exception Symfony\Component\Debug\Exception\UndefinedMethodException: "Attempted to call an undefined method named "createDateTime" of class "Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler"." at /ebs/www/web_root/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php line 144 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\UndefinedMethodException(code: 0): Attempted to call an undefined method named \"createDateTime\" of class \"Symfony\\Component\\HttpFoundation\\Session\\Storage\\Handler\\MongoDbSessionHandler\". at /ebs/www/web_root/vendor/symfony/http-foundation/Session/Storage/Handler/MongoDbSessionHandler.php:144)"} []
How to reproduce
- Have a Symfony installation with MongoDB.
- Have a simple login system with a user authenticator and provided.
- Have a dummy page which is behind access control (so a session is required to access that page).
- Configure it to store session in database.
- Run the application in PROD mode.
- Visit the page you created above.
- 500 error.
- Check the application error log.
Possible Solution
Method updateTimestamp()
uses $this->createDateTime()
which appears to be not defined in the local class or the extended one. Method doWrite()
attempts to work with time by using new \MongoDB\BSON\UTCDateTime()
which is correct. updateTimestamp()
should be changed to make use of \MongoDB\BSON\UTCDateTime()
.
Thanks.