8000 Merge branch '2.8' into 3.2 · symfony/symfony@80b114e · GitHub
[go: up one dir, main page]

Skip to content

Commit 80b114e

Browse files
committed
Merge branch '2.8' into 3.2
* 2.8: (40 commits) Show exception is checked twice in ExceptionController of twig allow SSI fragments configuration in XML fi 10000 les Display a better error message when the toolbar cannot be displayed render hidden _method field in form_rest() return fallback locales whenever possible [Console] Fix catching exception type in QuestionHelper [WebProfilerBundle] Eliminate line wrap on count columnt (routing) [Routing] Fix XmlFileLoader exception message [Translation] Fix FileLoader::loadResource() php doc Sessions: configurable "use_strict_mode" option for NativeSessionStorage [FrameworkBundle] [Command] Clean bundle directory, fixes #23177 Reset redirectCount when throwing exception [TwigBundle] Remove template.xml services when templating is disabled add content-type header on exception response Embedding a response that combines expiration and validation, that should not defeat expiration on the combined response Fix two edge cases in ResponseCacheStrategy [Routing] Expose request in route conditions, if needed and possible [Routing] Expose request in route conditions, if needed and possible [Translation][FrameworkBundle] Fix resource loading order inconsistency reported in #23034 [Filesystem] added workaround in Filesystem::rename for PHP bug ...
2 parents 5d3e776 + b4aa027 commit 80b114e

File tree

48 files changed

+449
-76
lines changed

Some content is hidden

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

48 files changed

+449
-76
lines changed

CONTRIBUTORS.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ Symfony is the result of the work of many people who made the code better
2020
- Javier Eguiluz (javier.eguiluz)
2121
- Hugo Hamon (hhamon)
2222
- Abdellatif Ait boudad (aitboudad)
23+
- Romain Neutron (romain)
2324
- Pascal Borreli (pborreli)
2425
- Wouter De Jong (wouterj)
25-
- Romain Neutron (romain)
26-
- Grégoire Pineau (lyrixx)
2726
- Robin Chalas (chalas_r)
28-
- Joseph Bielawski (stloyd)
2927
- Maxime Steinhausser (ogizanagi)
28+
- Grégoire Pineau (lyrixx)
29+
- Joseph Bielawski (stloyd)
3030
- Karma Dordrak (drak)
3131
- Lukas Kahwe Smith (lsmith)
3232
- Martin Hasoň (hason)
@@ -72,8 +72,8 @@ Symfony is the result of the work of many people who made the code better
7272
- Dariusz Górecki (canni)
7373
- Titouan Galopin (tgalopin)
7474
- Douglas Greenshields (shieldo)
75-
- Konstantin Myakshin (koc)
7675
- Jáchym Toušek (enumag)
76+
- Konstantin Myakshin (koc)
7777
- Lee McDermott
7878
- Brandon Turner
7979
- Luis Cordova (cordoval)
@@ -112,10 +112,10 @@ Symfony is the result of the work of many people who made the code better
112112
- Jacob Dreesen (jdreesen)
113113
- Tobias Nyholm (tobias)
114114
- Tomáš Votruba (tomas_votruba)
115+
- Yonel Ceruto González (yonelceruto)
115116
- Fabien Pennequin (fabienpennequin)
116117
- Gordon Franke (gimler)
117118
- Eric GELOEN (gelo)
118-
- Yonel Ceruto González (yonelceruto)
119119
- Daniel Wehner (dawehner)
120120
- Tugdual Saunier (tucksaun)
121121
- Théo FIDRY (theofidry)
@@ -130,6 +130,7 @@ Symfony is the result of the work of many people who made the code better
130130
- Daniel Gomes (danielcsgomes)
131131
- Hidenori Goto (hidenorigoto)
132132
- Guilherme Blanco (guilhermeblanco)
133+
- Vincent AUBERT (vincent)
133134
- Pablo Godel (pgodel)
134135
- Jérémie Augustin (jaugustin)
135136
- Andréia Bohner (andreia)
@@ -140,18 +141,17 @@ Symfony is the result of the work of many people who made the code better
140141
- Joel Wurtz (brouznouf)
141142
- Philipp Wahala (hifi)
142143
- Vyacheslav Pavlov
144+
- Richard van Laak (rvanlaak)
143145
- Javier Spagnoletti (phansys)
144146
- Richard Shank (iampersistent)
145147
- Thomas Rabaix (rande)
146-
- Vincent AUBERT (vincent)
147148
- Rouven Weßling (realityking)
148149
- Teoh Han Hui (teohhanhui)
149150
- Jérôme Vasseur (jvasseur)
150151
- Clemens Tolboom
151152
- Helmer Aaviksoo
152153
- Grégoire Paris (greg0ire)
153154
- Hiromi Hishida (77web)
154-
- Richard van Laak (rvanlaak)
155155
- Matthieu Ouellette-Vachon (maoueh)
156156
- Michał Pipa (michal.pipa)
157157
- Amal Raghav (kertz)
@@ -244,6 +244,7 @@ Symfony is the result of the work of many people who made the code better
244244
- Uwe Jäger (uwej711)
245245
- Eugene Leonovich (rybakit)
246246
- Filippo Tessarotto
247+
- Oleg Voronkovich
247248
- Joseph Rouff (rouffj)
248249
- Félix Labrecque (woodspire)
249250
- GordonsLondon
@@ -279,7 +280,6 @@ Symfony is the result of the work of many people who made the code better
279280
- Jordan Samouh (jordansamouh)
280281
- Chris Smith (cs278)
281282
- Florian Klein (docteurklein)
282-
- Oleg Voronkovich
283283
- Manuel Kiessling (manuelkiessling)
284284
- Atsuhiro KUBO (iteman)
285285
- Andrew Moore (finewolf)
@@ -389,6 +389,7 @@ Symfony is the result of the work of many people who made the code better
389389
- Emanuele Gaspari (inmarelibero)
390390
- Sébastien Santoro (dereckson)
391391
- Brian King
392+
- Frank de Jonge (frenkynet)
392393
- Michel Salib (michelsalib)
393394
- geoffrey
394395
- Steffen Roßkamp
@@ -525,7 +526,6 @@ Symfony is the result of the work of many people who made the code better
525526
- Romain Pierre (romain-pierre)
526527
- Jan Behrens
527528
- Mantas Var (mvar)
528-
- Frank de Jonge (frenkynet)
529529
- Sebastian Krebs
530530
- Jean-Christophe Cuvelier [Artack]
531531
- Christopher Davis (chrisguitarguy)
@@ -1280,6 +1280,7 @@ Symfony is the result of the work of many people who made the code better
12801280
- ged15
12811281
- Daan van Renterghem
12821282
- Nicole Cordes
1283+
- Martin Kirilov
12831284
- Bram Van der Sype (brammm)
12841285
- Christopher Hertel (chertel)
12851286
- Guile (guile)

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@
285285
{%- endblock form -%}
286286

