diff --git a/.travis.yml b/.travis.yml index e01ab63ab3227..e34ba5a8bcaaf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,8 +25,9 @@ matrix: - php: 5.5 - php: 5.6 - php: 7.0 - env: deps=high - php: 7.1 + env: deps=high + - php: 7.2 env: deps=low fast_finish: true diff --git a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php index 9abb0e3b6ea78..b9aa168fd763d 100644 --- a/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php +++ b/src/Symfony/Bridge/Twig/Tests/AppVariableTest.php @@ -44,6 +44,9 @@ public function testEnvironment() $this->assertEquals('dev', $this->appVariable->getEnvironment()); } + /** + * @runInSeparateProcess + */ public function testGetSession() { $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')->getMock(); diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 9610edc8085b5..04e3819176844 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -23,6 +23,7 @@ "symfony/asset": "~2.7", "symfony/finder": "~2.3", "symfony/form": "~2.7.30|^2.8.23", + "symfony/http-foundation": "~2.7.36|^2.8.29", "symfony/http-kernel": "~2.3", "symfony/intl": "~2.3", "symfony/routing": "~2.2", diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php index f1140e86bb378..a25aa8e637e44 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Command/CacheClearCommand/CacheClearCommandTest.php @@ -55,7 +55,7 @@ public function testCacheIsFreshAfterCacheClearedWithWarmup() $finder = new Finder(); $metaFiles = $finder->files()->in($this->kernel->getCacheDir())->name('*.php.meta'); // simply check that cache is warmed up - $this->assertGreaterThanOrEqual(1, count($metaFiles)); + $this->assertNotEmpty($metaFiles); foreach ($metaFiles as $file) { $configCache = new ConfigCache(substr($file, 0, -5), true); $this->assertTrue( diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php index d7f40a24d8b4a..cb813c61d62ac 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php +++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerTest.php @@ -143,6 +143,9 @@ public function testRedirectToRoute() $this->assertSame(302, $response->getStatusCode()); } + /** + * @runInSeparateProcess + */ public function testAddFlash() { $flashBag = new FlashBag(); diff --git a/src/Symfony/Bundle/FrameworkBundle/composer.json b/src/Symfony/Bundle/FrameworkBundle/composer.json index 76648774f3baa..ed611114fe2aa 100644 --- a/src/Symfony/Bundle/FrameworkBundle/composer.json +++ b/src/Symfony/Bundle/FrameworkBundle/composer.json @@ -23,7 +23,7 @@ "symfony/config": "~2.4", "symfony/event-dispatcher": "~2.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/filesystem": "~2.3", "symfony/routing": "~2.7.24|^2.8.17", diff --git a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php index 898a985a29e2f..fd9ac577ee73a 100644 --- a/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php +++ b/src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php @@ -79,7 +79,9 @@ public function testNotice() $this->assertEquals(E_NOTICE, $exception->getSeverity()); $this->assertEquals(__FILE__, $exception->getFile()); $this->assertRegExp('/^Notice: Undefined variable: (foo|bar)/', $exception->getMessage()); - $this->assertArrayHasKey('foobar', $exception->getContext()); + if (\PHP_VERSION_ID < 70200) { + $this->assertArrayHasKey('foobar', $exception->getContext()); + } $trace = $exception->getTrace(); $this->assertEquals(__FILE__, $trace[0]['file']); diff --git a/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php b/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php index 21e0aba17d358..d338ca9d5752b 100644 --- a/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php +++ b/src/Symfony/Component/Debug/Tests/Fixtures/Throwing.php @@ -1,3 +1,5 @@ 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'; diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php index 824e81c553032..8cca486369ec0 100644 --- a/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php +++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/CsrfProvider/LegacyDefaultCsrfProviderTest.php @@ -23,12 +23,6 @@ class LegacyDefaultCsrfProviderTest extends TestCase { protected $provider; - public static function setUpBeforeClass() - { - ini_set('session.save_handler', 'files'); - ini_set('session.save_path', sys_get_temp_dir()); - } - protected function setUp() { $this->provider = new DefaultCsrfProvider('SECRET'); diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index 5888323bd7c30..09cb242f92c2d 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -101,8 +101,11 @@ class NativeSessionStorage implements SessionStorageInterface */ 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) - ini_set('session.use_cookies', 1); + $options += array( + // disable by default because it's managed by HeaderBag (if used) + 'cache_limiter' => '', + 'use_cookies' => 1, + ); if (\PHP_VERSION_ID >= 50400) { session_register_shutdown(); @@ -208,6 +211,10 @@ public function regenerate($destroy = false, $lifetime = null) return false; } + if (headers_sent()) { + return false; + } + if (null !== $lifetime) { ini_set('session.cookie_lifetime', $lifetime); } @@ -332,6 +339,10 @@ public function isStarted() */ public function setOptions(array $options) { + if (headers_sent()) { + return; + } + $validOptions = array_flip(array( 'cache_limiter', 'cookie_domain', 'cookie_httponly', 'cookie_lifetime', 'cookie_path', 'cookie_secure', @@ -383,6 +394,10 @@ public function setSaveHandler($saveHandler = 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 if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) { $saveHandler = new SessionHandlerProxy($saveHandler); diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php index a47120f1807e2..a9884c1c92ea3 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php @@ -269,6 +269,9 @@ public function testSessionDestroy() $this->assertSame('', $data, 'Destroyed session returns empty string'); } + /** + * @runInSeparateProcess + */ public function testSessionGC() { $previousLifeTime = ini_set('session.gc_maxlifetime', 1000); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php index b6977ea88b6de..1898ee0863a4b 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/LocaleListenerTest.php @@ -38,8 +38,7 @@ public function testDefaultLocaleWithoutSession() public function testLocaleFromRequestAttribute() { $request = Request::create('/'); - session_name('foo'); - $request->cookies->set('foo', 'value'); + $request->cookies->set(session_name(), 'value'); $request->attributes->set('_locale', 'es'); $listener = new LocaleListener('fr', null, $this->requestStack); diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php index 52794e0272832..47ee153342df5 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/TestSessionListenerTest.php @@ -62,8 +62,7 @@ public function testDoesNotDeleteCookieIfUsingSessionLifetime() { $this->sessionHasBeenStarted(); - $params = session_get_cookie_params(); - session_set_cookie_params(0, $params['path'], $params['domain'], $params['secure'], $params['httponly']); + @ini_set('session.cookie_lifetime', 0); $response = $this->filterResponse(new Request(), HttpKernelInterface::MASTER_REQUEST); $cookies = $response->headers->getCookies(); diff --git a/src/Symfony/Component/HttpKernel/composer.json b/src/Symfony/Component/HttpKernel/composer.json index 6b6ec3f17b886..1b6b096a8a61f 100644 --- a/src/Symfony/Component/HttpKernel/composer.json +++ b/src/Symfony/Component/HttpKernel/composer.json @@ -18,7 +18,7 @@ "require": { "php": ">=5.3.9", "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", "psr/log": "~1.0" }, diff --git a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.php b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.php index 482c80b29e919..f59a234d6589a 100644 --- a/src/Symfony/Component/Routing/Tests/Fixtures/validresource.php +++ b/src/Symfony/Component/Routing/Tests/Fixtures/validresource.php @@ -1,5 +1,8 @@ import('validpattern.php'); diff --git a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php index ea20cff5291ff..d7931c09b2099 100644 --- a/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php +++ b/src/Symfony/Component/Security/Csrf/Tests/TokenStorage/NativeSessionTokenStorageTest.php @@ -29,14 +29,6 @@ class NativeSessionTokenStorageTest extends TestCase */ 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() { $_SESSION = array();