8000 Merge branch '3.4' · symfony/symfony@3041b4c · GitHub
[go: up one dir, main page]

Skip to content

Commit 3041b4c

Browse files
committed
Merge branch '3.4'
* 3.4: Misspelled word Display a better error design when the toolbar cannot be displayed fixed CS do not validate empty values [Cache] fix cleanup of expired items for PdoAdapter [Dotenv] clean up before running assertions [Console] fix description of INF default values parse escaped quotes in unquoted env var values [PropertyAccess] Fix TypeError discard [Validator] Throw exception on Comparison constraints null options [FrameworkBundle] Display a proper warning on cache:clear without the --no-warmup option [Security] Fix Firewall ExceptionListener priority Allow * to bind all interfaces (as INADDR_ANY) Identify tty tests in Component/Process [Workflow] Added more events to the announce function [Validator] Remove property path suggestion for using the Expression validator [WebProfilerBundle] Fix css trick used for offsetting html anchor from fixed header disable unusable fragment renderers [Stopwatch] Add a reset method [Security] Fix annotation
2 parents b12f215 + 886df99 commit 3041b4c

File tree

57 files changed

+373
-44
lines changed

Some content is hidden

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

57 files changed

+373
-44
lines changed

src/Symfony/Bridge/Doctrine/Validator/Constraints/UniqueEntityValidator.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public function validate($entity, Constraint $constraint)
6363
throw new ConstraintDefinitionException('At least one field has to be specified.');
6464
}
6565

