8000 Merge branch '2.8' into 3.4 · symfony/symfony@5632dc7 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5632dc7

Browse files
Merge branch '2.8' into 3.4
* 2.8: [appveyor] fix Revert "minor #28321 [Routing] Fixed the interface description of the url generator interface (Toflar)" 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 eaeb124 + 992a174 commit 5632dc7

File tree

8 files changed

+41
-20
lines changed

8 files changed

+41
-20
lines changed

appveyor.yml renamed to .appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ install:
5353
- php composer.phar self-update
5454
- copy /Y .composer\* %APPDATA%\Composer\
5555
- php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
56-
- php .github/build-packages.php %APPVEYOR_REPO_COMMIT%^^ src\Symfony\Bridge\PhpUnit
56+
- php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
5757
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
5858
- php composer.phar config platform.php 5.5.9
5959
- php composer.phar update --no-progress --no-suggest --ansi

.github/build-packages.php

Lines 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

Lines 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

Lines 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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ public function load(array $configs, ContainerBuilder $container)
166166
$container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader');
167167
$container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime');
168168

169+
if (false === $config['cache']) {
170+
$container->removeDefinition('twig.cache_warmer');
171+
$container->removeDefinition('twig.template_cache_warmer');
172+
}
173+
169174
if (\PHP_VERSION_ID < 70000) {
170175
$this->addClassesToCompile(array(
171176
'Twig_Environment',

src/Symfony/Component/HttpKernel/Client.php

Lines 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

Lines 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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,11 +450,17 @@ public function uploadedFileErrorProvider()
450450
'{{ suffix }}' => 'bytes',
451451
), '1');
452452

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

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

0 commit comments

Comments
 (0)
0