8000 Attempted to call an undefined method named "createDateTime" of class "Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler" · Issue #28195 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

Attempted to call an undefined method named "createDateTime" of class "Symfony\Component\HttpFoundation\Session\Storage\Handler\MongoDbSessionHandler" #28195

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mranawake opened this issue Aug 12, 2018 · 1 comment

Comments

@mranawake
Copy link
mranawake commented Aug 12, 2018

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.

@xabbuh
Copy link
Member
xabbuh commented Aug 13, 2018

This is already fixed in #26403.

@xabbuh xabbuh closed this as completed Aug 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants
0