66+
if (null === $entity) {
67+
return;
68+
}
69+
6670
if ($constraint->em) {
6771
$em = $this->registry->getManager($constraint->em);
6872

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@ private function registerFormConfiguration($config, ContainerBuilder $container,
331331
private function registerEsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
332332
{
333333
if (!$this->isConfigEnabled($container, $config)) {
334+
$container->removeDefinition('fragment.renderer.esi');
335+
334336
return;
335337
}
336338

@@ -347,6 +349,8 @@ private function registerEsiConfiguration(array $config, ContainerBuilder $conta
347349
private function registerSsiConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
348350
{
349351
if (!$this->isConfigEnabled($container, $config)) {
352+
$container->removeDefinition('fragment.renderer.ssi');
353+
350354
return;
351355
}
352356

@@ -363,6 +367,8 @@ private function registerSsiConfiguration(array $config, ContainerBuilder $conta
363367
private function registerFragmentsConfiguration(array $config, ContainerBuilder $container, XmlFileLoader $loader)
364368
{
365369
if (!$this->isConfigEnabled($container, $config)) {
370+
$container->removeDefinition('fragment.renderer.hinclude');
371+
366372
return;
367373
}
368374

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'fragments' => array(
5+
'enabled' => false,
6+
),
7+
'esi' => array(
8+
'enabled' => true,
9+
),
10+
'ssi' => array(
11+
'enabled' => true,
12+
),
13+
));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'esi' => array(
5+
'enabled' => false,
6+
),
7+
));
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?php
2+
3+
$container->loadFromExtension('framework', array(
4+
'ssi' => array(
5+
'enabled' => false,
6+
),
7+
));
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:fragments enabled="false" />
10+
<framework:esi enabled="true" />
11+
<framework:ssi enabled="true" />
12+
</framework:config>
13+
</container>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:esi enabled="false" />
10+
</framework:config>
11+
</container>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" ?>
2+
<container xmlns="http://symfony.com/schema/dic/services"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xmlns:framework="http://symfony.com/schema/dic/symfony"
5+
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd
6+
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd">
7+
8+
<framework:config>
9+
<framework:ssi enabled="false" />
10+
</framework:config>
11+
</container>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
framework:
2+
fragments:
3+
enabled: false
4+
esi:
5+
enabled: true
6+
ssi:
7+
enabled: true
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
esi:
3+
enabled: false
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
framework:
2+
ssi:
3+
enabled: false

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,38 @@ public function testEsi()
132132
$container = $this->createContainerFromFile('full');
133133

134134
$this->assertTrue($container->hasDefinition('esi'), '->registerEsiConfiguration() loads esi.xml');
135+
$this->assertTrue($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is registered');
136+
}
137+
138+
public function testEsiDisabled()
139+
{
140+
$container = $this->createContainerFromFile('esi_disabled');
141+
142+
$this->assertFalse($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is not registered');
135143
}
136144

137145
public function testSsi()
138146
{
139147
$container = $this->createContainerFromFile('full');
140148

141149
$this->assertTrue($container->hasDefinition('ssi'), '->registerSsiConfiguration() loads ssi.xml');
150+
$this->assertTrue($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is registered');
151+
}
152+
153+
public function testSsiDisabled()
154+
{
155+
$container = $this->createContainerFromFile('ssi_disabled');
156+
157+
$this->assertFalse($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is not registered');
158+
}
159+
160+
public function testEsiAndSsiWithoutFragments()
161+
{
162+
$container = $this->createContainerFromFile('esi_and_ssi_without_fragments');
163+
164+
$this->assertFalse($container->hasDefinition('fragment.renderer.hinclude'), 'The HInclude fragment renderer is not registered');
165+
$this->assertTrue($container->hasDefinition('fragment.renderer.esi'), 'The ESI fragment renderer is registered');
166+
$this->assertTrue($container->hasDefinition('fragment.renderer.ssi'), 'The SSI fragment renderer is registered');
142167
}
143168

144169
public function testEnabledProfiler()

src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,7 @@ public function process(ContainerBuilder $container)
6161
$container->getDefinition('twig.extension.httpkernel')->addTag('twig.extension');
6262

6363
// inject Twig in the hinclude service if Twig is the only registered templating engine
64-
if (
65-
!$container->hasParameter('templating.engines')
66-
|| array('twig') == $container->getParameter('templating.engines')
67-
) {
64+
if ((!$container->hasParameter('templating.engines') || array('twig') == $container->getParameter('templating.engines')) && $container->hasDefinition('fragment.renderer.hinclude')) {
6865
$container->getDefinition('fragment.renderer.hinclude')
6966
->addTag('kernel.fragment_renderer', array('alias' => 'hinclude'))
7067
->replaceArgument(0, new Reference('twig'))

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/open.css.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ a.doc:hover {
6464

6565
.anchor {
6666
position: relative;
67-
padding-top: 7em;
68-
margin-top: -7em;
67+
display: block;
68+
top: -7em;
6969
visibility: hidden;
7070
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar.css.twig

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,3 +540,33 @@
540540
display: none;
541541
}
542542
}
543+
544+
/***** Error Toolbar *****/
545+
.sf-error-toolbar .sf-toolbarreset {
546+
background: #222;
547+
color: #f5f5f5;
548+
font: 13px/36px Arial, sans-serif;
549+
height: 36px;
550+
padding: 0 15px;
551+
text-align: left;
552+
}
553+
554+
.sf-error-toolbar .sf-toolbarreset svg {
555+
height: auto;
556+
}
557+
558+
.sf-error-toolbar .sf-toolbarreset a {
559+
color: #99cdd8;
560+
margin-left: 5px;
561+
text-decoration: underline;
562+
}
563+
564+
.sf-error-toolbar .sf-toolbarreset a:hover {
565+
text-decoration: none;
566+
}
567+
568+
.sf-error-toolbar .sf-toolbarreset .sf-toolbar-icon {
569+
float: left;
570+
padding: 5px 0;
571+
margin-right: 10px;
572+
}

src/Symfony/Bundle/WebProfilerBundle/Resources/views/Profiler/toolbar_js.html.twig

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,15 @@
100100
});
101101
},
102102
function(xhr) {
103-
var errorToolbarHtml = '
104-
<style>
105-
.sfErrorToolbar { background: #222; bottom: 0; color: #f5f5f5; font: 13px/36px Arial, sans-serif; height: 36px; padding: 0 15px; position: fixed; width: 100%; }
106-
.sfErrorToolbar a { color: #99cdd8; margin-left: 5px; text-decoration: underline; }
107-
.sfErrorToolbar a:hover { text-decoration: none; }
108-
</style>
109-
<div class="sfErrorToolbar">An error occurred while loading the web debug toolbar. <a href="{{ path("_profiler", { "token": token }) }}">Open the web profiler.</a></div>
110-
';
111-
112103
if (xhr.status !== 0) {
113-
window.document.body.insertAdjacentHTML('beforeend', errorToolbarHtml);
104+
var sfwdt = document.getElementById('sfwdt{{ token }}');
105+
sfwdt.innerHTML = '\
106+
<div class="sf-toolbarreset">\
107+
<div class="sf-toolbar-icon"><svg width="26" height="28" xmlns="http://www.w3.org/2000/svg" version="1.1" x="0px" y="0px" viewBox="0 0 26 28" enable-background="new 0 0 26 28" xml:space="preserve"><path fill="#FFFFFF" d="M13 0C5.8 0 0 5.8 0 13c0 7.2 5.8 13 13 13c7.2 0 13-5.8 13-13C26 5.8 20.2 0 13 0z M20 7.5 c-0.6 0-1-0.3-1-0.9c0-0.2 0-0.4 0.2-0.6c0.1-0.3 0.2-0.3 0.2-0.4c0-0.3-0.5-0.4-0.7-0.4c-2 0.1-2.5 2.7-2.9 4.8l-0.2 1.1 c1.1 0.2 1.9 0 2.4-0.3c0.6-0.4-0.2-0.8-0.1-1.3C18 9.2 18.4 9 18.7 8.9c0.5 0 0.8 0.5 0.8 1c0 0.8-1.1 2-3.3 1.9 c-0.3 0-0.5 0-0.7-0.1L15 14.1c-0.4 1.7-0.9 4.1-2.6 6.2c-1.5 1.8-3.1 2.1-3.8 2.1c-1.3 0-2.1-0.6-2.2-1.6c0-0.9 0.8-1.4 1.3-1.4 c0.7 0 1.2 0.5 1.2 1.1c0 0.5-0.2 0.6-0.4 0.7c-0.1 0.1-0.3 0.2-0.3 0.4c0 0.1 0.1 0.3 0.4 0.3c0.5 0 0.9-0.3 1.2-0.5 c1.3-1 1.7-2.9 2.4-6.2l0.1-0.8c0.2-1.1 0.5-2.3 0.8-3.5c-0.9-0.7-1.4-1.5-2.6-1.8c-0.8-0.2-1.3 0-1.7 0.4C8.4 10 8.6 10.7 9 11.1 l0.7 0.7c0.8 0.9 1.3 1.7 1.1 2.7c-0.3 1.6-2.1 2.8-4.3 2.1c-1.9-0.6-2.2-1.9-2-2.7c0.2-0.6 0.7-0.8 1.2-0.6 c0.5 0.2 0.7 0.8 0.6 1.3c0 0.1 0 0.1-0.1 0.3C6 15 5.9 15.2 5.9 15.3c-0.1 0.4 0.4 0.7 0.8 0.8c0.8 0.3 1.7-0.2 1.9-0.9 c0.2-0.6-0.2-1.1-0.4-1.2l-0.8-0.9c-0.4-0.4-1.2-1.5-0.8-2.8c0.2-0.5 0.5-1 0.9-1.4c1-0.7 2-0.8 3-0.6c1.3 0.4 1.9 1.2 2.8 1.9 c0.5-1.3 1.1-2.6 2-3.8c0.9-1 2-1.7 3.3-1.8C20 4.8 21 5.4 21 6.3C21 6.7 20.8 7.5 20 7.5z"/></svg></div>\
108+
An error occurred while loading the web debug toolbar. <a href="{{ path("_profiler", { "token": token }) }}">Open the web profiler.</a>\
109+
</div>\
110+
';
111+
sfwdt.setAttribute('class', 'sf-toolbar sf-error-toolbar');
114112
}
115113
},
116114
{ maxTries: 5 }

src/Symfony/Bundle/WebServerBundle/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
3.4.0
5+
-----
6+
7+
* WebServer can now use '*' as a wildcard to bind to 0.0.0.0 (INADDR_ANY)
8+
49
3.3.0
510
-----
611

src/Symfony/Bundle/WebServerBundle/WebServerConfig.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function __construct($documentRoot, $env, $address = null, $router = null
5454
$this->port = $this->findBestPort();
5555
} elseif (false !== $pos = strrpos($address, ':')) {
5656
$this->hostname = substr($address, 0, $pos);
57+
if ('*' === $this->hostname) {
58+
$this->hostname = '0.0.0.0';
59+
}
5760
$this->port = substr($address, $pos + 1);
5861
} elseif (ctype_digit($address)) {
5962
$this->hostname = '127.0.0.1';

src/Symfony/Component/Cache/Tests/Adapter/PdoAdapterTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,30 @@ public function createCachePool($defaultLifetime = 0)
4141
{
4242
return new PdoAdapter('sqlite:'.self::$dbFile, 'ns', $defaultLifetime);
4343
}
44+
45+
public function testCleanupExpiredItems()
46+
{
47+
$pdo = new \PDO('sqlite:'.self::$dbFile);
48+
49+
$getCacheItemCount = function () use ($pdo) {
50+
return (int) $pdo->query('SELECT COUNT(*) FROM cache_items')->fetch(\PDO::FETCH_COLUMN);
51+
};
52+
53+
$this->assertSame(0, $getCacheItemCount());
54+
55+
$cache = $this->createCachePool();
56+
57+
$item = $cache->getItem('some_nice_key');
58+
$item->expiresAfter(1);
59+
$item->set(1);
60+
61+
$cache->save($item);
62+
$this->assertSame(1, $getCacheItemCount());
63+
64+
sleep(2);
65+
66+
$newItem = $cache->getItem($item->getKey());
67+
$this->assertFalse($newItem->isHit());
68+
$this->assertSame(0, $getCacheItemCount(), 'PDOAdapter must clean up expired items');
69+
}
4470
}

src/Symfony/Component/Cache/Traits/PdoTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ protected function doFetch(array $ids)
170170
foreach ($expired as $id) {
171171
$stmt->bindValue(++$i, $id);
172172
}
173-
$stmt->execute($expired);
173+
$stmt->execute();
174174
}
175175
}
176176

src/Symfony/Component/Console/Descriptor/JsonDescriptor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ private function getInputArgumentData(InputArgument $argument)
115115
'is_required' => $argument->isRequired(),
116116
'is_array' => $argument->isArray(),
117117
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
118-
'default' => $argument->getDefault(),
118+
'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
119119
);
120120
}
121121

@@ -133,7 +133,7 @@ private function getInputOptionData(InputOption $option)
133133
'is_value_required' => $option->isValueRequired(),
134134
'is_multiple' => $option->isArray(),
135135
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
136-
'default' => $option->getDefault(),
136+
'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
137137
);
138138
}
139139

src/Symfony/Component/Console/Descriptor/TextDescriptor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,10 @@ private function getCommandAliasesText($command)
278278
*/
279279
private function formatDefaultValue($default)
280280
{
281+
if (INF === $default) {
282+
return 'INF';
283+
}
284+
281285
if (is_string($default)) {
282286
$default = OutputFormatter::escape($default);
283287
} elseif (is_array($default)) {

src/Symfony/Component/Console/Tests/Descriptor/ObjectsProvider.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public static function getInputArguments()
3232
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
3333
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
3434
'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', '<comment>style</>'),
35+
'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF),
3536
);
3637
}
3738

