? Success

User tests: Successful: Unsuccessful:

avatar wilsonge
wilsonge
23 Mar 2016

This fixes a fatal error being thrown when you use the restart method

Test CLI script to replicate issue. Before patch you get a fatal error trying to start the session twice. After patch no such error

<?php
const _JEXEC = 1;
error_reporting(E_ALL | E_NOTICE);
ini_set('display_errors', 1);

// Load system defines
if (file_exists(getcwd() . '/defines.php'))
{
    require_once getcwd() . '/defines.php';
}

if (!defined('_JDEFINES'))
{
    define('JPATH_BASE', getcwd());
    require_once JPATH_BASE . '/includes/defines.php';
}

require_once JPATH_LIBRARIES . '/import.legacy.php';
require_once JPATH_LIBRARIES . '/cms.php';

// Load the configuration
require_once JPATH_CONFIGURATION . '/configuration.php';

class TestIssue extends JApplicationCli
{
    public function doExecute()
    {
        JFactory::getSession()->initialise($this->input, $this->dispatcher);
        JFactory::getSession()->restart();
    }
}

JApplicationCli::getInstance('TestIssue')->execute();

Whilst the CMS doesn't use the restart method it does use the start method which has been tweaked here to remove duplicate code so just navigate around the CMS and check nothing major has been broken

avatar wilsonge wilsonge - open - 23 Mar 2016
avatar wilsonge wilsonge - change - 23 Mar 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 23 Mar 2016
Labels Added: ?
avatar wilsonge wilsonge - change - 23 Mar 2016
Milestone Added:
avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

Tested the cli script in php 7.

Before patch
# php test-cli.php
PHP Warning:  session_regenerate_id(): Cannot regenerate session id - session is not active in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 186

Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 186
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /path/to/joomla-staging/libraries/joomla/session/handler/native.php:186) in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 199

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /path/to/joomla-staging/libraries/joomla/session/handler/native.php:186) in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 199
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/joomla-staging/libraries/joomla/session/handler/native.php:186) in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 199

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/joomla-staging/libraries/joomla/session/handler/native.php:186) in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 199
Error displaying the error page: Application Instantiation Error: Failed to start the session: already started by PHP.
After patch
# php test-cli.php
PHP Warning:  session_regenerate_id(): Cannot regenerate session id - session is not active in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 150

Warning: session_regenerate_id(): Cannot regenerate session id - session is not active in /path/to/joomla-staging/libraries/joomla/session/handler/native.php on line 150
Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/path/to/joomla-staging/libraries/joomla/session/handler/native.php" at line 150.

Is this how it's supposed to work?

avatar wilsonge
wilsonge - comment - 23 Mar 2016

For me I get (running PHP 5.5.15)

Before

georg_000@GeorgeLaptop MINGW64 /c/VirtualHost/joomla350.testing.org/joomla-cms (staging)
$ php cli/testRegenerate.php
Error displaying the error page: Application Instantiation Error: Failed to star
t the session: already started by PHP.

After

georg_000@GeorgeLaptop MINGW64 /c/VirtualHost/joomla350.testing.org/joomla-cms (staging)
$ php cli/testRegenerate.php

Looks like you still get the fatal on PHP 7 :(

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

no it's not a fatal is a warning reggarding session_regenerate_id.

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016
avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

Maybe this already existed in 3.4.8, but cannot test now (i only have php 7 now)

avatar wilsonge
wilsonge - comment - 23 Mar 2016

Can you try dropping in the 3.4.8 session.php file into the 3.5 install and see what happens please. That file was PHP 7 compatible anyhow - so should be ok

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016
3.4.8 test
# php test-cli.php
PHP Warning:  session_destroy(): Trying to destroy uninitialized session in /path/to/joomla-348/libraries/joomla/session/session.php on line 729

Warning: session_destroy(): Trying to destroy uninitialized session in /path/to/joomla-348/libraries/joomla/session/session.php on line 729
PHP Warning:  session_regenerate_id(): Cannot regenerate session id - headers already sent in /path/to/joomla-348/libraries/joomla/session/session.php on line 757

Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /path/to/joomla-348/libraries/joomla/session/session.php on line 757
PHP Warning:  session_regenerate_id(): Cannot regenerate session id - headers already sent in /path/to/joomla-348/libraries/joomla/session/session.php on line 623

Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /path/to/joomla-348/libraries/joomla/session/session.php on line 623
PHP Warning:  session_start(): Cannot send session cookie - headers already sent by (output started at /path/to/joomla-348/libraries/joomla/session/session.php:729) in /path/to/joomla-348/libraries/joomla/session/session.php on line 651

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /path/to/joomla-348/libraries/joomla/session/session.php:729) in /path/to/joomla-348/libraries/joomla/session/session.php on line 651
PHP Warning:  session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/joomla-348/libraries/joomla/session/session.php:729) in /path/to/joomla-348/libraries/joomla/session/session.php on line 651

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /path/to/joomla-348/libraries/joomla/session/session.php:729) in /path/to/joomla-348/libraries/joomla/session/session.php on line 651
avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

so the session_regenerate_id warning seems a new php 7 problem right?

avatar wilsonge
wilsonge - comment - 23 Mar 2016

It would appear so. I mean it kinda makes sense - the php.net article says:

Update the current session id with a newly generated one

But we are currently destroying the session, calling regenerate id and then restarting it!? Which seems totally wrong. But i'd rather fix one issue at a time. And let's not start the session twice!

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

ok so anything more to test?

avatar wilsonge
wilsonge - comment - 23 Mar 2016

I don't think so. On PHP 5.5 for me i've removed a fatal. You don't get as far as the fatal because of the php warnings - but I guess as there are less warnings that has to be a good thing right?

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

right :)

avatar wilsonge
wilsonge - comment - 23 Mar 2016

Can you just confirm i haven't screwed up any of the rest of Joomla with this. As I said at the end we don't use the restart method - but we do start sessions :P I can't imagine how this could cause problems as it's a copy/paste of the existing code into a common method. But just in case :P

avatar andrepereiradasilva
andrepereiradasilva - comment - 23 Mar 2016

navigated a little in a sample site, login, logout frontend and backend and have no problems.

avatar wilsonge
wilsonge - comment - 23 Mar 2016

Perfect sounds like a good test to me :)

avatar brianteeman brianteeman - change - 24 Mar 2016
Category Libraries
avatar wilsonge wilsonge - change - 26 Mar 2016
Status Pending Fixed in Code Base
Closed_Date 0000-00-00 00:00:00 2016-03-26 00:56:56
Closed_By wilsonge
avatar wilsonge wilsonge - close - 26 Mar 2016
avatar wilsonge wilsonge - merge - 26 Mar 2016
avatar wilsonge wilsonge - reference | ff1fdcb - 26 Mar 16
avatar wilsonge wilsonge - merge - 26 Mar 2016
avatar wilsonge wilsonge - close - 26 Mar 2016
avatar wilsonge
wilsonge - comment - 26 Mar 2016

I've contacted siteground and this fixed an issue in their automatic upgrade script as well so merging this combined with sitegrounds and @andrepereiradasilva 's test

Add a Comment

Login with GitHub to post a comment