From b862168cd043108fd1e5c999c953f57f0e6c4367 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 13 Nov 2017 06:34:51 +0100 Subject: [PATCH 1/5] fix method name --- src/Symfony/Component/Form/Form.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Form/Form.php b/src/Symfony/Component/Form/Form.php index 83f0055e0c..26c6c2077e 100644 --- a/src/Symfony/Component/Form/Form.php +++ b/src/Symfony/Component/Form/Form.php @@ -50,7 +50,7 @@ use Symfony\Component\PropertyAccess\PropertyPath; * either as "Y-m-d" string or as timestamp. Internally we still want to * use a DateTime object for processing. To convert the data from string/integer * to DateTime you can set a normalization transformer by calling - * addNormTransformer(). The normalized data is then converted to the displayed + * addModelTransformer(). The normalized data is then converted to the displayed * data as described before. * * The conversions (1) -> (2) -> (3) use the transform methods of the transformers. From 65ebe99e783a34b3b576b07b63d501106e90c5e2 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Nov 2017 16:31:11 +0100 Subject: [PATCH 2/5] [Process] Workaround PHP bug #75515 in ProcessTest::testSimpleInputStream() --- src/Symfony/Component/Process/Tests/ProcessTest.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Symfony/Component/Process/Tests/ProcessTest.php b/src/Symfony/Component/Process/Tests/ProcessTest.php index 9524778393..b73a5fa166 100644 --- a/src/Symfony/Component/Process/Tests/ProcessTest.php +++ b/src/Symfony/Component/Process/Tests/ProcessTest.php @@ -1223,13 +1223,9 @@ class ProcessTest extends TestCase public function testSimpleInputStream() { - if (\PHP_VERSION_ID === 70200 && \PHP_EXTRA_VERSION === 'RC6') { - $this->markTestSkipped('See bug #75515 in PHP 7.2RC6.'); - } - $input = new InputStream(); - $process = $this->getProcessForCode('echo \'ping\'; stream_copy_to_stream(STDIN, STDOUT);'); + $process = $this->getProcessForCode('echo \'ping\'; echo fread(STDIN, 4); echo fread(STDIN, 4);'); $process->setInput($input); $process->start(function ($type, $data) use ($input) { From 3eaa18889c5ca3c0573c78ad523d3101f83deea5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Nov 2017 16:41:44 +0100 Subject: [PATCH 3/5] [HttpFoundation] Fix session-related BC break --- .../Session/Storage/NativeSessionStorage.php | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php index e35af4e291..f03cdf3430 100644 --- a/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php +++ b/src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php @@ -102,12 +102,6 @@ class NativeSessionStorage implements SessionStorageInterface */ public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null) { - $this->setMetadataBag($metaBag); - - if (\PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status()) { - return; - } - $options += array( // disable by default because it's managed by HeaderBag (if used) 'cache_limiter' => '', @@ -120,6 +114,7 @@ class NativeSessionStorage implements SessionStorageInterface register_shutdown_function('session_write_close'); } + $this->setMetadataBag($metaBag); $this->setOptions($options); $this->setSaveHandler($handler); } @@ -292,7 +287,7 @@ class NativeSessionStorage implements SessionStorageInterface throw new \InvalidArgumentException(sprintf('The SessionBagInterface %s is not registered.', $name)); } - if ($this->saveHandler->isActive() && !$this->started) { + if (!$this->started && $this->saveHandler->isActive()) { $this->loadSession(); } elseif (!$this->started) { $this->start(); @@ -340,7 +335,7 @@ class NativeSessionStorage implements SessionStorageInterface */ public function setOptions(array $options) { - if (headers_sent()) { + if (headers_sent() || (\PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status())) { return; } @@ -395,10 +390,6 @@ class NativeSessionStorage implements SessionStorageInterface 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); @@ -408,6 +399,10 @@ class NativeSessionStorage implements SessionStorageInterface } $this->saveHandler = $saveHandler; + if (headers_sent() || (\PHP_VERSION_ID >= 50400 && \PHP_SESSION_ACTIVE === session_status())) { + return; + } + if ($this->saveHandler instanceof \SessionHandlerInterface) { if (\PHP_VERSION_ID >= 50400) { session_set_save_handler($this->saveHandler, false); From 38186aab2fbfffad55c05311e9a794689eb9295a Mon Sep 17 00:00:00 2001 From: Samuel ROZE Date: Mon, 13 Nov 2017 13:14:59 +0000 Subject: [PATCH 4/5] [HttpFoundation] Add test --- .../Session/Storage/NativeSessionStorageTest.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php index 673cd386bf..7eb7e56478 100644 --- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php +++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php @@ -296,4 +296,19 @@ class NativeSessionStorageTest extends TestCase // Assert no exception has been thrown by `getStorage()` $this->addToAssertionCount(1); } + + /** + * @requires PHP 5.4 + */ + public function testGetBagsOnceSessionStartedIsIgnored() + { + session_start(); + $bag = new AttributeBag(); + $bag->setName('flashes'); + + $storage = $this->getStorage(); + $storage->registerBag($bag); + + $this->assertEquals($storage->getBag('flashes'), $bag); + } } From 2dd74ab89e005556c4b8fe80c9f0328c1f34a989 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 13 Nov 2017 18:28:57 +0100 Subject: [PATCH 5/5] [DI] Fix dumping with custom base class --- .../Component/DependencyInjection/Dumper/PhpDumper.php | 8 ++++++-- .../Tests/Fixtures/php/services1-1.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index a402c6cebb..d60072b755 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -112,7 +112,11 @@ class PhpDumper extends Dumper 'debug' => true, ), $options); - $this->initializeMethodNamesMap($options['base_class']); + if (0 !== strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) { + $baseClass = sprintf('%s\%s', $options['namespace'] ? '\\'.$options['namespace'] : '', $baseClass); + } + + $this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass); $this->docStar = $options['debug'] ? '*' : ''; @@ -141,7 +145,7 @@ class PhpDumper extends Dumper } } - $code = $this->startClass($options['class'], $options['base_class'], $options['namespace']); + $code = $this->startClass($options['class'], $baseClass, $options['namespace']); if ($this->container->isCompiled()) { $code .= $this->addFrozenConstructor(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index b791398c13..ed49a7e1c2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -16,7 +16,7 @@ use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag; * * @final since Symfony 3.3 */ -class Container extends AbstractContainer +class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer { private $parameters; private $targetDirs = array();