-
Notifications
You must be signed in to change notification settings - Fork 114
Session issue in database PHP7 #4
Comments
The problem might be in PHP itself: https://bugs.php.net/bug.php?id=70520 |
had this issue too - redis backend is also broken this way (likely as it also uses the db interface). |
In hope this will aid your search for solution - when I encountered session issues with Magento 1.x + PHP 7 beta 3 + Redis, I used following workaround as quick fix to regain Magento admin access (save as "whatever.patch" and apply with "patch -p1 < whatever.patch"):
Unfortunately I'm unable to do tests with PHP 7 final atm, but I'll test this workaround again first chance I get, if someone doesn't come up with something better in the meantime. |
Just tested it a bit, win + php7 + db sessions .. As @Marko-M posted, temp fix is bypassing session renewal. It seems when session_regenerate_id() is called, write() of session handler is never called. You get new session id in php and $_SESSION value is ok after regeneration, but it's never written because it's never passed to session handler. Why? No clue :) I also suspect it's php7 bug or some kind of change we're not aware of. Interesting thing, if you manually change session id and manually set cookie, everything works as expected.
Is it possible to (easily) generate/get new session id in php without session_regenerate_id(), to use in above example? I'm planning to test same thing on M2 tomorrow, to see how it behaves there. |
Hello all, I managed to trace the problem.
When called on session_regenerate_id(true) it returns false which breaks regeneration. It seems it's going to be easy fix. Can someone confirm this is correct? Thx. |
I didn't test Redis, but I think it could be similar problem since I was getting this error with db handler: and similar error is reported here colinmollenhour/Cm_RedisSession#70 |
Ivan, I have just pushed a fix based on your findings. Lets see how it works on database sessions, and when we have a chance, it's probably a good starting point for Redis fix. |
I have try the fix. But no luck. |
@lexbeelen, @arosenhagen: Can you please write on which OS problem occurred, is php stable 7.0.0 version or older RC and is it mod_php, php-fpm, etc. |
for me it is ubuntu 14.04.3 / debian 8.2.0 with a nginx / php-fpm setup. I hadn't the chance to try the proposed fix though. |
Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-57-generic x86_64) PHP 7.0.0-5+deb.sury.org~trusty+1 (cli) ( NTS ) nginx version: nginx/1.4.6 (Ubuntu) php-fpm setup |
@lexbeelen try now, I think it's fixed. And, we are probably on the right track to fix Redis too. |
@icurdinj I can confirm you, that the issue is fixed 👍 Great job 👍 |
Please what did you guys do to fix this issue? I don't understand what the solution to try is here. |
@johnbendi - the solution was traced by our ingenious @ivanweiler :
What actually happened was that Magentos function lied in docbloc to always return string, while actually it sometimes returned FALSE. And that function was then fed to PHPs session handler. PHP 5.* silently converted that FALSE to empty string (I guess), and it worked. PHP 7.0 does type checking here and expects string, so it crashed. Once the problem was traced, the solution was trivial. We replaced original :-) |
I'm having this same issue. It looks like it was a simple typecast. Where did you all make the change? I can't log into PhpMyAdmin after switching to memcached and would like to try this workaround |
More about memcached: https://github.com/Inchoo/Inchoo_PHP7/wiki/Memcache |
@cscart - CS-Cart session handler (PHP7 + Redis session cache) shares a similar fix as Magento. In app/Tygh/Session.php within the In the case of CS-Cart, the way we noticed this error was using Chrome inspector in mobile emulator mode, then going back and forth to desktop mode. One or the other eventually caused session fail with error from a function further down the chain:
|
If you get this problem using memcache, change to memcached into your app/etc/local.xml and remove protocol : tcp:// |
I have the same problem with php7 and session db mysql. The problem is when session_regenerate_id is called it calls: destroy and read. I did a fix which use debug_backtrace to check if call is from session_regenerate_id. class Mage_Core_Model_Resource_Session implements Zend_Session_SaveHandler_Interface {
///....
/**
* @param string $sessId
* @return string
*/
public function read($sessId)
{
$flags = 0;
$backtrace = debug_backtrace($flags,2);
$regenerate = 'session_regenerate_id' === $backtrace[1]['function'];
$select = $this->_read->select()
->from($this->_sessionTable, array('session_data'))
->where('session_id = :session_id')
->where('session_expires > :session_expires');
$expires = $regenerate ? 0 : Varien_Date::toTimestamp(true);
$bind = array(
'session_id' => $sessId,
'session_expires' => $expires
);
$data = (string)$this->_read->fetchOne($select, $bind);
return $data;
} |
There is a issue with sessions.
This only happens when you set "session_save" in "local.xml" to "db".
If you try with the option "files" there are no problems.
Error.
Recoverable Error: session_regenerate_id(): Failed to create(read) session ID: user (path: /var/lib/php/sessions) in app/code/core/Mage/Core/Model/Session/Abstract/Varien.php on line 492
The text was updated successfully, but these errors were encountered: