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
This commit is contained in:
Nicolas Grekas 2018-09-05 13:56:21 +02:00
commit 5632dc7c7a
8 changed files with 41 additions and 20 deletions

View File

@ -53,7 +53,7 @@ install:
- php composer.phar self-update - php composer.phar self-update
- copy /Y .composer\* %APPDATA%\Composer\ - copy /Y .composer\* %APPDATA%\Composer\
- php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex dev-master - php composer.phar global require --no-progress --no-scripts --no-plugins symfony/flex dev-master
- php .github/build-packages.php %APPVEYOR_REPO_COMMIT%^^ src\Symfony\Bridge\PhpUnit - php .github/build-packages.php "HEAD^" src\Symfony\Bridge\PhpUnit
- IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev) - IF %APPVEYOR_REPO_BRANCH%==master (SET COMPOSER_ROOT_VERSION=dev-master) ELSE (SET COMPOSER_ROOT_VERSION=%APPVEYOR_REPO_BRANCH%.x-dev)
- php composer.phar config platform.php 5.5.9 - php composer.phar config platform.php 5.5.9
- php composer.phar update --no-progress --no-suggest --ansi - php composer.phar update --no-progress --no-suggest --ansi

View File

@ -6,15 +6,20 @@ if (3 > $_SERVER['argc']) {
} }
chdir(dirname(__DIR__)); chdir(dirname(__DIR__));
$json = ltrim(file_get_contents('composer.json'));
if ($json !== $package = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json)) {
file_put_contents('composer.json', $package);
}
$dirs = $_SERVER['argv']; $dirs = $_SERVER['argv'];
array_shift($dirs); array_shift($dirs);
$mergeBase = trim(shell_exec(sprintf('git merge-base %s HEAD', array_shift($dirs)))); $mergeBase = trim(shell_exec(sprintf('git merge-base "%s" HEAD', array_shift($dirs))));
$packages = array(); $packages = array();
$flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; $flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0;
foreach ($dirs as $k => $dir) { foreach ($dirs as $k => $dir) {
if (!system("git diff --name-only \"$mergeBase\" -- $dir", $exitStatus)) { if (!system("git diff --name-only $mergeBase -- $dir", $exitStatus)) {
if ($exitStatus) { if ($exitStatus) {
exit($exitStatus); exit($exitStatus);
} }
@ -74,7 +79,6 @@ if ($dirs) {
'type' => 'composer', 'type' => 'composer',
'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/', 'url' => 'file://'.str_replace(DIRECTORY_SEPARATOR, '/', dirname(__DIR__)).'/',
)); ));
$json = preg_replace('/\n "repositories": \[\n.*?\n \],/s', '', $json);
$json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1); $json = rtrim(json_encode(array('repositories' => $package->repositories), $flags), "\n}").','.substr($json, 1);
file_put_contents('composer.json', $json); file_put_contents('composer.json', $json);
} }

View File

