Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 432487f

Browse filesBrowse files
Merge branch '3.4' into 4.1
* 3.4: [appveyor] fix Revert "minor #28321 [Routing] Fixed the interface description of the url generator interface (Toflar)" Fixed caching of templates in default path on cache warmup remove cache warmers when Twig cache is disabled [HttpKernel][FrameworkBundle] Fix escaping of serialized payloads passed to test clients chore: rename Appveyor filename Fixed the interface description of the url generator interface Format file size in validation message according to binaryFormat option
2 parents cba6421 + 5632dc7 commit 432487f
Copy full SHA for 432487f

File tree

12 files changed

+60
-29
lines changed
Filter options

12 files changed

+60
-29
lines changed

‎appveyor.yml renamed to ‎.appveyor.yml

Copy file name to clipboardExpand all lines: .appveyor.yml
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ install:
4545
- php composer.phar self-update
4646
- copy /Y .composer\* %APPDATA%\Composer\
4747
- php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
48-
- php .github/build-packages.php %APPVEYOR_REPO_COMMIT%^^ src\Symfony\Bridge\PhpUnit
48+
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
4949
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
5050
- php composer.phar update --no-progress --no-suggest --ansi
5151
- php phpunit install

‎.github/build-packages.php

Copy file name to clipboardExpand all lines: .github/build-packages.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,20 @@
66
}
77
chdir(dirname(__DIR__));
88

9+
$json = ltrim(file_get_contents('composer.json'));
10+
if ($json !== $package = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json)) {
11+
file_put_contents('composer.json', $package);
12+
}
13+
914
$dirs = $_SERVER['argv'];
1015
array_shift($dirs);
11-
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs))));
16+
$mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($dirs))));
1217

1318
$packages = array();
1419
$flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
1520

1621
foreach ($dirs as $k => $dir) {
17-
if (!system("git diff --name-only \"$mergeBase\" -- $dir", $exitStatus)) {
22+
if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
1823
if ($exitStatus) {
1924
exit($exitStatus);
2025
}
@@ -74,7 +79,6 @@
7479
'type' => 'composer',
7580
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
7681
));
77-
$json = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json);
7882
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
7983
file_put_contents('composer.json', $json);
8084
}

‎src/Symfony/Bundle/FrameworkBundle/Client.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Client.php
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ protected function doRequestInProcess($request)
161161
*/
162162
protected function getScript($request)
163163
{
164-
$kernel = str_replace("'", "\\'", serialize($this->kernel));
165-
$request = str_replace("'", "\\'", serialize($request));
164+
$kernel = var_export(serialize($this->kernel), true);
165+
$request = var_export(serialize($request), true);
166166
$errorReporting = error_reporting();
167167

168168
$requires = '';
@@ -171,7 +171,7 @@ protected function getScript($request)
171171
$r = new \ReflectionClass($class);
172172
$file = \dirname(\dirname($r->getFileName())).'/autoload.php';
173173
if (file_exists($file)) {
174-
$requires .= "require_once '".str_replace("'", "\\'", $file)."';\n";
174+
$requires .= 'require_once '.var_export($file, true).";\n";
175175
}
176176
}
177177
}
@@ -180,7 +180,7 @@ protected function getScript($request)
180180
throw new \RuntimeException('Composer autoloader not found.');
181181
}
182182

183-
$requires .= "require_once '".str_replace("'", "\\'", (new \ReflectionObject($this->kernel))->getFileName())."';\n";
183+
$requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n";
184184

185185
$profilerCode = '';
186186
if ($this->profiler) {
@@ -194,11 +194,11 @@ protected function getScript($request)
194194
195195
$requires
196196
197-
\$kernel = unserialize('$kernel');
197+
\$kernel = unserialize($kernel);
198198
\$kernel->boot();
199199
$profilerCode
200200
201-
\$request = unserialize('$request');
201+
\$request = unserialize($request);
202202
EOF;
203203

204204
return $code.$this->getHandleScript();

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

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ public function process(ContainerBuilder $container)
4747
$coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form';
4848
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath));
4949

