Skip to content

Commit ecad1c4

Browse files
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
2 parents 3946f25 + 772f29f commit ecad1c4

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,12 @@ public function dump(array $options = array())
126126
$this->asFiles = $options['as_files'];
127127
$this->hotPathTag = $options['hot_path_tag'];
128128
$this->inlineRequires = $this->container->hasParameter($options['inline_class_loader_parameter']) && $this->container->getParameter($options['inline_class_loader_parameter']);
129-
$this->initializeMethodNamesMap($options['base_class']);
129+
130+
if (0 !== strpos($baseClass = $options['base_class'], '\\') && 'Container' !== $baseClass) {
131+
$baseClass = sprintf('%s\%s', $options['namespace'] ? '\\'.$options['namespace'] : '', $baseClass);
132+
}
133+
134+
$this->initializeMethodNamesMap('Container' === $baseClass ? Container::class : $baseClass);
130135

131136
$this->docStar = $options['debug'] ? '*' : '';
132137

@@ -156,7 +161,7 @@ public function dump(array $options = array())
156161
}
157162

158163
$code =
159-
$this->startClass($options['class'], $options['base_class']).
164+
$this->startClass($options['class'], $baseClass).
160165
$this->addServices().
161166
$this->addDefaultParametersMethod().
162167
$this->endClass()

src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @final since Symfony 3.3
1818
*/
19-
class Container extends AbstractContainer
19+
class Container extends \Symfony\Component\DependencyInjection\Dump\AbstractContainer
2020
{
2121
private $parameters;
2222
private $targetDirs = array();

src/Symfony/Component/Form/Form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
* either as "Y-m-d" string or as timestamp. Internally we still want to
5050
* use a DateTime object for processing. To convert the data from string/integer
5151
* to DateTime you can set a normalization transformer by calling
52-
* addNormTransformer(). The normalized data is then converted to the displayed
52+
* addModelTransformer(). The normalized data is then converted to the displayed
5353
* data as described before.
5454
*
5555
* The conversions (1) -> (2) -> (3) use the transform methods of the transformers.

src/Symfony/Component/HttpFoundation/Session/Storage/NativeSessionStorage.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -100,12 +100,6 @@ class NativeSessionStorage implements SessionStorageInterface
100100
*/
101101
public function __construct(array $options = array(), $handler = null, MetadataBag $metaBag = null)
102102
{
103-
$this->setMetadataBag($metaBag);
104-
105-
if (\PHP_SESSION_ACTIVE === session_status()) {
106-
return;
107-
}
108-
109103
$options += array(
110104
'cache_limiter' => '',
111105
'cache_expire' => 0,
@@ -115,6 +109,7 @@ public function __construct(array $options = array(), $handler = null, MetadataB
115109

116110
session_register_shutdown();
117111

112+
$this->setMetadataBag($metaBag);
118113
$this->setOptions($options);
119114
$this->setSaveHandler($handler);
120115
}
@@ -349,7 +344,7 @@ public function isStarted()
349344
*/
350345
public function setOptions(array $options)
351346
{
352-
if (headers_sent()) {
347+
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
353348
return;
354349
}
355350

@@ -403,10 +398,6 @@ public function setSaveHandler($saveHandler = null)
403398
throw new \InvalidArgumentException('Must be instance of AbstractProxy; implement \SessionHandlerInterface; or be null.');
404399
}
405400

406-
if (headers_sent($file, $line)) {
407-
throw new \RuntimeException(sprintf('Failed to set the session handler because headers have already been sent by "%s" at line %d.', $file, $line));
408-
}
409-
410401
// Wrap $saveHandler in proxy and prevent double wrapping of proxy
411402
if (!$saveHandler instanceof AbstractProxy && $saveHandler instanceof \SessionHandlerInterface) {
412403
$saveHandler = new SessionHandlerProxy($saveHandler);
@@ -415,6 +406,10 @@ public function setSaveHandler($saveHandler = null)
415406
}
416407
$this->saveHandler = $saveHandler;
417408

409+
if (headers_sent() || \PHP_SESSION_ACTIVE === session_status()) {
410+
return;
411+
}
412+
418413
if ($this->saveHandler instanceof SessionHandlerProxy) {
419414
session_set_save_handler($this->saveHandler->getHandler(), false);
420415
} elseif ($this->saveHandler instanceof \SessionHandlerInterface) {

src/Symfony/Component/HttpFoundation/Tests/Session/Storage/NativeSessionStorageTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,4 +262,16 @@ public function testSetSessionOptionsOnceSessionStartedIsIgnored()
262262
// Assert no exception has been thrown by `getStorage()`
263263
$this->addToAssertionCount(1);
264264
}
265+
266+
public function testGetBagsOnceSessionStartedIsIgnored()
267+
{
268+
session_start();
269+
$bag = new AttributeBag();
270+
$bag->setName('flashes');
271+
272+
$storage = $this->getStorage();
273+
$storage->registerBag($bag);
274+
275+
$this->assertEquals($storage->getBag('flashes'), $bag);
276+
}
265277
}

src/Symfony/Component/Process/Tests/ProcessTest.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,13 +1263,9 @@ public function testIteratorInput()
12631263

12641264
public function testSimpleInputStream()
12651265
{
1266-
if (\PHP_VERSION_ID === 70200 && \PHP_EXTRA_VERSION === 'RC6') {
1267-
$this->markTestSkipped('See bug #75515 in PHP 7.2RC6.');
1268-
}
1269-
12701266
$input = new InputStream();
12711267

1272-
$process = $this->getProcessForCode('echo \'ping\'; stream_copy_to_stream(STDIN, STDOUT);');
1268+
$process = $this->getProcessForCode('echo \'ping\'; echo fread(STDIN, 4); echo fread(STDIN, 4);');
12731269
$process->setInput($input);
12741270

12751271
$process->start(function ($type, $data) use ($input) {

0 commit comments

Comments
 (0)