@ -161,8 +161,8 @@ class Client extends BaseClient
*/ */
protected function getScript($request) protected function getScript($request)
{ {
$kernel = str_replace("'", "\\'", serialize($this->kernel)); $kernel = var_export(serialize($this->kernel), true);
$request = str_replace("'", "\\'", serialize($request)); $request = var_export(serialize($request), true);
$errorReporting = error_reporting(); $errorReporting = error_reporting();
$requires = ''; $requires = '';
@ -171,7 +171,7 @@ class Client extends BaseClient
$r = new \ReflectionClass($class); $r = new \ReflectionClass($class);
$file = \dirname(\dirname($r->getFileName())).'/autoload.php'; $file = \dirname(\dirname($r->getFileName())).'/autoload.php';
if (file_exists($file)) { if (file_exists($file)) {
$requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; $requires .= 'require_once '.var_export($file, true).";\n";
} }
} }
} }
@ -180,7 +180,7 @@ class Client extends BaseClient
throw new \RuntimeException('Composer autoloader not found.'); throw new \RuntimeException('Composer autoloader not found.');
} }
$requires .= "require_once '".str_replace("'", "\\'", (new \ReflectionObject($this->kernel))->getFileName())."';\n"; $requires .= 'require_once '.var_export((new \ReflectionObject($this->kernel))->getFileName(), true).";\n";
$profilerCode = ''; $profilerCode = '';
if ($this->profiler) { if ($this->profiler) {
@ -194,11 +194,11 @@ error_reporting($errorReporting);
$requires $requires
\$kernel = unserialize('$kernel'); \$kernel = unserialize($kernel);
\$kernel->boot(); \$kernel->boot();
$profilerCode $profilerCode
\$request = unserialize('$request'); \$request = unserialize($request);
EOF; EOF;
return $code.$this->getHandleScript(); return $code.$this->getHandleScript();

View File

@ -47,10 +47,15 @@ class ExtensionPass implements CompilerPassInterface
$coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form'; $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form';
$container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath)); $container->getDefinition('twig.loader.native_filesystem')->addMethodCall('addPath', array($coreThemePath));
$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2); $paths = $container->getDefinition('twig.template_iterator')->getArgument(2);
$paths[$coreThemePath] = null; $paths[$coreThemePath] = null;
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
$container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths); $container->getDefinition('twig.template_iterator')->replaceArgument(2, $paths);
if ($container->hasDefinition('twig.cache_warmer')) {
$paths = $container->getDefinition('twig.cache_warmer')->getArgument(2);
$paths[$coreThemePath] = null;
$container->getDefinition('twig.cache_warmer')->replaceArgument(2, $paths);
}
} }
if ($container->has('router')) { if ($container->has('router')) {

View File

@ -166,6 +166,11 @@ class TwigExtension extends Extension
$container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader'); $container->registerForAutoconfiguration(LoaderInterface::class)->addTag('twig.loader');
$container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime'); $container->registerForAutoconfiguration(RuntimeExtensionInterface::class)->addTag('twig.runtime');
if (false === $config['cache']) {
$container->removeDefinition('twig.cache_warmer');
$container->removeDefinition('twig.template_cache_warmer');
}
if (\PHP_VERSION_ID < 70000) { if (\PHP_VERSION_ID < 70000) {
$this->addClassesToCompile(array( $this->addClassesToCompile(array(
'Twig_Environment', 'Twig_Environment',

View File

@ -81,8 +81,9 @@ class Client extends BaseClient
*/ */
protected function getScript($request) protected function getScript($request)
{ {
$kernel = str_replace("'", "\\'", serialize($this->kernel)); $kernel = var_export(serialize($this->kernel), true);
$request = str_replace("'", "\\'", serialize($request)); $request = var_export(serialize($request), true);
$errorReporting = error_reporting(); $errorReporting = error_reporting();
$requires = ''; $requires = '';
@ -91,7 +92,7 @@ class Client extends BaseClient
$r = new \ReflectionClass($class); $r = new \ReflectionClass($class);
$file = \dirname(\dirname($r->getFileName())).'/autoload.php'; $file = \dirname(\dirname($r->getFileName())).'/autoload.php';
if (file_exists($file)) { if (file_exists($file)) {
$requires .= "require_once '".str_replace("'", "\\'", $file)."';\n"; $requires .= 'require_once '.var_export($file, true).";\n";
} }
} }
} }
@ -107,8 +108,8 @@ error_reporting($errorReporting);
$requires $requires
\$kernel = unserialize('$kernel'); \$kernel = unserialize($kernel);
\$request = unserialize('$request'); \$request = unserialize($request);
EOF; EOF;
return $code.$this->getHandleScript(); return $code.$this->getHandleScript();

View File

@ -57,7 +57,7 @@ class FileValidator extends ConstraintValidator
$binaryFormat = $constraint->binaryFormat; $binaryFormat = $constraint->binaryFormat;
} else { } else {
$limitInBytes = $iniLimitSize; $limitInBytes = $iniLimitSize;
$binaryFormat = true; $binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat;
} }
list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat); list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat);

View File

@ -450,11 +450,17 @@ abstract class FileValidatorTest extends ConstraintValidatorTestCase
'{{ suffix }}' => 'bytes', '{{ suffix }}' => 'bytes',
), '1'); ), '1');
// access FileValidator::factorizeSizes() private method to format max file size
$reflection = new \ReflectionClass(\get_class(new FileValidator()));
$method = $reflection->getMethod('factorizeSizes');
$method->setAccessible(true);
list($sizeAsString, $limit, $suffix) = $method->invokeArgs(new FileValidator(), array(0, UploadedFile::getMaxFilesize(), false));
// it correctly parses the maxSize option and not only uses simple string comparison // it correctly parses the maxSize option and not only uses simple string comparison
// 1000M should be bigger than the ini value // 1000M should be bigger than the ini value
$tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array( $tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array(
'{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576, '{{ limit }}' => $limit,
'{{ suffix }}' => 'MiB', '{{ suffix }}' => $suffix,
), '1000M'); ), '1000M');
// it correctly parses the maxSize option and not only uses simple string comparison // it correctly parses the maxSize option and not only uses simple string comparison