Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3baa43b

Browse files
committed
Merge branch '2.4'
* 2.4: (52 commits) Fix #8205 : Deprecate file mode update when calling dumpFile Fix #10437: Catch exceptions when reloading a no-cache request Fix libxml_use_internal_errors and libxml_disable_entity_loader usage removed ini check to make uploadedfile work on gae Update OptionsResolver.php fixed comment in forms.xml file Clean KernelInterface docblocks Cast the group name as a string Fixed doc of InitAclCommand [Form] Fix "Array was modified outside object" in ResizeFormListener. Fix IBAN validator [Process] Remove unreachable code + avoid skipping tests in sigchild environment Fixed bug that incorrectly causes the "required" attribute to be omitted from select even though it contains the "multiple" attribute Added travis_retry to .travis.yml [Process] fix some typos and refactor some code [Process] Fix unit tests in sigchild disabled environment [Process] Trow exceptions in case a Process method is supposed to be called after termination fixed typo [Process] fixed fatal errors in getOutput and getErrorOutput when process was not started [Process] Fix escaping on Windows ... Conflicts: src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php src/Symfony/Component/Form/Extension/Core/EventListener/ResizeFormListener.php src/Symfony/Component/Process/Process.php src/Symfony/Component/Process/ProcessPipes.php src/Symfony/Component/Process/Tests/AbstractProcessTest.php
2 parents 9e13cc0 + ab42e9c commit 3baa43b

File tree

60 files changed

+748
-241
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+748
-241
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ matrix:
1515
services: mongodb
1616

1717
before_script:
18-
- sudo apt-get install parallel
18+
- travis_retry sudo apt-get install parallel
1919
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "" >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini; fi;'
2020
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ]; then echo "extension = mongo.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'
2121
- sh -c 'if [ "$TRAVIS_PHP_VERSION" != "hhvm" ] && [ $(php -r "echo PHP_MINOR_VERSION;") -le 4 ]; then echo "extension = apc.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini; fi;'

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2004-2013 Fabien Potencier
1+
Copyright (c) 2004-2014 Fabien Potencier
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy
44
of this software and associated documentation files (the "Software"), to deal

src/Symfony/Bridge/Twig/Resources/views/Form/form_div_layout.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767

6868
{% block choice_widget_collapsed %}
6969
{% spaceless %}
70-
{% if required and empty_value is none and not empty_value_in_choices %}
70+
{% if required and empty_value is none and not empty_value_in_choices and not multiple %}
7171
{% set required = false %}
7272
{% endif %}
7373
<select {{ block('widget_attributes') }}{% if multiple %} multiple="multiple"{% endif %}>

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"symfony/yaml": "For using the YamlExtension",
4242
"symfony/security": "For using the SecurityExtension",
4343
"symfony/stopwatch": "For using the StopwatchExtension",
44-
"symfony/expression": "For using the ExpressionExtension"
44+
"symfony/expression-language": "For using the ExpressionExtension"
4545
},
4646
"autoload": {
4747
"psr-0": { "Symfony\\Bridge\\Twig\\": "" }

src/Symfony/Bundle/FrameworkBundle/Command/ServerRunCommand.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ protected function configure()
6767
6868
<info>%command.full_name% --router=app/config/router.php</info>
6969
70+
Specifing a router script is required when the used environment is not "dev" or
71+
"prod".
72+
7073
See also: http://www.php.net/manual/en/features.commandline.webserver.php
7174
7275
EOF
@@ -85,7 +88,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
8588
$output->writeln('<error>Running PHP built-in server in production environment is NOT recommended!</error>');
8689
}
8790

88-
$output->writeln(sprintf("Server running on <info>%s</info>\n", $input->getArgument('address')));
91+
$output->writeln(sprintf("Server running on <info>http://%s</info>\n", $input->getArgument('address')));
92+
93+
$router = $input->getOption('router') ?: $this
94+
->getContainer()
95+
->get('kernel')
96+
->locateResource(sprintf('@FrameworkBundle/Resources/config/router_%s.php', $env))
97+
;
8998