287287
{%- block form_start -%}
288+
{%- do form.setMethodRendered() -%}
288289
{% set method = method|upper %}
289290
{%- if method in ["GET", "POST"] -%}
290291
{% set form_method = method %}
@@ -320,6 +321,20 @@
320321
{{- form_row(child) -}}
321322
{% endif %}
322323
{%- endfor %}
324+
325+
{% if not form.methodRendered %}
326+
{%- do form.setMethodRendered() -%}
327+
{% set method = method|upper %}
328+
{%- if method in ["GET", "POST"] -%}
329+
{% set form_method = method %}
330+
{%- else -%}
331+
{% set form_method = "POST" %}
332+
{%- endif -%}
333+
334+
{%- if form_method != method -%}
335+
<input type="hidden" name="_method" value="{{ method }}" />
336+
{%- endif -%}
337+
{% endif %}
323338
{% endblock form_rest %}
324339

325340
{# Support #}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require-dev": {
2323
"symfony/asset": "~2.8|~3.0",
2424
"symfony/finder": "~2.8|~3.0",
25-
"symfony/form": "^3.2.7",
25+
"symfony/form": "^3.2.10|^3.3.3",
2626
"symfony/http-kernel": "~3.2",
2727
"symfony/polyfill-intl-icu": "~1.0",
2828
"symfony/routing": "~2.8|~3.0",
@@ -36,6 +36,9 @@
3636
"symfony/var-dumper": "~2.8.10|~3.1.4|~3.2",
3737
"symfony/expression-language": "~2.8|~3.0"
3838
},
39+
"conflict": {
40+
"symfony/form": "<3.2.10|~3.3,<3.3.3"
41+
},
3942
"suggest": {
4043
"symfony/finder": "",
4144
"symfony/asset": "For using the AssetExtension",

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
110110
$rows = array();
111111
$copyUsed = false;
112112
$exitCode = 0;
113+
$validAssetDirs = array();
113114
/** @var BundleInterface $bundle */
114115
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
115116
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
@@ -148,6 +149,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
148149
$exitCode = 1;
149150
$rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage());
150151
}
152+
$validAssetDirs[] = $targetDir;
153+
}
154+
// remove the assets of the bundles that no longer exist
155+
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
156+
if (!in_array($dir, $validAssetDirs)) {
157+
$filesystem->remove($dir);
158+
}
151159
}
152160

