Pending

User tests: Successful: Unsuccessful:

avatar mbabker
mbabker
26 Apr 2017

Summary of Changes

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.

Testing Instructions

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();

Expected result

Michaels-MacBook-Pro:joomla-cms mbabker$ php cli/session_test.php 
User retrieved

Actual result

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

Votes

# of Users Experiencing Issue
1/1
Average Importance Score
5.00

avatar mbabker mbabker - open - 26 Apr 2017
avatar mbabker mbabker - change - 26 Apr 2017
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 26 Apr 2017
Category Libraries
avatar nzampella
nzampella - comment - 27 Apr 2017

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.

avatar elkuku
elkuku - comment - 27 Apr 2017

I have tested this item successfully on 3292c86

Works.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15605.

avatar elkuku elkuku - test_item - 27 Apr 2017 - Tested successfully
avatar mbabker mbabker - change - 27 Apr 2017
Priority Medium Urgent
avatar alikon
alikon - comment - 27 Apr 2017

I have tested this item successfully on 3292c86


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/15605.

avatar alikon alikon - test_item - 27 Apr 2017 - Tested successfully
avatar wilsonge wilsonge - change - 27 Apr 2017
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2017-04-27 08:39:07
Closed_By wilsonge
avatar wilsonge wilsonge - close - 27 Apr 2017
avatar wilsonge wilsonge - merge - 27 Apr 2017
avatar alex-equities
alex-equities - comment - 3 May 2017

that fixed it, thanks

avatar tso2085
tso2085 - comment - 8 May 2017

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.

avatar vishalCTUK
vishalCTUK - comment - 23 Jun 2017

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

avatar brianteeman
brianteeman - comment - 23 Jun 2017

commenting on a closed issue will not be seen

avatar tso2085
tso2085 - comment - 23 Jun 2017

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.

Add a Comment

Login with GitHub to post a comment