User tests: Successful: Unsuccessful:
Pull Request for Issue noticed by @nikosdion in akeeba/fof@d69b179
The Joomla 4 session manager doesn't handle namespaces anymore. For j3 b/c joomla includes a b/c layer which was doesn't handle existing sessions correctly. In PR #31561 we tried to fix the upgrade double login issue. This PR got merged too early and a bugfix PR #31575 fixed a part of the problem. The session PRs introduced a new bug handling none "default" namespace which is addressed in this PR.
Try the prefixed namespace used in session migrated from j3 after the none prefixed parameter in the following functions:
Joomla\CMS\Session\Session::get()
Joomla\CMS\Session\Session::has()
Joomla\CMS\Session\Session::clean()
We don't change the Joomla\CMS\Session\Session::set()
function because new parameters will always be stored in a none prefixed namespace.
$session = JFactory::getApplication()->getSession();
# Clear session
$session->clear('__ns');
$session->clear('ns');
echo "Set wow without namespace ns\n";
$session->set('wow', 'xxx');
echo "Check wow without namespace\n";
if ($session->has('wow')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('wow', 'xxx'));
$session->clear('wow');
echo "Set wow with namespace ns and j3 syntax \n";
$session->set('wow', 'xxx', 'ns');
echo "check wow with j3 syntax \n";
if ($session->has('wow','ns')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('wow', 'not found', 'ns'));
if ($session->has('ns.wow')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('ns.wow', 'not found'));
$session->clear('wow', 'ns');
$session->clear('ns');
echo "Set __ns.wow for j3 session simulation \n";
$session->set('__ns.wow', 'xxx');
echo "check wow with j3 syntax \n";
if ($session->has('wow','ns')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('wow', 'not found', 'ns'));
echo "check wow with j4 syntax and underscore prefixed (normally not used) \n";
if ($session->has('__ns.wow')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('__ns.wow', 'not found'));
echo "check wow with j4 syntax\n";
if ($session->has('ns.wow')) {
echo "Good\n";
} else {
echo "FAIL\n";
}
var_dump($session->get('ns.wow', 'not found'));
Working with the session using the old syntax and names doesn't work
Still all works including a better b/c layer for old syntax and namespaces
N/A
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
Labels |
Added:
?
|
Rather than this - all namespaces in our b/c mapping just need to be given a prefix by default. also we should try the get fallback if a namespace has been provided.
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2020-12-09 19:24:56 |
Closed_By | ⇒ | wilsonge | |
Labels |
Added:
?
|
Thanks!
thx @Quy fixed cs