@@ -46,6 +47,7 @@ public static function getInputOptions()
4647
'input_option_6' => new InputOption('option_name', array('o', 'O'), InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
4748
'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', '<comment>style</>'),
4849
'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', array('<comment>Hello</comment>', '<info>world</info>')),
50+
'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF),
4951
);
5052
}
5153

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"name": "argument_name",
3+
"is_required": false,
4+
"is_array": false,
5+
"description": "argument description",
6+
"default": "INF"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**argument_name:**
2+
3+
* Name: argument_name
4+
* Is required: no
5+
* Is array: no
6+
* Description: argument description
7+
* Default: `INF`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<info>argument_name</info> argument description<comment> [default: INF]</comment>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<argument name="argument_name" is_required="0" is_array="0">
3+
<description>argument description</description>
4+
<defaults>
5+
<default>INF</default>
6+
</defaults>
7+
</argument>
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "--option_name",
3+
"shortcut": "-o",
4+
"accept_value": true,
5+
"is_value_required": false,
6+
"is_multiple": false,
7+
"description": "option description",
8+
"default": "INF"
9+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
**option_name:**
2+
3+
* Name: `--option_name`
4+
* Shortcut: `-o`
5+
* Accept value: yes
6+
* Is value required: no
7+
* Is multiple: no
8+
* Description: option description
9+
* Default: `INF`
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> [default: INF]</comment>

0 commit comments

Comments
 (0)
0