8000 Merge branch '2.0' into 2.1 · symfony/symfony@8321127 · GitHub
[go: up one dir, main page]

Skip to content

Commit 8321127

Browse files
committed
Merge branch '2.0' into 2.1
* 2.0: [Bundle] [FrameworkBundle] fixed indentation in esi.xml services file. [TwigBundle] There is no CSS visibility of display, should be visible instead [DependencyInjection] fixed a bug where the strict flag on references were lost (closes #6607) [HttpFoundation] Check if required shell functions for `FileBinaryMimeTypeGuesser` are not disabled [CssSelector] added css selector with empty string [HttpFoundation] Docblock for Request::isXmlHttpRequest() now points to Wikipedia [DependencyInjection] refactored code to avoid logic duplication Conflicts: src/Symfony/Bundle/FrameworkBundle/Resources/config/esi.xml src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php
2 parents 1949ce0 + 835c1b8 commit 8321127

File tree

10 files changed

+56
-46
lines changed

10 files changed

+56
-46
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
<service id="esi" class="%esi.class%" />
1414

1515
<service id="esi_listener" class="%esi_listener.class%">
16-
<tag name="kernel.event_subscriber" />
17-
<argument type="service" id="esi" on-invalid="ignore" />
16+
<tag name="kernel.event_subscriber" />
17+
<argument type="service" id="esi" on-invalid="ignore" />
1818
</service>
1919
</services>
2020
</container>

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/trace.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
in {{ trace.file|format_file(trace.line) }}&nbsp;
1313
{% spaceless %}
1414
<a href="#" onclick="toggle('trace_{{ prefix ~ '_' ~ i }}'); switchIcons('icon_{{ prefix ~ '_' ~ i }}_open', 'icon_{{ prefix ~ '_' ~ i }}_close'); return false;">
15-
<img class="toggle" id="icon_{{ prefix ~ '_' ~ i }}_close" alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="visibility: {{ 0 == i ? 'display' : 'hidden' }}" />
16-
<img class="toggle" id="icon_{{ prefix ~ '_' ~ i }}_open" alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="visibility: {{ 0 == i ? 'hidden' : 'display' }}; margin-left: -18px" />
15+
<img class="toggle" id="icon_{{ prefix ~ '_' ~ i }}_close" alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="visibility: {{ 0 == i ? 'visible' : 'hidden' }}" />
16+
<img class="toggle" id="icon_{{ prefix ~ '_' ~ i }}_open" alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="visibility: {{ 0 == i ? 'hidden' : 'visible' }}; margin-left: -18px" />
1717
</a>
1818
{% endspaceless %}
1919
<div id="trace_{{ prefix ~ '_' ~ i }}" style="display: {{ 0 == i ? 'block' : 'none' }}" class="trace">

src/Symfony/Bundle/TwigBundle/Resources/views/Exception/traces.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
{{ exception.class|abbr_class }}: {{ exception.message|nl2br|format_file_from_text }}&nbsp;
66
{% spaceless %}
77
<a href="#" onclick="toggle('traces_{{ position }}', 'traces'); switchIcons('icon_traces_{{ position }}_open', 'icon_traces_{{ position }}_close'); return false;">
8-
<img class="toggle" id="icon_traces_{{ position }}_close" alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="visibility: {{ 0 == count ? 'display' : 'hidden' }}" />
9-
<img class="toggle" id="icon_traces_{{ position }}_open" alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="visibility: {{ 0 == count ? 'hidden' : 'display' }}; margin-left: -18px" />
8+
<img class="toggle" id="icon_traces_{{ position }}_close" alt="-" src="{{ asset('bundles/framework/images/blue_picto_less.gif') }}" style="visibility: {{ 0 == count ? 'visible' : 'hidden' }}" />
9+
<img class="toggle" id="icon_traces_{{ position }}_open" alt="+" src="{{ asset('bundles/framework/images/blue_picto_more.gif') }}" style="visibility: {{ 0 == count ? 'hidden' : 'visible' }}; margin-left: -18px" />
1010
</a>
1111
{% endspaceless %}
1212
</h2>

src/Symfony/Component/CssSelector/Tests/TokenizerTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public function testTokenizeWithQuotedStrings()
3434
{
3535
$this->assertEquals('foo[class=foo bar ]', $this->tokensToString($this->tokenizer->tokenize('foo[class="foo bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
3636
$this->assertEquals("foo[class=foo Abar ]", $this->tokensToString($this->tokenizer->tokenize('foo[class="foo \\65 bar"]')), '->tokenize() lexes an input string and returns an array of tokens');
37+
$this->assertEquals("img[alt= ]", $this->tokensToString($this->tokenizer->tokenize('img[alt=""]')), '->tokenize() lexes an input string and returns an array of tokens');
3738
}
3839

3940
/**

src/Symfony/Component/CssSelector/Tokenizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function tokenizeEscapedString($s, $pos)
129129
}
130130

131131
$result = substr($s, $start, $next - $start);
132-
if ('\\' === $result[strlen($result) - 1]) {
132+
if (strlen($result) > 0 && '\\' === $result[strlen($result) - 1]) {
133133
// next quote character is escaped
134134
$pos = $next + 1;
135135
continue;

src/Symfony/Component/DependencyInjection/Compiler/ResolveInvalidReferencesPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private function processArguments(array $arguments, $inMethodCall = false)
8989

9090
// resolve invalid behavior
9191
if ($exists && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $invalidBehavior) {
92-
$arguments[$k] = new Reference($id);
92+
$arguments[$k] = new Reference($id, ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE, $argument->isStrict());
9393
} elseif (!$exists && ContainerInterface::NULL_ON_INVALID_REFERENCE === $invalidBehavior) {
9494
$arguments[$k] = null;
9595
} elseif (!$exists && ContainerInterface::IGNORE_ON_INVALID_REFERENCE === $invalidBehavior) {

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

Lines changed: 30 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -229,24 +229,7 @@ private function addServiceInlinedDefinitions($id, $definition)
229229
throw new ServiceCircularReferenceException($id, array($id));
230230
}
231231

232-
$arguments = array();
233-
foreach ($sDefinition->getArguments() as $argument) {
234-
$arguments[] = $this->dumpValue($argument);
235-
}
236-
237-
if (null !== $sDefinition->getFactoryMethod()) {
238-
if (null !== $sDefinition->getFactoryClass()) {
239-
$code .= sprintf(" \$%s = call_user_func(array(%s, '%s')%s);\n", $name, $this->dumpValue($sDefinition->getFactoryClass()), $sDefinition->getFactoryMethod(), count($arguments) > 0 ? ', '.implode(', ', $arguments) : '');
240-
} elseif (null !== $sDefinition->getFactoryService()) {
241-
$code .= sprintf(" \$%s = %s->%s(%s);\n", $name, $this->getServiceCall($sDefinition->getFactoryService()), $sDefinition->getFactoryMethod(), implode(', ', $arguments));
242-
} else {
243-
throw new RuntimeException('Factory service or factory class must be defined in service definition for '.$id);
244-
}
245-
} elseif (false !== strpos($class, '$')) {
246-
$code .= sprintf(" \$class = %s;\n \$%s = new \$class(%s);\n", $class, $name, implode(', ', $arguments));
247-
} else {
248-
$code .= sprintf(" \$%s = new \\%s(%s);\n", $name, substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
249-
}
232+
$code .= $this->addNewInstance($id, $sDefinition, '$'.$name, ' = ');
250233

251234
if (!$this->hasReference($id, $sDefinition->getMethodCalls(), true) && !$this->hasReference($id, $sDefinition->getProperties(), true)) {
252235
$code .= $this->addServiceMethodCalls(null, $sDefinition, $name);
@@ -297,11 +280,6 @@ private function addServiceInstance($id, $definition)
297280
throw new InvalidArgumentException(sprintf('"%s" is not a valid class name for the "%s" service.', $class, $id));
298281
}
299282

300-
$arguments = array();
301-
foreach ($definition->getArguments() as $value) {
302-
$arguments[] = $this->dumpValue($value);
303-
}
304-
305283
$simple = $this->isSimpleInstance($id, $definition);
306284

307285
$instantiation = '';
@@ -320,19 +298,7 @@ private function addServiceInstance($id, $definition)
320298
$instantiation .= ' = ';
321299
}
322300

323-
if (null !== $definition->getFactoryMethod()) {
324-
if (null !== $definition->getFactoryClass()) {
325-
$code = sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : '');
326-
} elseif (null !== $definition->getFactoryService()) {
327-
$code = sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments));
328-
} else {
329-
throw new RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id);
330-
}
331-
} elseif (false !== strpos($class, '$')) {
332-
$code = sprintf(" \$class = %s;\n\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
333-
} else {
334-
$code = sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
335-
}
301+
$code = $this->addNewInstance($id, $definition, $return, $instantiation);
336302

337303
if (!$simple) {
338304
$code .= "\n";
@@ -611,6 +577,34 @@ private function addServices()
611577
return $publicServices.$aliasServices.$privateServices;
612578
}
613579

580+
private function addNewInstance($id, Definition $definition, $return, $instantiation)
581+
{
582+
$class = $this->dumpValue($definition->getClass());
583+
584+
$arguments = array();
585+
foreach ($definition->getArguments() as $value) {
586+
$arguments[] = $this->dumpValue($value);
587+
}
588+
589+
if (null !== $definition->getFactoryMethod()) {
590+
if (null !== $definition->getFactoryClass()) {
591+
return sprintf(" $return{$instantiation}call_user_func(array(%s, '%s')%s);\n", $this->dumpValue($definition->getFactoryClass()), $definition->getFactoryMethod(), $arguments ? ', '.implode(', ', $arguments) : '');
592+
}
593+
594+
if (null !== $definition->getFactoryService()) {
595+
return sprintf(" $return{$instantiation}%s->%s(%s);\n", $this->getServiceCall($definition->getFactoryService()), $definition->getFactoryMethod(), implode(', ', $arguments));
596+
}
597+
598+
throw new RuntimeException('Factory method requires a factory service or factory class in service definition for '.$id);
599+
}
600+
601+
if (false !== strpos($class, '$')) {
602+
return sprintf(" \$class = %s;\n\n $return{$instantiation}new \$class(%s);\n", $class, implode(', ', $arguments));
603+
}
604+
605+
return sprintf(" $return{$instantiation}new \\%s(%s);\n", substr(str_replace('\\\\', '\\', $class), 1, -1), implode(', ', $arguments));
606+
}
607+
614608
/**
615609
* Adds the class headers.
616610
*

src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveInvalidReferencesPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ public function testProcessRemovesPropertiesOnInvalid()
6161
$this->assertEquals(array(), $def->getProperties());
6262
}
6363

64+
public function testStrictFlagIsPreserved()
65+
{
66+
$container = new ContainerBuilder();
67+
$container->register('bar');
68+
$def = $container
69+
->register('foo')
70+
->addArgument(new Reference('bar', ContainerInterface::NULL_ON_INVALID_REFERENCE, false))
71+
;
72+
73+
$this->process($container);
74+
75+
$this->assertFalse($def->getArgument(0)->isStrict());
76+
}
77+
6478
protected function process(ContainerBuilder $container)
6579
{
6680
$pass = new ResolveInvalidReferencesPass();

src/Symfony/Component/HttpFoundation/File/MimeType/FileBinaryMimeTypeGuesser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function __construct($cmd = 'file -b --mime %s 2>/dev/null')
4545
*/
4646
public static function isSupported()
4747
{
48-
return !defined('PHP_WINDOWS_VERSION_BUILD');
48+
return !defined('PHP_WINDOWS_VERSION_BUILD') && function_exists('passthru') && function_exists('escapeshellarg');
4949
}
5050

5151
/**

src/Symfony/Component/HttpFoundation/Request.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,8 @@ public function getAcceptableContentTypes()
13581358
* Returns true if the request is a XMLHttpRequest.
13591359
*
13601360
* It works if your JavaScript library set an X-Requested-With HTTP header.
1361-
* It is known to work with Prototype, Mootools, jQuery.
1361+
* It is known to work with common JavaScript frameworks:
1362+
* @link http://en.wikipedia.org/wiki/List_of_Ajax_frameworks#JavaScript
13621363
*
13631364
* @return Boolean true if the request is an XMLHttpRequest, false otherwise
13641365
*

0 commit comments

Comments
 (0)
0