From 0edbbd3feaaf1fa852dd4b92c1004f7d383c23b1 Mon Sep 17 00:00:00 2001 From: Julien Fredon Date: Sun, 8 Jul 2018 23:39:51 +0200 Subject: [PATCH 1/7] Format file size in validation message according to binaryFormat option --- .../Component/Validator/Constraints/FileValidator.php | 2 +- .../Validator/Tests/Constraints/FileValidatorTest.php | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Component/Validator/Constraints/FileValidator.php b/src/Symfony/Component/Validator/Constraints/FileValidator.php index bb96e2c9a1..33c784b68c 100644 --- a/src/Symfony/Component/Validator/Constraints/FileValidator.php +++ b/src/Symfony/Component/Validator/Constraints/FileValidator.php @@ -58,7 +58,7 @@ class FileValidator extends ConstraintValidator $binaryFormat = $constraint->binaryFormat; } else { $limitInBytes = $iniLimitSize; - $binaryFormat = true; + $binaryFormat = null === $constraint->binaryFormat ? true : $constraint->binaryFormat; } list($sizeAsString, $limitAsString, $suffix) = $this->factorizeSizes(0, $limitInBytes, $binaryFormat); diff --git a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php index add06817d0..6e2199ce02 100644 --- a/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php +++ b/src/Symfony/Component/Validator/Tests/Constraints/FileValidatorTest.php @@ -455,11 +455,17 @@ abstract class FileValidatorTest extends AbstractConstraintValidatorTest '{{ suffix }}' => 'bytes', ), '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 // 1000M should be bigger than the ini value $tests[] = array(UPLOAD_ERR_INI_SIZE, 'uploadIniSizeErrorMessage', array( - '{{ limit }}' => UploadedFile::getMaxFilesize() / 1048576, - '{{ suffix }}' => 'MiB', + '{{ limit }}' => $limit, + '{{ suffix }}' => $suffix, ), '1000M'); // it correctly parses the maxSize option and not only uses simple string comparison From d2e9e0bcf3d0860e19f95872ad566763adbc9910 Mon Sep 17 00:00:00 2001 From: Yanick Witschi Date: Fri, 31 Aug 2018 10:56:24 +0200 Subject: [PATCH 2/7] Fixed the interface description of the url generator interface --- .../Component/Routing/Generator/UrlGeneratorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index f501ebd9a8..c7f4fca744 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -73,7 +73,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * @param mixed $parameters An array of parameters * @param int $referenceType The type of reference to be generated (one of the constants) * - * @return string The generated URL + * @return string|null The generated URL * * @throws RouteNotFoundException If the named route doesn't exist * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route From b133bd6bd30e54f9dfedff68f998def65988ae03 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Mon, 3 Sep 2018 20:51:33 +0200 Subject: [PATCH 3/7] chore: rename Appveyor filename --- appveyor.yml => .appveyor.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename appveyor.yml => .appveyor.yml (100%) diff --git a/appveyor.yml b/.appveyor.yml similarity index 100% rename from appveyor.yml rename to .appveyor.yml From 255455430a9363b5b7862e8729d870533e34826c Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 3 Sep 2018 16:40:22 +0200 Subject: [PATCH 4/7] [HttpKernel][FrameworkBundle] Fix escaping of serialized payloads passed to test clients --- src/Symfony/Bundle/FrameworkBundle/Client.php | 20 +++++++++---------- src/Symfony/Component/HttpKernel/Client.php | 16 +++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/Client.php b/src/Symfony/Bundle/FrameworkBundle/Client.php index 6cd0832b13..d8c7380d18 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Client.php +++ b/src/Symfony/Bundle/FrameworkBundle/Client.php @@ -161,19 +161,19 @@ class Client extends BaseClient */ protected function getScript($request) { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); $r = new \ReflectionObject($this->kernel); $autoloader = \dirname($r->getFileName()).'/autoload.php'; if (is_file($autoloader)) { - $autoloader = str_replace("'", "\\'", $autoloader); + $autoloader = var_export($autoloader, true); } else { - $autoloader = ''; + $autoloader = 'false'; } - $path = str_replace("'", "\\'", $r->getFileName()); + $path = var_export($r->getFileName(), true); $profilerCode = ''; if ($this->profiler) { @@ -187,16 +187,16 @@ class Client extends BaseClient error_reporting($errorReporting); -if ('$autoloader') { - require_once '$autoloader'; +if ($autoloader) { + require_once $autoloader; } -require_once '$path'; +require_once $path; -\$kernel = unserialize('$kernel'); +\$kernel = unserialize($kernel); \$kernel->boot(); $profilerCode -\$request = unserialize('$request'); +\$request = unserialize($request); EOF; return $code.$this->getHandleScript(); diff --git a/src/Symfony/Component/HttpKernel/Client.php b/src/Symfony/Component/HttpKernel/Client.php index 49f0e4c169..2175b567a7 100644 --- a/src/Symfony/Component/HttpKernel/Client.php +++ b/src/Symfony/Component/HttpKernel/Client.php @@ -71,12 +71,12 @@ class Client extends BaseClient */ protected function getScript($request) { - $kernel = str_replace("'", "\\'", serialize($this->kernel)); - $request = str_replace("'", "\\'", serialize($request)); + $kernel = var_export(serialize($this->kernel), true); + $request = var_export(serialize($request), true); $r = new \ReflectionClass('\\Symfony\\Component\\ClassLoader\\ClassLoader'); - $requirePath = str_replace("'", "\\'", $r->getFileName()); - $symfonyPath = str_replace("'", "\\'", \dirname(\dirname(\dirname(__DIR__)))); + $requirePath = var_export($r->getFileName(), true); + $symfonyPath = var_export(\dirname(\dirname(\dirname(__DIR__))), true); $errorReporting = error_reporting(); $code = <<addPrefix('Symfony', '$symfonyPath'); +\$loader->addPrefix('Symfony', $symfonyPath); \$loader->register(); -\$kernel = unserialize('$kernel'); -\$request = unserialize('$request'); +\$kernel = unserialize($kernel); +\$request = unserialize($request); EOF; return $code.$this->getHandleScript(); From ef1f7ff0bb1f3ac80c34505148532c3a34ab0bd3 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Mon, 23 Jul 2018 10:03:04 +0200 Subject: [PATCH 5/7] remove cache warmers when Twig cache is disabled --- .../DependencyInjection/Compiler/ExtensionPass.php | 9 +++++++-- .../TwigBundle/DependencyInjection/TwigExtension.php | 5 +++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php index b91744781a..4420a02b30 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/ExtensionPass.php @@ -49,10 +49,15 @@ class ExtensionPass implements CompilerPassInterface $coreThemePath = \dirname(\dirname($reflClass->getFileName())).'/Resources/views/Form'; $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; - $container->getDefinition('twig.cache_warmer')->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('fragment.handler')) { diff --git a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php index f23147440e..2b5f1d1a4e 100644 --- a/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php +++ b/src/Symfony/Bundle/TwigBundle/DependencyInjection/TwigExtension.php @@ -132,6 +132,11 @@ class TwigExtension extends Extension $container->getDefinition('twig')->replaceArgument(1, $config); + if (false === $config['cache']) { + $container->removeDefinition('twig.cache_warmer'); + $container->removeDefinition('twig.template_cache_warmer'); + } + $this->addClassesToCompile(array( 'Twig_Environment', 'Twig_Extension', From 90494c20cc1f029293d12b480c280cb056751a2b Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Wed, 5 Sep 2018 07:00:57 +0200 Subject: [PATCH 6/7] Revert "minor #28321 [Routing] Fixed the interface description of the url generator interface (Toflar)" This reverts commit 487f8acde58baf73c601f480b217488e549caca2, reversing changes made to cf359c2e79c85992bfcd3cd7588eb6cbea2a2f80. --- .../Component/Routing/Generator/UrlGeneratorInterface.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php index c7f4fca744..f501ebd9a8 100644 --- a/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php +++ b/src/Symfony/Component/Routing/Generator/UrlGeneratorInterface.php @@ -73,7 +73,7 @@ interface UrlGeneratorInterface extends RequestContextAwareInterface * @param mixed $parameters An array of parameters * @param int $referenceType The type of reference to be generated (one of the constants) * - * @return string|null The generated URL + * @return string The generated URL * * @throws RouteNotFoundException If the named route doesn't exist * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route From 992a174470fd557e1cddccd3a35447209602aea3 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 5 Sep 2018 13:23:46 +0200 Subject: [PATCH 7/7] [appveyor] fix --- .appveyor.yml | 2 +- .github/build-packages.php | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index 2e04c58473..8fb89ca158 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -56,7 +56,7 @@ install: - php composer.phar self-update - copy /Y .composer\* %APPDATA%\Composer\ - 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) - php composer.phar config platform.php 5.3.9 - php composer.phar update --no-progress --no-suggest --ansi diff --git a/.github/build-packages.php b/.github/build-packages.php index ab190c339a..b09cea2fe2 100644 --- a/.github/build-packages.php +++ b/.github/build-packages.php @@ -6,15 +6,20 @@ if (3 > $_SERVER['argc']) { } 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']; 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(); $flags = \PHP_VERSION_ID >= 50400 ? JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE : 0; 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) { exit($exitStatus); } @@ -74,7 +79,6 @@ if ($dirs) { 'type' => 'composer', '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); file_put_contents('composer.json', $json); }