User tests: Successful: Unsuccessful:
Calling JFactory::getSession()
without a properly configured session already injected into JFactory::$session
results in an invalid JSession
object being created in that the internal dependencies are not fully initialized. Namely, the JSessionHandlerJoomla
class needs a JInput
instance which is not injected at all. The web applications build the JSession
object on their own and correctly call JSession::initialise()
with the needed dependencies, hence the reason this bug has not been previously reported; it takes running a custom web application not extending JApplicationCms
or a CLI application to reproduce the issue.
Place the following script in your site's cli
directory:
<?php
// We are a valid entry point.
const _JEXEC = 1;
// Load system defines
if (file_exists(dirname(__DIR__) . '/defines.php'))
{
require_once dirname(__DIR__) . '/defines.php';
}
if (!defined('_JDEFINES'))
{
define('JPATH_BASE', dirname(__DIR__));
require_once JPATH_BASE . '/includes/defines.php';
}
// Get the framework.
require_once JPATH_LIBRARIES . '/import.legacy.php';
// Bootstrap the CMS libraries.
require_once JPATH_LIBRARIES . '/cms.php';
// Configure error reporting to maximum for CLI output.
error_reporting(E_ALL);
ini_set('display_errors', 1);
class SessionTestCli extends JApplicationCli
{
public function doExecute()
{
JFactory::getUser();
$this->out('User retrieved');
}
}
// Instantiate the application object, passing the class name to JCli::getInstance
// and use chaining to execute the application.
JApplicationCli::getInstance('SessionTestCli')->execute();
Michaels-MacBook-Pro:joomla-cms mbabker$ php cli/session_test.php
User retrieved
Michaels-MacBook-Pro:joomla-cms mbabker$ php cli/session_test.php
Notice: Trying to get property of non-object in /libraries/joomla/session/handler/joomla.php on line 69
Call Stack:
0.0003 361576 1. {main}() /cli/session_test.php:0
0.0333 1729656 2. JApplicationCli->execute() /cli/session_test.php:38
0.0333 1729656 3. SessionTestCli->doExecute() /libraries/joomla/application/cli.php:142
0.0333 1729656 4. JFactory::getUser() /cli/session_test.php:31
0.0352 1884160 5. JSession->get() /libraries/joomla/factory.php:236
0.0352 1884160 6. JSession->start() /libraries/joomla/session/session.php:486
0.0352 1884160 7. JSession->_start() /libraries/joomla/session/session.php:608
0.0352 1884160 8. JSessionHandlerJoomla->start() /libraries/joomla/session/session.php:648
Error displaying the error page: Application Instantiation Error: Call to a member function get() on null
Status | New | ⇒ | Pending |
Category | ⇒ | Libraries |
I have tested this item
Works.
Priority | Medium | ⇒ | Urgent |
I have tested this item
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2017-04-27 08:39:07 |
Closed_By | ⇒ | wilsonge |
that fixed it, thanks
I was receiving this error when running a CRON job for CiviCRM. I made the changes to the factory.php file, but now I get a different error when the CRON job executes. I verified (3 times) that the changes were made correctly. The error now is:
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /../../public_html/../ccprod/libraries/joomla/session/handler/joomla.php on line 46
Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/../../public_html/../ccprod/libraries/joomla/session/handler/joomla.php" at line 46.
I receive the same error as tso2085, with my cron job from CiviCRM
Warning: ini_set(): A session is active. You cannot change the session module's ini settings at this time in /home/xxx/public_html/libraries/joomla/session/handler/joomla.php on line 46, I have error with the settings below
CivivCRM 4.7.20
Joomla 3.7.2
PHP 5.6
commenting on a closed issue will not be seen
vishalCTUK,
I created an item in the Joomla forum also. Unfortunately there have been no updates or suggestions to it. Feel free to add to the forum item if you wish:
https://forum.joomla.org/viewtopic.php?f=706&t=950332
This is still an issue for me as well.
Also related to issues with CRON jobs, see issue: 15603
This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15605.