I haven't had time to track this down yet but the 3.4.7 update has broken /cli
apps like AkeebaBackup. The specific error in the logs:
[21-Dec-2015 23:57:53 CST6CDT] PHP Fatal error: Call to a member function get() on a non-object in /home/xxx/public_html/libraries/joomla/session/session.php on line 448
Steps to reproduce:
php_errorlog
file in /cli
directorySorry I don't have any more details yet but I'll update as I find out more.
Yes the core /cli
scripts are unaffected — if @nikosdion isn't aware yet he will be soon as there is already a ticket on his site about it.
I'm trying to distill this to it's escence. Basically though line 448:
return $this->data->get($namespace . '.' . $name, $default);
Fails for these third party cli scripts because $this->data
is not an object… now I'm not sure why they are in JSession in the first place… working on that.
I should add that changing line 448 to guard against $this->data
not being set/object works e.g. we've deployed this temp patch to get all of clients tools back up and running (incl. AkeebaBackup)
if (isset($this->data) && is_object($this->data))
{
return $this->data->get($namespace . '.' . $name, $default);
}
else
{
return $default;
}
The session code is apparently triggered by JFactory::getUser()
. Unfortunately that's not the only way this Joomla! bug can affect CLI scripts. Using any model –which implicitly saves its state in the session– will also trigger this issue.
Apparently, until this issue is fixed, all developers must add this code in their CLI scripts:
if (version_compare(JVERSION, '3.4.7', 'ge'))
{
JFactory::getSession()->restart();
}
It seems that the best place to add it is in either the __construct
method of the CLI application or as the very first code block in the execute
method.
Right now @tampe125 is looking at the Joomla! code itself and he tells me the actual root cause is how Joomla! treats an inexistent session. Joomla! marks its state as "inactive". However, it does this kind of check:
if ($session->getState() == 'expired')
{
$session->restart();
}
Since the state is inactive
, not expired
, the session is never "restarted" –which would actually initialise it– therefore $this->data
is never initialised to a new JRegistry object. I can personally see two ways to fix that: either initialise $this->data in the constructor (which is the sane approach) or treat a missing session as "expired" which MAY have unforeseen issues.
I'll leave that to the CLT, JSST and @tampe125 to discuss. I will be too busy patching all of our CLI scripts, releasing new versions and at the same time trying to explain to our clients that it's Joomla!'s bug, not ours. Merry Christmas...
Status | New | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2015-12-24 11:30:57 |
Closed_By | ⇒ | wilsonge |
Labels |
Added:
?
|
I've just tested all core CLI scripts without a problem. Could you please analyze this issue in more detail?
@nikosdion Are you aware of the problem?