Skip to content
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

session_write_close(): Failed to write session data using user defined save handler. #6

Closed
weierophinney opened this issue Dec 31, 2019 · 11 comments
Assignees
Labels
Bug Something isn't working Help Wanted Invalid This doesn't seem right

Comments

@weierophinney
Copy link
Member

Occasionally,we get the following not yet reproducible warning:

WARN: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: ) {"errno":2,"file":"/var/www/html/vendor/zendframework/zend-session/src/SessionManager.php","line":229}

This is how we initialize the session:

// Load config
$config = $serviceManager->get('Config');

// Initialize session
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions($config['session']);

$sessionTableGateway = new TableGateway('session', $serviceManager->get('Zend\Db\Adapter\Adapter'));
$saveHandler = new DbTableGateway($sessionTableGateway, new DbTableGatewayOptions());

$sessionManager = new SessionManager($sessionConfig, null, $saveHandler);
$sessionManager->setName($config['session']['name']);

$sessionManager->start();

Container::setDefaultManager($sessionManager);

Originally posted by @intellent at zendframework/zend-session#77

@weierophinney
Copy link
Member Author

I am facing a similar issue since upgrading to PHP 7.1 . I should note though, that we are using a VERY old version of Zend Framework: 1.10.

I do notice though that your session.save_path seems to be empty?
(session.save_path: )
There should probably be something there like /var/lib/php/session


Originally posted by @cg923 at zendframework/zend-session#77 (comment)

@weierophinney
Copy link
Member Author

Yes, I am facing exactly the same issue here. I am using also the session-db, i don't know why he reproduces this error pointing to something like if was saved on local disk.

captura de ecra 2018-09-11 as 11 54 04


Originally posted by @apoca at zendframework/zend-session#77 (comment)

@weierophinney
Copy link
Member Author

I'm also experienced the same issue but my particularity is that the session save handler want well to store user id (after logging) but doesn't want to store data session cart to sessiondb


Originally posted by @jamelcity at zendframework/zend-session#77 (comment)

@weierophinney
Copy link
Member Author

🤔 I'm facing the exact same issue when I use Zend\Cache\Storage\Adapter\BlackHole::class as save handler


Originally posted by @Nguimjeu at zendframework/zend-session#77 (comment)

@weierophinney
Copy link
Member Author

I also occasionally experience the error (E_WARNING):

session_write_close(): Failed to write session data using user defined save handler. 
(session.save_path: /var/lib/php/sessions)

in src/SessionManager.php on line 234.

What is interesting is that I am using Zend\Session\SaveHandler\DbTableGateway as a SaveHandler.

The session with the session ID included in the error log is not stored in the database.

The error happens sporadically and is not reproducible.

I am using zend-session 2.9.1.


Originally posted by @jonathanmaron at zendframework/zend-session#77 (comment)

@apoca
Copy link

apoca commented Jan 1, 2020

Yes unfortunately we have the same error here..

@FabianKoestring
Copy link

I think we have the exact same problem. We use our own SaveHandler and getting this exception ....

2020/11/20 11:23:59 [error] 16683#16683: *34849755 FastCGI sent in stderr: "PHP message: Doctrine\ORM\Cache\CacheException: Cannot update a readonly entity "...\Filemanager\Entity\File" in /var/www/stack/src/www/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/CacheException.php:50 Stack trace: #0 /var/www/stack/src/www/vendor/doctrine/orm/lib/Doctrine/ORM/Cache/Persister/Entity/ReadOnlyCachedEntityPersister.php(39): Doctrine\ORM\Cache\CacheException::updateReadOnlyEntity() #1 /var/www/stack/src/www/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(1172): Doctrine\ORM\Cache\Persister\Entity\ReadOnlyCachedEntityPersister->update() #2 /var/www/stack/src/www/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php(407): Doctrine\ORM\UnitOfWork->executeUpdates() #3 /var/www/stack/src/www/vendor/doctrine/orm/lib/Doctrine/ORM/EntityManager.php(371): Doctrine\ORM\UnitOfWork->commit() #4 /var/www/stack/src/vendor/.../service/src/Session.php(51): Doctrine\ORM\EntityManager->flush() #5 /var/www/stack/src/www/module/Application/src/Session/SaveHandler/Doctrine.php(68): ...\Ser...PHP message: PHP Warning: session_write_close(): Failed to write session data using user defined save handler. (session.save_path: /var/lib/php/sessions) in /var/www/stack/src/www/vendor/laminas/laminas-session/src/SessionManager.php on line 235" while reading upstream, client: 54.236.1.13, request: "GET / HTTP/1.1", upstream: "fastcgi://unix:/run/php/php7.4-fpm-www.sock:"

@StefanGerl
Copy link

Is this issue still occuring with laminas-session versions > 2.9.1?
Did anybody resolve this issue with an upgrade of the laminas-session Version?
I am still facing this problem, I am using laminas-session 2.8.7, with php7.3-fpm.

@tyrsson
Copy link

tyrsson commented Jul 24, 2022

Im still getting the same random error with laminas-session 2.13.0, DbTableGateway SaveHandler, php 8.1.1, windows 10

@romantaranenko
Copy link

@StefanGerl laminas/laminas-session version 2.12.1 with PHP 8.1.13 and i have it.

@Ocramius
Copy link
Member

Errors like these seem unrelated:

Cannot update a readonly entity

I'm closing here: please consider opening a new issue with logs presenting exactly:

  • which session savehandler was used
  • how it was configured
  • which method calls on the savehandler have been performed (you may need to decorate it)

@Ocramius Ocramius closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2022
@Ocramius Ocramius added Bug Something isn't working Invalid This doesn't seem right Help Wanted labels Dec 15, 2022
@Ocramius Ocramius self-assigned this Dec 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Help Wanted Invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

7 participants