Skip to content

Commit ca9ea9f

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 files 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 4ec5b5d + c880639 commit ca9ea9f

File tree

11 files changed

+103
-13
lines changed

11 files changed

+103
-13
lines changed

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);

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));

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')

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
}

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

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,

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
@@ -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

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');

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)