50-
$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
50+
$paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
5151
$paths[$coreThemePath] = null;
52-
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
5352
$container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);
53+
54+
if ($container->hasDefinition('twig.cache_warmer')) {
55+
$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
56+
$paths[$coreThemePath] = null;
57+
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
58+
}
5459
}
5560

5661
if ($container->has('router')) {

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,11 @@ public function load(array $configs, ContainerBuilder $container)
147147
$container->registerForAutoconfiguration(ExtensionInterface::class)->addTag('twig.extension');
148148
$container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader');
149149
$container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime');
150+
151+
if (false === $config['cache']) {
152+
$container->removeDefinition('twig.cache_warmer');
153+
$container->removeDefinition('twig.template_cache_warmer');
154+
}
150155
}
151156

152157
private function getBundleTemplatePaths(ContainerBuilder $container, array $config)

‎src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Resources/config/twig.xml
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<argument type="service" id="kernel" />
4242
<argument>%kernel.root_dir%</argument>
4343
<argument type="collection" /> <!-- Twig paths -->
44+
<argument>%twig.default_path%</argument>
4445
</service>
4546

4647
<service id="twig.template_cache_warmer" class="Symfony\Bundle\TwigBundle\CacheWarmer\TemplateCacheWarmer">

‎src/Symfony/Bundle/TwigBundle/TemplateIterator.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/TemplateIterator.php
+15-8Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,20 @@ class TemplateIterator implements \IteratorAggregate
2525
private $rootDir;
2626
private $templates;
2727
private $paths;
28+
private $defaultPath;
2829

2930
/**
30-
* @param KernelInterface $kernel A KernelInterface instance
31-
* @param string $rootDir The directory where global templates can be stored
32-
* @param array $paths Additional Twig paths to warm
31+
* @param KernelInterface $kernel A KernelInterface instance
32+
* @param string $rootDir The directory where global templates can be stored
33+
* @param array $paths Additional Twig paths to warm
34+
* @param string $defaultPath The directory where global templates can be stored
3335
*/
34-
public function __construct(KernelInterface $kernel, string $rootDir, array $paths = array())
36+
public function __construct(KernelInterface $kernel, string $rootDir, array $paths = array(), string $defaultPath = null)
3537
{
3638
$this->kernel = $kernel;
3739
$this->rootDir = $rootDir;
3840
$this->paths = $paths;
41+
$this->defaultPath = $defaultPath;
3942
}
4043

