bug #23711 Fix support for PHP 7.2 (Simperfit, nicolas-grekas)
This PR was merged into the 2.7 branch. Discussion ---------- Fix support for PHP 7.2 | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | no | Fixed tickets | #23671 | License | MIT | Doc PR | - There are still the deprecation problem with phpunit since it use `each()`. There are 3 tests linked to session that I don't know how to fix / what to do, do you have any idea @nicolas-grekas ? Commits -------fdf285b5c9
Fix 7.2 compat layere229dd0302
Fix PHP 7.2 support
This commit is contained in:
commit
5fd0fe6631
|
@ -25,8 +25,9 @@ matrix:
|
||||||
- php: 5.5
|
- php: 5.5
|
||||||
- php: 5.6
|
- php: 5.6
|
||||||
- php: 7.0
|
- php: 7.0
|
||||||
env: deps=high
|
|
||||||
- php: 7.1
|
- php: 7.1
|
||||||
|
env: deps=high
|
||||||
|
- php: 7.2
|
||||||
env: deps=low
|
env: deps=low
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,9 @@ class AppVariableTest extends TestCase
|
||||||
$this->assertEquals('dev', $this->appVariable->getEnvironment());
|
$this->assertEquals('dev', $this->appVariable->getEnvironment());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
public function testGetSession()
|
public function testGetSession()
|
||||||
{
|
{
|
||||||
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
$request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock();
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
"symfony/asset": "~2.7",
|
"symfony/asset": "~2.7",
|
||||||
"symfony/finder": "~2.3",
|
"symfony/finder": "~2.3",
|
||||||
"symfony/form": "~2.7.30|^2.8.23",
|
"symfony/form": "~2.7.30|^2.8.23",
|
||||||
|
"symfony/http-foundation": "~2.7.36|^2.8.29",
|
||||||
"symfony/http-kernel": "~2.3",
|
"symfony/http-kernel": "~2.3",
|
||||||
"symfony/intl": "~2.3",
|
"symfony/intl": "~2.3",
|
||||||
"symfony/routing": "~2.2",
|
"symfony/routing": "~2.2",
|
||||||
|
|
|
@ -55,7 +55,7 @@ class CacheClearCommandTest extends TestCase
|
||||||
$finder = new Finder();
|
$finder = new Finder();
|
||||||
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
|
$metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta');
|
||||||
// simply check that cache is warmed up
|
// simply check that cache is warmed up
|
||||||
$this->assertGreaterThanOrEqual(1, count($metaFiles));
|
$this->assertNotEmpty($metaFiles);
|
||||||
foreach ($metaFiles as $file) {
|
foreach ($metaFiles as $file) {
|
||||||
$configCache = new ConfigCache(substr($file, 0, -5), true);
|
$configCache = new ConfigCache(substr($file, 0, -5), true);
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
|
|
|
@ -143,6 +143,9 @@ class ControllerTest extends TestCase
|
||||||
$this->assertSame(302, $response->getStatusCode());
|
$this->assertSame(302, $response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
public function testAddFlash()
|
public function testAddFlash()
|
||||||
{
|
{
|
||||||
$flashBag = new FlashBag();
|
$flashBag = new FlashBag();
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
"symfony/config": "~2.4",
|
"symfony/config": "~2.4",
|
||||||
"symfony/event-dispatcher": "~2.5",
|
"symfony/event-dispatcher": "~2.5",
|
||||||
"symfony/finder": "^2.0.5",
|
"symfony/finder": "^2.0.5",
|
||||||
"symfony/http-foundation": "~2.7",
|
"symfony/http-foundation": "~2.7.36|^2.8.29",
|
||||||
"symfony/http-kernel": "~2.7.29|^2.8.22",
|
"symfony/http-kernel": "~2.7.29|^2.8.22",
|
||||||
"symfony/filesystem": "~2.3",
|
"symfony/filesystem": "~2.3",
|
||||||
"symfony/routing": "~2.7.24|^2.8.17",
|
"symfony/routing": "~2.7.24|^2.8.17",
|
||||||
|
|
|
@ -79,7 +79,9 @@ class ErrorHandlerTest extends TestCase
|
||||||
$this->assertEquals(E_NOTICE, $exception->getSeverity());
|
$this->assertEquals(E_NOTICE, $exception->getSeverity());
|
||||||
$this->assertEquals(__FILE__, $exception->getFile());
|
$this->assertEquals(__FILE__, $exception->getFile());
|
||||||
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
$this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage());
|
||||||
|
if (\PHP_VERSION_ID < 70200) {
|
||||||
$this->assertArrayHasKey('foobar', $exception->getContext());
|
$this->assertArrayHasKey('foobar', $exception->getContext());
|
||||||
|
}
|
||||||
|
|
||||||
$trace = $exception->getTrace();
|
$trace = $exception->getTrace();
|
||||||
$this->assertEquals(__FILE__, $trace[0]['file']);
|
$this->assertEquals(__FILE__, $trace[0]['file']);
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
throw new \Exception('boo');
|
if (!function_exists('__phpunit_run_isolated_test')) {
|
||||||
|
throw new \Exception('boo');
|
||||||
|
}
|
||||||
|
|
|
@ -421,6 +421,9 @@ class XmlFileLoaderTest extends TestCase
|
||||||
if (extension_loaded('suhosin') && false === strpos(ini_get('suhosin.executor.include.whitelist'), 'phar')) {
|
if (extension_loaded('suhosin') && false === strpos(ini_get('suhosin.executor.include.whitelist'), 'phar')) {
|
||||||
$this->markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.');
|
$this->markTestSkipped('To run this test, add "phar" to the "suhosin.executor.include.whitelist" settings in your php.ini file.');
|
||||||
}
|
}
|
||||||
|
if (defined('HHVM_VERSION')) {
|
||||||
|
$this->markTestSkipped('HHVM makes this test conflict with those run in separate processes.');
|
||||||
|
}
|
||||||
|
|
||||||
require_once self::$fixturesPath.'/includes/ProjectWithXsdExtensionInPhar.phar';
|
require_once self::$fixturesPath.'/includes/ProjectWithXsdExtensionInPhar.phar';
|
||||||
|
|
||||||
|
|
|
@ -23,12 +23,6 @@ class LegacyDefaultCsrfProviderTest extends TestCase
|
||||||
{
|
{
|
||||||
protected $provider;
|
protected $provider;
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
ini_set('session.save_handler', 'files');
|
|
||||||
ini_set('session.save_path', sys_get_temp_dir());
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$this->provider = new DefaultCsrfProvider('SECRET');
|
$this->provider = new DefaultCsrfProvider('SECRET');
|
||||||
|
|
|
@ -102,8 +102,11 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
*/
|
*/
|
||||||
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
|
||||||
{
|
{
|
||||||
session_cache_limiter(''); // disable by default because it's managed by HeaderBag (if used)
|
$options += array(
|
||||||
ini_set('session.use_cookies', 1);
|
// disable by default because it's managed by HeaderBag (if used)
|
||||||
|
'cache_limiter' => '',
|
||||||
|
'use_cookies' => 1,
|
||||||
|
);
|
||||||
|
|
||||||
if (\PHP_VERSION_ID >= 50400) {
|
if (\PHP_VERSION_ID >= 50400) {
|
||||||
session_register_shutdown();
|
session_register_shutdown();
|
||||||
|
@ -209,6 +212,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (headers_sent()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
if (null !== $lifetime) {
|
if (null !== $lifetime) {
|
||||||
ini_set('session.cookie_lifetime', $lifetime);
|
ini_set('session.cookie_lifetime', $lifetime);
|
||||||
}
|
}
|
||||||
|
@ -333,6 +340,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
*/
|
*/
|
||||||
public function setOptions(array $options)
|
public function setOptions(array $options)
|
||||||
{
|
{
|
||||||
|
if (headers_sent()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$validOptions = array_flip(array(
|
$validOptions = array_flip(array(
|
||||||
'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
'cache_limiter', 'cookie_domain', 'cookie_httponly',
|
||||||
'cookie_lifetime', 'cookie_path', 'cookie_secure',
|
'cookie_lifetime', 'cookie_path', 'cookie_secure',
|
||||||
|
@ -384,6 +395,10 @@ class NativeSessionStorage implements SessionStorageInterface
|
||||||
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.');
|
throw new \InvalidArgumentException('Must be instance of AbstractProxy or NativeSessionHandler; implement \SessionHandlerInterface; or be null.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (headers_sent($file, $line)) {
|
||||||
|
throw new \RuntimeException(sprintf('Failed to set the session handler because headers have already been sent by "%s" at line %d.', $file, $line));
|
||||||
|
}
|
||||||
|
|
||||||
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
|
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
|
||||||
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
|
||||||
$saveHandler = new SessionHandlerProxy($saveHandler);
|
$saveHandler = new SessionHandlerProxy($saveHandler);
|
||||||
|
|
|
@ -269,6 +269,9 @@ class PdoSessionHandlerTest extends TestCase
|
||||||
$this->assertSame('', $data, 'Destroyed session returns empty string');
|
$this->assertSame('', $data, 'Destroyed session returns empty string');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @runInSeparateProcess
|
||||||
|
*/
|
||||||
public function testSessionGC()
|
public function testSessionGC()
|
||||||
{
|
{
|
||||||
$previousLifeTime = ini_set('session.gc_maxlifetime', 1000);
|
$previousLifeTime = ini_set('session.gc_maxlifetime', 1000);
|
||||||
|
|
|
@ -38,8 +38,7 @@ class LocaleListenerTest extends TestCase
|
||||||
public function testLocaleFromRequestAttribute()
|
public function testLocaleFromRequestAttribute()
|
||||||
{
|
{
|
||||||
$request = Request::create('/');
|
$request = Request::create('/');
|
||||||
session_name('foo');
|
$request->cookies->set(session_name(), 'value');
|
||||||
$request->cookies->set('foo', 'value');
|
|
||||||
|
|
||||||
$request->attributes->set('_locale', 'es');
|
$request->attributes->set('_locale', 'es');
|
||||||
$listener = new LocaleListener('fr', null, $this->requestStack);
|
$listener = new LocaleListener('fr', null, $this->requestStack);
|
||||||
|
|
|
@ -62,8 +62,7 @@ class TestSessionListenerTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->sessionHasBeenStarted();
|
$this->sessionHasBeenStarted();
|
||||||
|
|
||||||
$params = session_get_cookie_params();
|
@ini_set('session.cookie_lifetime', 0);
|
||||||
session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']);
|
|
||||||
|
|
||||||
$response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST);
|
$response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST);
|
||||||
$cookies = $response->headers->getCookies();
|
$cookies = $response->headers->getCookies();
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=5.3.9",
|
"php": ">=5.3.9",
|
||||||
"symfony/event-dispatcher": "^2.6.7",
|
"symfony/event-dispatcher": "^2.6.7",
|
||||||
"symfony/http-foundation": "~2.7.20|^2.8.13",
|
"symfony/http-foundation": "~2.7.36|^2.8.29",
|
||||||
"symfony/debug": "^2.6.2",
|
"symfony/debug": "^2.6.2",
|
||||||
"psr/log": "~1.0"
|
"psr/log": "~1.0"
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
if (function_exists('__phpunit_run_isolated_test')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
/** @var $loader \Symfony\Component\Routing\Loader\PhpFileLoader */
|
/** @var $loader \Symfony\Component\Routing\Loader\PhpFileLoader */
|
||||||
/** @var \Symfony\Component\Routing\RouteCollection $collection */
|
/** @var \Symfony\Component\Routing\RouteCollection $collection */
|
||||||
$collection = $loader->import('validpattern.php');
|
$collection = $loader->import('validpattern.php');
|
||||||
|
|
|
@ -29,14 +29,6 @@ class NativeSessionTokenStorageTest extends TestCase
|
||||||
*/
|
*/
|
||||||
private $storage;
|
private $storage;
|
||||||
|
|
||||||
public static function setUpBeforeClass()
|
|
||||||
{
|
|
||||||
ini_set('session.save_handler', 'files');
|
|
||||||
ini_set('session.save_path', sys_get_temp_dir());
|
|
||||||
|
|
||||||
parent::setUpBeforeClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected function setUp()
|
protected function setUp()
|
||||||
{
|
{
|
||||||
$_SESSION = array();
|
$_SESSION = array();
|
||||||
|
|
Reference in New Issue