9099
if (defined('HHVM_VERSION')) {
91100
$builder = $this->createHhvmProcessBuilder($input, $output, $env);

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/CompilerDebugDumpPass.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class CompilerDebugDumpPass implements CompilerPassInterface
2020
{
2121
public function process(ContainerBuilder $container)
2222
{
23+
$filename = self::getCompilerLogFilename($container);
24+
2325
$filesystem = new Filesystem();
24-
$filesystem->dumpFile(
25-
self::getCompilerLogFilename($container),
26-
implode("\n", $container->getCompiler()->getLog()),
27-
0666 & ~umask()
28-
);
26+
$filesystem->dumpFile($filename, implode("\n", $container->getCompiler()->getLog()), null);
27+
// discard chmod failure (some filesystem may not support it)
28+
@chmod($filename, 0666 & ~umask());
2929
}
3030

3131
public static function getCompilerLogFilename(ContainerInterface $container)

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ContainerBuilderDebugDumpPass.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ class ContainerBuilderDebugDumpPass implements CompilerPassInterface
2828
public function process(ContainerBuilder $container)
2929
{
3030
$dumper = new XmlDumper($container);
31+
$filename = $container->getParameter('debug.container.dump');
3132
$filesystem = new Filesystem();
32-
$filesystem->dumpFile(
33-
$container->getParameter('debug.container.dump'),
34-
$dumper->dump(),
35-
0666 & ~umask()
36-
);
33+
$filesystem->dumpFile($filename, $dumper->dump(), null);
34+
// discard chmod failure (some filesystem may not support it)
35+
@chmod($filename, 0666 & ~umask());
3736
}
3837
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/form.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
We don't need to be able to add more extensions.
2525
* more types can be registered with the form.type tag
2626
* more type extensions can be registered with the form.type_extension tag
27-
* more type_guessers can be registered with the form.type.type_guesser tag
27+
* more type_guessers can be registered with the form.type_guesser tag
2828
-->
2929
<argument type="service" id="form.extension" />
3030
</argument>

src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/choice_widget_collapsed.html.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<select
2+
<?php if ($required && $empty_value === null && $empty_value_in_choices === false && $multiple === false):
3+
$required = false;
4+
endif; ?>
25
<?php echo $view['form']->block($form, 'widget_attributes', array(
3-
'required' => $required && (null !== $empty_value || $empty_value_in_choices)
6+
'required' => $required
47
)) ?>
58
<?php if ($multiple): ?> multiple="multiple"<?php endif ?>
69
>

src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class InitAclCommand extends ContainerAwareCommand
2525
{
2626
/**
27-
* @see Command
27+
* {@inheritdoc}
2828
*/
2929
protected function configure()
3030
{
@@ -47,7 +47,7 @@ protected function configure()
4747
}
4848

4949
/**
50-
* @see Command::execute()
50+
* {@inheritdoc}
5151
*/
5252
protected function execute(InputInterface $input, OutputInterface $output)
5353
{

src/Symfony/Component/BrowserKit/Cookie.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public function __toString()
9696
throw new \UnexpectedValueException(sprintf('The cookie expiration time "%s" is not valid.'), $this->expires);
9797
}
9898

99-
$cookie .= '; expires='.substr($dateTime->format(self::$dateFormats[0]), 0, -5);
99+
$cookie .= '; expires='.str_replace('+0000', '', $dateTime->format(self::$dateFormats[0]));
100100
}
101101

102102
if ('' !== $this->domain) {

src/Symfony/Component/Config/ConfigCache.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,12 @@ public function write($content, array $metadata = null)
9595
{
9696
$mode = 0666 & ~umask();
9797
$filesystem = new Filesystem();
98-
$filesystem->dumpFile($this->file, $content, $mode);
98+
$filesystem->dumpFile($this->file, $content, null);
99+
@chmod($this->file, $mode);
99100

100101
if (null !== $metadata && true === $this->debug) {
101-
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), $mode);
102+
$filesystem->dumpFile($this->getMetaFile(), serialize($metadata), null);
103+
@chmod($this->getMetaFile(), $mode);
102104
}
103105
}
104106

src/Symfony/Component/Config/Loader/DelegatingLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@ public function load($resource, $type = null)
5757
*/
5858
public function supports($resource, $type = null)
5959
{
60-
return false === $this->resolver->resolve($resource, $type) ? false : true;
60+
return false !== $this->resolver->resolve($resource, $type);
6161
}
6262
}