153161
$io->table(array('', 'Bundle', 'Method / Error'), $rows);

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
147147
$safeTempKernel = str_replace('\\', '\\\\', get_class($tempKernel));
148148
$realKernelFQN = get_class($realKernel);
149149

150-
foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) {
150+
foreach (Finder::create()->files()->depth('<3')->name('*.meta')->in($warmupDir) as $file) {
151151
file_put_contents($file, preg_replace(
152152
'/(C\:\d+\:)"'.$safeTempKernel.'"/',
153153
sprintf('$1"%s"', $realKernelFQN),
@@ -159,14 +159,16 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
159159
$search = array($warmupDir, str_replace('\\', '\\\\', $warmupDir));
160160
$replace = str_replace('\\', '/', $realCacheDir);
161161
foreach (Finder::create()->files()->in($warmupDir) as $file) {
162-
$content = str_replace($search, $replace, file_get_contents($file));
163-
file_put_contents($file, $content);
162+
$content = str_replace($search, $replace, file_get_contents($file), $count);
163+
if ($count) {
164+
file_put_contents($file, $content);
165+
}
164166
}
165167

166168
// fix references to container's class
167169
$tempContainerClass = get_class($tempKernel->getContainer());
168170
$realContainerClass = get_class($realKernel->getContainer());
169-
foreach (Finder::create()->files()->name($tempContainerClass.'*')->in($warmupDir) as $file) {
171+
foreach (Finder::create()->files()->depth('<2')->name($tempContainerClass.'*')->in($warmupDir) as $file) {
170172
$content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file));
171173
file_put_contents($file, $content);
172174
rename($file, str_replace(DIRECTORY_SEPARATOR.$tempContainerClass, DIRECTORY_SEPARATOR.$realContainerClass, $file));

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -400,6 +400,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
400400
->scalarNode('gc_divisor')->end()
401401
->scalarNode('gc_probability')->defaultValue(1)->end()
402402
->scalarNode('gc_maxlifetime')->end()
403+
->booleanNode('use_strict_mode')->end()
403404
->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
404405
->integerNode('metadata_update_threshold')
405406
->defaultValue('0')

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
555555
// session storage
556556
$container->setAlias('session.storage', $config['storage_id']);
557557
$options = array();
558-
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor') as $key) {
558+
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor', 'use_strict_mode') as $key) {
559559
if (isset($config[$key])) {
560560
$options[$key] = $config[$key];
561561
}

src/Symfony/Bundle/FrameworkBundle/Resources/config/schema/symfony-1.0.xsd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<xsd:element name="form" type="form" minOccurs="0" maxOccurs="1" />
1414
<xsd:element name="csrf-protection" type="csrf_protection" minOccurs="0" maxOccurs="1" />
1515
<xsd:element name="esi" type="esi" minOccurs="0" maxOccurs="1" />
16+
<xsd:element name="ssi" type="ssi" minOccurs="0" maxOccurs="1" />
1617
<xsd:element name="fragments" type="fragments" minOccurs="0" maxOccurs="1" />
1718
<xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
1819
<xsd:element name="router" type="router" minOccurs="0" maxOccurs="1" />
@@ -57,6 +58,10 @@
5758
<xsd:attribute name="enabled" type="xsd:boolean" />
5859
</xsd:complexType>
5960

61+
<xsd:complexType name="ssi">
62+
<xsd:attribute name="enabled" type="xsd:boolean" />
63+
</xsd:complexType>
64+
6065
<xsd:complexType name="fragments">
6166
<xsd:attribute name="enabled" type="xsd:boolean" />
6267
<xsd:attribute name="path" type="xsd:string" />
@@ -105,6 +110,7 @@
105110
<xsd:attribute name="gc-maxlifetime" type="xsd:string" />
106111
<xsd:attribute name="gc-divisor" type="xsd:string" />
107112
<xsd:attribute name="gc-probability" type="xsd:string" />
113+
<xsd:attribute name="use-strict-mode" type="xsd:boolean" />
108114
<xsd:attribute name="save-path" type="xsd:string" />
109115
</xsd:complexType>
110116

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/full.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
'esi' => array(
1515
'enabled' => true,
1616
),
17+
'ssi' => array(
18+
'enabled' => true,
19+
),
1720
'profiler' => array(
1821
'only_exceptions' => true,
1922
'enabled' => false,

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/full.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
<framework:csrf-protection field-name="_csrf"/>
1313
</framework:form>
1414
<framework:esi enabled="true" />
15+
<framework:ssi enabled="true" />
1516
<framework:profiler only-exceptions="true" enabled="false" />
1617
<framework:router resource="%kernel.root_dir%/config/routing.xml" type="xml" />
1718
<framework:session gc-maxlifetime="90000" gc-probability="1" gc-divisor="108" storage-id="session.storage.native" handler-id="session.handler.native_file" name="_SYMFONY" cookie-lifetime="86400" cookie-path="/" cookie-domain="example.com" cookie-secure="true" cookie-httponly="false" use-cookies="true" save-path="/path/to/sessions" />

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ framework:
99
trusted_proxies: ['127.0.0.1', '10.0.0.1']
1010
esi:
1111
enabled: true
12+
ssi:
13+
enabled: true
1214
profiler:
1315
only_exceptions: true
1416
enabled: false

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,13 @@ public function testEsi()
133133
$this->assertTrue($container->hasDefinition('esi'), '->registerEsiConfiguration() loads esi.xml');
134134
}
135135

136+
public function testSsi()
137+
{
138+
$container = $this->createContainerFromFile('full');
139+
140+
$this->assertTrue($container->hasDefinition('ssi'), '->registerSsiConfiguration() loads ssi.xml');
141+
}
142+
136143
public function testEnabledProfiler()
137144
{
138145
$container = $this->createContainerFromFile('profiler');

src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,52 @@ public function testInvalidOptions()
144144
{
145145
$container = $this->getMockBuilder('Symfony\Component\DependencyInjection\ContainerInterface')->getMock();
146146

147-
(new Translator($container, new MessageSelector(), array(), array('foo' => 'bar')));
147+
(new Translator($container, new MessageSelector(), [], ['foo' => 'bar']));
148+
}
149+
150+
/** @dataProvider getDebugModeAndCacheDirCombinations */
151+
public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache)
152+
{
153+
$someCatalogue = $this->getCatalogue('some_locale', array());
154+
155+
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
156+
157+
$loader->expects($this->at(0))
158+
->method('load')
159+
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
160+
->with('messages.some_locale.loader', 'some_locale', 'messages')
161+
->willReturn($someCatalogue);
162+
163+
$loader->expects($this->at(1))
164+
->method('load')
165+
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
166+
->with('second_resource.some_locale.loader', 'some_locale', 'messages')
167+
->willReturn($someCatalogue);
168+
169+
$options = array(
170+
'resource_files' => array('some_locale' => array('messages.some_locale.loader')),
171+
'debug' => $debug,
172+
);
173+
174+
if ($enableCache) {
175+
$options['cache_dir'] = $this->tmpDir;
176+
}
177+
178+
/** @var Translator $translator */
179+
$translator = $this->createTranslator($loader, $options);
180+
$translator->addResource('loader', 'second_resource.some_locale.loader', 'some_locale', 'messages');
181+
182+
$translator->trans('some_message', array(), null, 'some_locale');
183+
}
184+
185+
public function getDebugModeAndCacheDirCombinations()
186+
{
187+
return array(
188+
array(false, false),
189+
array(true, false),
190+
array(false, true),
191+
array(true, true),
192+
);
148193
}
149194

150195
protected function getCatalogue($locale, $messages, $resources = array())

0 commit comments

Comments
 (0)
0