Skip to content

Commit 673523a

Browse files
committed
Merge branch '3.2' into 3.3
* 3.2: (42 commits) Show exception is checked twice in ExceptionController of twig allow SSI fragments configuration in XML files Display a better error message when the toolbar cannot be displayed render hidden _method field in form_rest() Add Doctrine Cache to dev dependencies to fix failing unit tests. 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 fixed bad merge 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 ...
2 parents 968d0c1 + ca9ea9f commit 673523a

File tree

11 files changed

+102
-12
lines changed

11 files changed

+102
-12
lines changed

Command/AssetsInstallCommand.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
114114
$rows = array();
115115
$copyUsed = false;
116116
$exitCode = 0;
117+
$validAssetDirs = array();
117118
/** @var BundleInterface $bundle */
118119
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
119120
if (!is_dir($originDir = $bundle->getPath().'/Resources/public')) {
@@ -152,6 +153,13 @@ protected function execute(InputInterface $input, OutputInterface $output)
152153
$exitCode = 1;
153154
$rows[] = array(sprintf('<fg=red;options=bold>%s</>', '\\' === DIRECTORY_SEPARATOR ? 'ERROR' : "\xE2\x9C\x98" /* HEAVY BALLOT X (U+2718) */), $message, $e->getMessage());
154155
}
156+
$validAssetDirs[] = $targetDir;
157+
}
158+
// remove the assets of the bundles that no longer exist
159+
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
160+
if (!in_array($dir, $validAssetDirs)) {
161+
$filesystem->remove($dir);
162+
}
155163
}
156164

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

Command/CacheClearCommand.php

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

161-
foreach (Finder::create()->files()->name('*.meta')->in($warmupDir) as $file) {
161+
foreach (Finder::create()->files()->depth('<3')->name('*.meta')->in($warmupDir) as $file) {
162162
file_put_contents($file, preg_replace(
163163
'/(C\:\d+\:)"'.$safeTempKernel.'"/',
164164
sprintf('$1"%s"', $realKernelFQN),
@@ -170,14 +170,16 @@ protected function warmup($warmupDir, $realCacheDir, $enableOptionalWarmers = tr
170170
$search = array($warmupDir, str_replace('\\', '\\\\', $warmupDir));
171171
$replace = str_replace('\\', '/', $realCacheDir);
172172
foreach (Finder::create()->files()->in($warmupDir) as $file) {
173-
$content = str_replace($search, $replace, file_get_contents($file));
174-
file_put_contents($file, $content);
173+
$content = str_replace($search, $replace, file_get_contents($file), $count);
174+
if ($count) {
175+
file_put_contents($file, $content);
176+
}
175177
}
176178

177179
// fix references to container's class
178180
$tempContainerClass = get_class($tempKernel->getContainer());
179181
$realContainerClass = get_class($realKernel->getContainer());
180-
foreach (Finder::create()->files()->name($tempContainerClass.'*')->in($warmupDir) as $file) {
182+
foreach (Finder::create()->files()->depth('<2')->name($tempContainerClass.'*')->in($warmupDir) as $file) {
181183
$content = str_replace($tempContainerClass, $realContainerClass, file_get_contents($file));
182184
file_put_contents($file, $content);
183185
rename($file, str_replace(DIRECTORY_SEPARATOR.$tempContainerClass, DIRECTORY_SEPARATOR.$realContainerClass, $file));

DependencyInjection/Configuration.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ private function addSessionSection(ArrayNodeDefinition $rootNode)
435435
->scalarNode('gc_divisor')->end()
436436
->scalarNode('gc_probability')->defaultValue(1)->end()
437437
->scalarNode('gc_maxlifetime')->end()
438+
->booleanNode('use_strict_mode')->end()
438439
->scalarNode('save_path')->defaultValue('%kernel.cache_dir%/sessions')->end()
439440
->integerNode('metadata_update_threshold')
440441
->defaultValue('0')

DependencyInjection/FrameworkExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,7 @@ private function registerSessionConfiguration(array $config, ContainerBuilder $c
702702
// session storage
703703
$container->setAlias('session.storage', $config['storage_id']);
704704
$options = array();
705-
foreach (array('name', 'cookie_lifetime', 'cookie_path', 'cookie_domain', 'cookie_secure', 'cookie_httponly', 'use_cookies', 'gc_maxlifetime', 'gc_probability', 'gc_divisor') as $key) {
705+
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) {
706706
if (isset($config[$key])) {
707707
$options[$key] = $config[$key];
708708
}

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="web-link" type="web_link" minOccurs="0" maxOccurs="1" />
1819
<xsd:element name="profiler" type="profiler" minOccurs="0" maxOccurs="1" />
@@ -58,6 +59,10 @@
5859
<xsd:attribute name="enabled" type="xsd:boolean" />
5960
</xsd:complexType>
6061

62+
<xsd:complexType name="ssi">
63+
<xsd:attribute name="enabled" type="xsd:boolean" />
64+
</xsd:complexType>
65+
6166
<xsd:complexType name="fragments">
6267
<xsd:attribute name="enabled" type="xsd:boolean" />
6368
<xsd:attribute name="path" type="xsd:string" />
@@ -110,6 +115,7 @@
110115
<xsd:attribute name="gc-maxlifetime" type="xsd:string" />
111116
<xsd:attribute name="gc-divisor" type="xsd:string" />
112117
<xsd:attribute name="gc-probability" type="xsd:string" />
118+
<xsd:attribute name="use-strict-mode" type="xsd:boolean" />
113119
<xsd:attribute name="save-path" type="xsd:string" />
114120
</xsd:complexType>
115121

Tests/DependencyInjection/Fixtures/php/full.php

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

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" />

Tests/DependencyInjection/Fixtures/yml/full.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ framework:
88
http_method_override: false
99
esi:
1010
enabled: true
11+
ssi:
12+
enabled: true
1113
profiler:
1214
only_exceptions: true
1315
enabled: false

Tests/DependencyInjection/FrameworkExtensionTest.php

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

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

Tests/Translation/TranslatorTest.php

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,51 @@ public function testInvalidOptions()
293293
(new Translator($container, new MessageSelector(), 'en', array(), array('foo' => 'bar')));
294294
}
295295

296+
/** @dataProvider getDebugModeAndCacheDirCombinations */
297+
public function testResourceFilesOptionLoadsBeforeOtherAddedResources($debug, $enableCache)
298+
{
299+
$someCatalogue = $this->getCatalogue('some_locale', array());
300+
301+
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
302+
303+
$loader->expects($this->at(0))
304+
->method('load')
305+
/* The "messages.some_locale.loader" is passed via the resource_file option and shall be loaded first */
306+
->with('messages.some_locale.loader', 'some_locale', 'messages')
307+
->willReturn($someCatalogue);
308+
309+
$loader->expects($this->at(1))
310+
->method('load')
311+
/* This resource is added by an addResource() call and shall be loaded after the resource_files */
312+
->with('second_resource.some_locale.loader', 'some_locale', 'messages')
313+
->willReturn($someCatalogue);
314+
315+
$options = array(
316+
'resource_files' => array('some_locale' => array('messages.some_locale.loader')),
317+
'debug' => $debug,
318+
);
319+
320+
if ($enableCache) {
321+
$options['cache_dir'] = $this->tmpDir;
322+
}
323+
324+
/** @var Translator $translator */
325+
$translator = $this->createTranslator($loader, $options);
326+
$translator->addResource('loader', 'second_resource.some_locale.loader', 'some_locale', 'messages');
327+
328+
$translator->trans('some_message', array(), null, 'some_locale');
329+
}
330+
331+
public function getDebugModeAndCacheDirCombinations()
332+
{
333+
return array(
334+
array(false, false),
335+
array(true, false),
336+
array(false, true),
337+
array(true, true),
338+
);
339+
}
340+
296341
protected function getCatalogue($locale, $messages, $resources = array())
297342
{
298343
$catalogue = new MessageCatalogue($locale);

0 commit comments

Comments
 (0)