4144
/**
@@ -47,7 +50,10 @@ public function getIterator()
4750
return $this->templates;
4851
}
4952

50-
$this->templates = $this->findTemplatesInDirectory($this->rootDir.'/Resources/views');
53+
$this->templates = array_merge(
54+
$this->findTemplatesInDirectory($this->rootDir.'/Resources/views'),
55+
$this->findTemplatesInDirectory($this->defaultPath, null, array('bundles'))
56+
);
5157
foreach ($this->kernel->getBundles() as $bundle) {
5258
$name = $bundle->getName();
5359
if ('Bundle' === substr($name, -6)) {
@@ -57,7 +63,8 @@ public function getIterator()
5763
$this->templates = array_merge(
5864
$this->templates,
5965
$this->findTemplatesInDirectory($bundle->getPath().'/Resources/views', $name),
60-
$this->findTemplatesInDirectory($this->rootDir.'/'.$bundle->getName().'/views', $name)
66+
$this->findTemplatesInDirectory($this->rootDir.'/'.$bundle->getName().'/views', $name),
67+
$this->findTemplatesInDirectory($this->defaultPath.'/bundles/'.$bundle->getName(), $name)
6168
);
6269
}
6370

@@ -76,14 +83,14 @@ public function getIterator()
7683
*
7784
* @return array
7885
*/
79-
private function findTemplatesInDirectory($dir, $namespace = null)
86+
private function findTemplatesInDirectory($dir, $namespace = null, array $excludeDirs = array())
8087
{
8188
if (!is_dir($dir)) {
8289
return array();
8390
}
8491

8592
$templates = array();
86-
foreach (Finder::create()->files()->followLinks()->in($dir) as $file) {
93+
foreach (Finder::create()->files()->followLinks()->in($dir)->exclude($excludeDirs) as $file) {
8794
$templates[] = (null !== $namespace ? '@'.$namespace.'/' : '').str_replace('\\', '/', $file->getRelativePathname());
8895
}
8996

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This is a layout

‎src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/Tests/TemplateIteratorTest.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,14 @@ public function testGetIterator()
2525
$kernel->expects($this->any())->method('getBundles')->will($this->returnValue(array(
2626
$bundle,
2727
)));
28-
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'));
28+
$iterator = new TemplateIterator($kernel, __DIR__.'/Fixtures/templates', array(__DIR__.'/Fixtures/templates/Foo' => 'Foo'), __DIR__.'/DependencyInjection/Fixtures/templates');
2929

3030
$sorted = iterator_to_array($iterator);
3131
sort($sorted);
3232
$this->assertEquals(
3333
array(
3434
'@Bar/index.html.twig',
35+
'@Bar/layout.html.twig',
3536
'@Foo/index.html.twig',
3637
'layout.html.twig',
3738
'sub/sub.html.twig',

‎src/Symfony/Component/HttpKernel/Client.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpKernel/Client.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ protected function doRequest($request)
8181
*/
8282
protected function getScript($request)
8383
{
84-
$kernel = str_replace("'", "\\'", serialize($this->kernel));
85-
$request = str_replace("'", "\\'", serialize($request));
84+
$kernel = var_export(serialize($this->kernel), true);
85+
$request = var_export(serialize($request), true);
86+
8687
$errorReporting = error_reporting();
8788

8889
$requires = '';
@@ -91,7 +92,7 @@ protected function getScript($request)
9192
$r = new \ReflectionClass($class);
9293
$file = \dirname(\dirname($r->getFileName())).'/autoload.php';
9394
if (file_exists($file)) {
94-
$requires .= "require_once '".str_replace("'", "\\'", $file)."';\n";
95+
$requires .= 'require_once '.var_export($file, true).";\n";
9596
}
9697
}
9798
}
@@ -107,8 +108,8 @@ protected function getScript($request)
107108
108109
$requires
109110
110-
\$kernel = unserialize('$kernel');
111-
\$request = unserialize('$request');
111+
\$kernel = unserialize($kernel);
112+
\$request = unserialize($request);
112113
EOF;
113114

114115
return $code.$this->getHandleScript();

‎src/Symfony/Component/Validator/Constraints/FileValidator.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/FileValidator.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function validate($value, Constraint $constraint)
5757
$binaryFormat = $constraint->binaryFormat;
5858
} else {
5959
$limitInBytes = $iniLimitSize;
60-
$binaryFormat = true;
60+
$binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
6161
}
6262

6363
list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);

‎src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php
+8-2Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,17 @@ public function uploadedFileErrorProvider()
451451
'{{ suffix }}' => 'bytes',
452452
), '1');
453453

454+
// access FileValidator::factorizeSizes() private method to format max file size
455+
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
456+
$method = $reflection->getMethod('factorizeSizes');
457+
$method->setAccessible(true);
458+
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false));
459+
454460
// it correctly parses the maxSize option and not only uses simple string comparison
455461
// 1000M should be bigger than the ini value
456462
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
457-
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576,
458-
'{{ suffix }}' => 'MiB',
463+
'{{ limit }}' => $limit,
464+
'{{ suffix }}' => $suffix,
459465
), '1000M');
460466

461467
// it correctly parses the maxSize option and not only uses simple string comparison

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.