src/Symfony/Component/Config/Tests/Util/XmlUtilsTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ public function getDataForConvertDomToArray()
8080
array(array('foo' => null), '<foo />'),
8181
array(array('foo' => 'bar'), '<foo>bar</foo>'),
8282
array(array('foo' => array('foo' => 'bar')), '<foo foo="bar"/>'),
83+
array(array('foo' => array('foo' => 0)), '<foo><foo>0</foo></foo>'),
8384
array(array('foo' => array('foo' => 'bar')), '<foo><foo>bar</foo></foo>'),
8485
array(array('foo' => array('foo' => 'bar', 'value' => 'text')), '<foo foo="bar">text</foo>'),
8586
array(array('foo' => array('attr' => 'bar', 'foo' => 'text')), '<foo attr="bar"><foo>text</foo></foo>'),
@@ -132,6 +133,45 @@ public function getDataForPhpize()
132133
array(6, '0b0110'),
133134
);
134135
}
136+
137+
public function testLoadEmptyXmlFile()
138+
{
139+
$file = __DIR__.'/../Fixtures/foo.xml';
140+
$this->setExpectedException('InvalidArgumentException', 'File '.$file.' does not contain valid XML, it is empty.');
141+
XmlUtils::loadFile($file);
142+
}
143+
144+
// test for issue https://github.com/symfony/symfony/issues/9731
145+
public function testLoadWrongEmptyXMLWithErrorHandler()
146+
{
147+
$originalDisableEntities = libxml_disable_entity_loader(false);
148+
$errorReporting = error_reporting(-1);
149+
150+
set_error_handler(function ($errno, $errstr) {
151+
throw new \Exception($errstr, $errno);
152+
});
153+
154+
$file = __DIR__.'/../Fixtures/foo.xml';
155+
try {
156+
XmlUtils::loadFile($file);
157+
$this->fail('An exception should have been raised');
158+
} catch (\InvalidArgumentException $e) {
159+
$this->assertEquals(sprintf('File %s does not contain valid XML, it is empty.', $file), $e->getMessage());
160+
}
161+
162+
restore_error_handler();
163+
error_reporting($errorReporting);
164+
165+
$disableEntities = libxml_disable_entity_loader(true);
166+
libxml_disable_entity_loader($disableEntities);
167+
168+
libxml_disable_entity_loader($originalDisableEntities);
169+
170+
$this->assertFalse($disableEntities);
171+
172+
// should not throw an exception
173+
XmlUtils::loadFile(__DIR__.'/../Fixtures/Util/valid.xml', __DIR__.'/../Fixtures/Util/schema.xsd');
174+
}
135175
}
136176

137177
interface Validator

