User tests: Successful: Unsuccessful:
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
Status | New | ⇒ | Pending |
Labels |
Added:
?
|
Milestone |
Added: |
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 :(
no it's not a fatal is a warning reggarding session_regenerate_id
.
i think is this case https://bugs.php.net/bug.php?id=70871
But not sure
I also see this http://stackoverflow.com/questions/34661205/sessions-in-codeigniter-with-php7
Maybe this already existed in 3.4.8, but cannot test now (i only have php 7 now)
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
# 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
so the session_regenerate_id
warning seems a new php 7 problem right?
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!
ok so anything more to test?
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?
right :)
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
navigated a little in a sample site, login, logout frontend and backend and have no problems.
Perfect sounds like a good test to me :)
Category | ⇒ | Libraries |
Status | Pending | ⇒ | Fixed in Code Base |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2016-03-26 00:56:56 |
Closed_By | ⇒ | wilsonge |
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
Tested the cli script in php 7.
Before patch
After patch
Is this how it's supposed to work?