Merge branch '3.3' into 3.4

* 3.3:
  [DI] Fix dumping with custom base class
  [HttpFoundation] Add test
  [HttpFoundation] Fix session-related BC break
  [Process] Workaround PHP bug #75515 in ProcessTest::testSimpleInputStream()
  fix method name
This commit is contained in:
Nicolas Grekas 2017-11-13 19:20:08 +01:00
commit ecad1c4b3b
6 changed files with 28 additions and 20 deletions

View File

@ -126,7 +126,12 @@ class PhpDumper extends Dumper
$this->asFiles = $options['as_files'];
$this->hotPathTag = $options['hot_path_tag'];
$this->inlineRequires = $this->container->hasParameter($options['inline_class_loader_parameter']) && $this->container->getParameter($options['inline_class_loader_parameter']);
$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'] ? '*' : '';
@ -156,7 +161,7 @@ class PhpDumper extends Dumper
}
$code =
$this->startClass($options['class'], $options['base_class']).
$this->startClass($options['class'], $baseClass).
$this->addServices().
$this->addDefaultParametersMethod().
$this->endClass()

View File

@ -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();

View File

@ -49,7 +49,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.

View File

@ -100,12 +100,6 @@ class NativeSessionStorage implements SessionStorageInterface
*/
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
{
$this->setMetadataBag($metaBag);
if (\PHP_SESSION_ACTIVE === session_status()) {
return;
}
$options += array(
'cache_limiter' => '',
'cache_expire' => 0,
@ -115,6 +109,7 @@ class NativeSessionStorage implements SessionStorageInterface
session_register_shutdown();
$this->setMetadataBag($metaBag);
$this->setOptions($options);
$this->setSaveHandler($handler);
}
@ -349,7 +344,7 @@ class NativeSessionStorage implements SessionStorageInterface
*/
public function setOptions(array $options)
{
if (headers_sent()) {
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
return;
}
@ -403,10 +398,6 @@ class NativeSessionStorage implements SessionStorageInterface
throw new \InvalidArgumentException('Must be instance of AbstractProxy; 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);
@ -415,6 +406,10 @@ class NativeSessionStorage implements SessionStorageInterface
}
$this->saveHandler = $saveHandler;
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
return;
}
if ($this->saveHandler instanceof SessionHandlerProxy) {
session_set_save_handler($this->saveHandler->getHandler(), false);
} elseif ($this->saveHandler instanceof \SessionHandlerInterface) {

View File

@ -262,4 +262,16 @@ class NativeSessionStorageTest extends TestCase
// Assert no exception has been thrown by `getStorage()`
$this->addToAssertionCount(1);
}
public function testGetBagsOnceSessionStartedIsIgnored()
{
session_start();
$bag = new AttributeBag();
$bag->setName('flashes');
$storage = $this->getStorage();
$storage->registerBag($bag);
$this->assertEquals($storage->getBag('flashes'), $bag);
}
}

View File

@ -1263,13 +1263,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) {