src/Symfony/Component/Config/Util/XmlUtils.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,18 @@ private function __construct()
4040
*/
4141
public static function loadFile($file, $schemaOrCallable = null)
4242
{
43+
$content = @file_get_contents($file);
44+
if ('' === trim($content)) {
45+
throw new \InvalidArgumentException(sprintf('File %s does not contain valid XML, it is empty.', $file));
46+
}
47+
4348
$internalErrors = libxml_use_internal_errors(true);
4449
$disableEntities = libxml_disable_entity_loader(true);
4550
libxml_clear_errors();
4651

4752
$dom = new \DOMDocument();
4853
$dom->validateOnParse = true;
49-
if (!$dom->loadXML(file_get_contents($file), LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
54+
if (!$dom->loadXML($content, LIBXML_NONET | (defined('LIBXML_COMPACT') ? LIBXML_COMPACT : 0))) {
5055
libxml_disable_entity_loader($disableEntities);
5156

5257
throw new \InvalidArgumentException(implode("\n", static::getXmlErrors($internalErrors)));
@@ -132,7 +137,7 @@ public static function convertDomElementToArray(\DomElement $element, $checkPref
132137
$nodeValue = false;
133138
foreach ($element->childNodes as $node) {
134139
if ($node instanceof \DOMText) {
135-
if (trim($node->nodeValue)) {
140+
if ('' !== trim($node->nodeValue)) {
136141
$nodeValue = trim($node->nodeValue);
137142
$empty = false;
138143
}

src/Symfony/Component/CssSelector/Tests/XPath/TranslatorTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public function testHtmlIds($css, array $elementsId)
4949
$translator->registerExtension(new HtmlExtension($translator));
5050
$document = new \DOMDocument();
5151
$document->strictErrorChecking = false;
52-
libxml_use_internal_errors(true);
52+
$internalErrors = libxml_use_internal_errors(true);
5353
$document->loadHTMLFile(__DIR__.'/Fixtures/ids.html');
5454
$document = simplexml_import_dom($document);
5555
$elements = $document->xpath($translator->cssToXPath($css));
@@ -59,6 +59,8 @@ public function testHtmlIds($css, array $elementsId)
5959
$this->assertTrue(in_array($element->attributes()->id, $elementsId));
6060
}
6161
}
62+
libxml_clear_errors();
63+
libxml_use_internal_errors($internalErrors);
6264
}
6365

6466
/** @dataProvider getHtmlShakespearTestData */

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public function addContent($content, $type = null)
151151
*/
152152
public function addHtmlContent($content, $charset = 'UTF-8')
153153
{
154-
$current = libxml_use_internal_errors(true);
154+
$internalErrors = libxml_use_internal_errors(true);
155155
$disableEntities = libxml_disable_entity_loader(true);
156156

157157
$dom = new \DOMDocument('1.0', $charset);
@@ -171,9 +171,11 @@ public function addHtmlContent($content, $charset = 'UTF-8')
171171
}
172172
}
173173

174-
@$dom->loadHTML($content);
174+
if ('' !== trim($content)) {
175+
@$dom->loadHTML($content);
176+
}
175177

176-
libxml_use_internal_errors($current);
178+
libxml_use_internal_errors($internalErrors);
177179
libxml_disable_entity_loader($disableEntities);
178180

179181
$this->addDocument($dom);
@@ -215,14 +217,18 @@ public function addXmlContent($content, $charset = 'UTF-8')
215217
$content = str_replace('xmlns', 'ns', $content);
216218
}
217219

218-
$current = libxml_use_internal_errors(true);
220+
$internalErrors = libxml_use_internal_errors(true);
219221
$disableEntities = libxml_disable_entity_loader(true);
220222

221223
$dom = new \DOMDocument('1.0', $charset);
222224
$dom->validateOnParse = true;
223-
@$dom->loadXML($content, LIBXML_NONET);
224225

225-
libxml_use_internal_errors($current);
226+
if ('' !== trim($content)) {
227+
// remove the default namespace to make XPath expressions simpler
228+
@$dom->loadXML(str_replace('xmlns', 'ns', $content), LIBXML_NONET);
229+
}
230+
231+
libxml_use_internal_errors($internalErrors);
226232
libxml_disable_entity_loader($disableEntities);
227233

228234
$this->addDocument($dom);

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,13 @@ public function getFiles()
143143
*/
144144
public function getPhpValues()
145145
{
146-
$qs = http_build_query($this->getValues(), '', '&');
147-
parse_str($qs, $values);
146+
$values = array();
147+
foreach ($this->getValues() as $name => $value) {
148+
$qs = http_build_query(array($name => $value), '', '&');
149+
parse_str($qs, $expandedValue);
150+
$varName = substr($name, 0, strlen(key($expandedValue)));
151+
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
152+
}
148153

149154
return $values;
150155
}
@@ -161,8 +166,13 @@ public function getPhpValues()
161166
*/
162167
public function getPhpFiles()
163168
{
164-
$qs = http_build_query($this->getFiles(), '', '&');
165-
parse_str($qs, $values);
169+
$values = array();
170+
foreach ($this->getFiles() as $name => $value) {
171+
$qs = http_build_query(array($name => $value), '', '&');
172+
parse_str($qs, $expandedValue);
173+
$varName = substr($name, 0, strlen(key($expandedValue)));
174+
$values = array_replace_recursive($values, array($varName => current($expandedValue)));
175+
}
166176

167177
return $values;
168178
}
@@ -414,8 +424,7 @@ private function initialize()
414424

415425
// restore the original name of the input node
416426
$this->button->setAttribute('name', $name);
417-
}
418-
else {
427+
} else {
419428
$this->set(new Field\InputFormField($document->importNode($this->button, true)));
420429
}
421430
}

src/Symfony/Component/DomCrawler/Tests/CrawlerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testAddHtmlContentCharsetGbk()
130130
*/
131131
public function testAddHtmlContentWithErrors()
132132
{
133-
libxml_use_internal_errors(true);
133+
$internalErrors = libxml_use_internal_errors(true);
134134

135135
$crawler = new Crawler();
136136
$crawler->addHtmlContent(<<<EOF
@@ -150,7 +150,7 @@ public function testAddHtmlContentWithErrors()
150150
$this->assertEquals("Tag nav invalid\n", $errors[0]->message);
151151

152152
libxml_clear_errors();
153-
libxml_use_internal_errors(false);
153+
libxml_use_internal_errors($internalErrors);
154154
}
155155

156156
/**
@@ -180,7 +180,7 @@ public function testAddXmlContentCharset()
180180
*/
181181
public function testAddXmlContentWithErrors()
182182
{
183-
libxml_use_internal_errors(true);
183+
$internalErrors = libxml_use_internal_errors(true);
184184

185185
$crawler = new Crawler();
186186
$crawler->addXmlContent(<<<EOF
@@ -198,7 +198,7 @@ public function testAddXmlContentWithErrors()
198198
$this->assertTrue(count(libxml_get_errors()) > 1);
199199

200200
libxml_clear_errors();
201-
libxml_use_internal_errors(false);
201+
libxml_use_internal_errors($internalErrors);
202202
}
203203

204204
/**

0 commit comments

Comments
 (0)