Merge pull request #3315 from Icinga/bugfix/php-7-2-support-3185
Don't call session_start() after ini_set()
This commit is contained in:
commit
4bea67e756
|
@ -29,7 +29,7 @@ class Session
|
|||
public static function create(BaseSession $session = null)
|
||||
{
|
||||
if ($session === null) {
|
||||
self::$session = new PhpSession();
|
||||
self::$session = PhpSession::create();
|
||||
} else {
|
||||
self::$session = $session;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/* Icinga Web 2 | (c) 2017 Icinga Development Team | GPLv2+ */
|
||||
|
||||
namespace Icinga\Web\Session;
|
||||
|
||||
use Icinga\Application\Logger;
|
||||
use Icinga\Exception\ConfigurationError;
|
||||
use Icinga\Web\Cookie;
|
||||
|
||||
/**
|
||||
* Session implementation in PHP
|
||||
*/
|
||||
class Php72Session extends PhpSession
|
||||
{
|
||||
/**
|
||||
* Open a PHP session
|
||||
*/
|
||||
protected function open()
|
||||
{
|
||||
session_name($this->sessionName);
|
||||
|
||||
$cookie = new Cookie('bogus');
|
||||
session_set_cookie_params(
|
||||
0,
|
||||
$cookie->getPath(),
|
||||
$cookie->getDomain(),
|
||||
$cookie->isSecure(),
|
||||
true
|
||||
);
|
||||
|
||||
session_start(array(
|
||||
'use_cookies' => true,
|
||||
'use_only_cookies' => true,
|
||||
'use_trans_sid' => false
|
||||
));
|
||||
}
|
||||
}
|
|
@ -33,6 +33,21 @@ class PhpSession extends Session
|
|||
*/
|
||||
protected $sessionName = 'Icingaweb2';
|
||||
|
||||
/**
|
||||
* Create a new PHPSession object using the provided options (if any)
|
||||
*
|
||||
* @param array $options An optional array of ini options to set
|
||||
*
|
||||
* @return static
|
||||
*
|
||||
* @throws ConfigurationError
|
||||
* @see http://php.net/manual/en/session.configuration.php
|
||||
*/
|
||||
public static function create(array $options = null)
|
||||
{
|
||||
return version_compare(PHP_VERSION, '7.2.0') < 0 ? new self($options) : new Php72Session($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new PHPSession object using the provided options (if any)
|
||||
*
|
||||
|
|
|
@ -13,7 +13,7 @@ class PhpSessionTest extends BaseTestCase
|
|||
if (!is_writable('/tmp')) {
|
||||
$this->markTestSkipped('Could not write to session directory');
|
||||
}
|
||||
return new PhpSession(
|
||||
return PhpSession::create(
|
||||
array(
|
||||
'use_cookies' => false,
|
||||
'save_path' => '/tmp',
|
||||
|
|
Loading…
Reference in New Issue