? ? Pending

User tests: Successful: Unsuccessful:

avatar HLeithner
HLeithner
6 Dec 2020

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.

Summary of Changes

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.

Testing Instructions

  • Upgrade from J3.10 to j4, this should still work
  • Save values to the session with and without 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'));

Actual result BEFORE applying this Pull Request

Working with the session using the old syntax and names doesn't work

Expected result AFTER applying this Pull Request

Still all works including a better b/c layer for old syntax and namespaces

Documentation Changes Required

N/A

avatar HLeithner HLeithner - open - 6 Dec 2020
avatar HLeithner HLeithner - change - 6 Dec 2020
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 6 Dec 2020
Category Libraries
ef3e6dc 6 Dec 2020 avatar HLeithner cs
avatar HLeithner HLeithner - change - 6 Dec 2020
Labels Added: ?
avatar HLeithner
HLeithner - comment - 6 Dec 2020

thx @Quy fixed cs

avatar wilsonge
wilsonge - comment - 8 Dec 2020

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.

avatar wilsonge wilsonge - change - 9 Dec 2020
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: ?
avatar wilsonge wilsonge - close - 9 Dec 2020
avatar wilsonge wilsonge - merge - 9 Dec 2020
avatar wilsonge
wilsonge - comment - 9 Dec 2020

Thanks!

Add a Comment

Login with GitHub to post a comment