From e98c5841da01cf3dca8747e19d76999955fd69fb Mon Sep 17 00:00:00 2001 From: Christophe Coevoet Date: Fri, 15 Jul 2016 19:07:32 +0200 Subject: [PATCH 1/5] Fix the DBAL session handler version check for Postgresql --- .../HttpFoundation/DbalSessionHandler.php | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php index 92c7b6bf40..0b86f3964b 100644 --- a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php +++ b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php @@ -13,6 +13,7 @@ namespace Symfony\Bridge\Doctrine\HttpFoundation; use Doctrine\DBAL\Connection; use Doctrine\DBAL\Driver\DriverException; +use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Platforms\SQLServer2008Platform; /** @@ -241,9 +242,30 @@ class DbalSessionHandler implements \SessionHandlerInterface "WHEN MATCHED THEN UPDATE SET $this->dataCol = :data, $this->timeCol = :time;"; case 'sqlite' === $platform: return "INSERT OR REPLACE INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time)"; - case 'postgresql' === $platform && version_compare($this->con->getServerVersion(), '9.5', '>='): + case 'postgresql' === $platform && version_compare($this->getServerVersion(), '9.5', '>='): return "INSERT INTO $this->table ($this->idCol, $this->dataCol, $this->timeCol) VALUES (:id, :data, :time) ". "ON CONFLICT ($this->idCol) DO UPDATE SET ($this->dataCol, $this->timeCol) = (EXCLUDED.$this->dataCol, EXCLUDED.$this->timeCol)"; } } + + private function getServerVersion() + { + $params = $this->con->getParams(); + + if (isset($params['serverVersion'])) { + return $params['serverVersion']; // Explicit platform version requested (supersedes auto-detection), so we respect it. + } + + $wrappedConnection = $this->con->getWrappedConnection(); + + if ($wrappedConnection instanceof ServerInfoAwareConnection) { + return $wrappedConnection->getServerVersion(); + } + + if ($wrappedConnection instanceof \PDO) { // Support DBAL 2.4 by accessing it directly when using PDO PgSQL + return $wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION); + } + + return ''; // If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks. + } } From 72db6e706847c3530f7086f7361b475fe4754649 Mon Sep 17 00:00:00 2001 From: Alexander Zhuravlev Date: Tue, 12 Jul 2016 14:13:14 +1200 Subject: [PATCH 2/5] Added class existence check if is_subclass_of() fails in compiler passes --- .../DependencyInjection/RegisterListenersPass.php | 6 +++++- .../HttpKernel/DependencyInjection/FragmentRendererPass.php | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php index ebfe435f87..326bfd184f 100644 --- a/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php +++ b/src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php @@ -97,9 +97,13 @@ class RegisterListenersPass implements CompilerPassInterface // We must assume that the class value has been correctly filled, even if the service is created by a factory $class = $container->getParameterBag()->resolveValue($def->getClass()); - $interface = 'Symfony\Component\EventDispatcher\EventSubscriberInterface'; + if (!is_subclass_of($class, $interface)) { + if (!class_exists($class, false)) { + throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + } + throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); } diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php index 3187e943c9..0c4cecef66 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/FragmentRendererPass.php @@ -54,7 +54,12 @@ class FragmentRendererPass implements CompilerPassInterface $class = $container->getParameterBag()->resolveValue($def->getClass()); $interface = 'Symfony\Component\HttpKernel\Fragment\FragmentRendererInterface'; + if (!is_subclass_of($class, $interface)) { + if (!class_exists($class, false)) { + throw new \InvalidArgumentException(sprintf('Class "%s" used for service "%s" cannot be found.', $class, $id)); + } + throw new \InvalidArgumentException(sprintf('Service "%s" must implement interface "%s".', $id, $interface)); } From 1376e14e7e4e763e2fb99efa2fa53ce753f5490c Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 18 Jul 2016 11:42:28 +0200 Subject: [PATCH 3/5] fixed CS --- .../Doctrine/HttpFoundation/DbalSessionHandler.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php index 0b86f3964b..d819ff0a6c 100644 --- a/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php +++ b/src/Symfony/Bridge/Doctrine/HttpFoundation/DbalSessionHandler.php @@ -252,8 +252,9 @@ class DbalSessionHandler implements \SessionHandlerInterface { $params = $this->con->getParams(); + // Explicit platform version requested (supersedes auto-detection), so we respect it. if (isset($params['serverVersion'])) { - return $params['serverVersion']; // Explicit platform version requested (supersedes auto-detection), so we respect it. + return $params['serverVersion']; } $wrappedConnection = $this->con->getWrappedConnection(); @@ -262,10 +263,12 @@ class DbalSessionHandler implements \SessionHandlerInterface return $wrappedConnection->getServerVersion(); } - if ($wrappedConnection instanceof \PDO) { // Support DBAL 2.4 by accessing it directly when using PDO PgSQL + // Support DBAL 2.4 by accessing it directly when using PDO PgSQL + if ($wrappedConnection instanceof \PDO) { return $wrappedConnection->getAttribute(\PDO::ATTR_SERVER_VERSION); } - return ''; // If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks. + // If we cannot guess the version, the empty string will mean we won't use the code for newer versions when doing version checks. + return ''; } } From d422939f6c3ae33435b0208ff363fac9d97ebf6b Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Mon, 18 Jul 2016 14:55:17 +0200 Subject: [PATCH 4/5] [VarDumper] Fix for 7.1 --- src/Symfony/Component/VarDumper/Cloner/VarCloner.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php index 48ef6daa7f..90c2454e66 100644 --- a/src/Symfony/Component/VarDumper/Cloner/VarCloner.php +++ b/src/Symfony/Component/VarDumper/Cloner/VarCloner.php @@ -315,7 +315,7 @@ class VarCloner extends AbstractCloner if (!empty($frame['line'])) { ob_start(); debug_zval_dump($obj); - self::$hashMask = substr(ob_get_clean(), 17); + self::$hashMask = (int) substr(ob_get_clean(), 17); } } From 07467ed3a3aca5bd8760060e4472cf519b7812c5 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Tue, 19 Jul 2016 08:52:31 +0200 Subject: [PATCH 5/5] Fix PHP 7.1 related failures --- .travis.yml | 10 +++++----- .../Fixtures/php/lazy_service_structure.txt | 4 ++-- src/Symfony/Bridge/Twig/composer.json | 2 +- src/Symfony/Component/Console/Helper/Table.php | 2 +- .../DependencyInjection/Tests/CrossCheckTest.php | 2 +- .../Component/DependencyInjection/composer.json | 2 +- src/Symfony/Component/Form/Util/OrderedHashMap.php | 2 +- .../Component/HttpKernel/CacheWarmer/CacheWarmer.php | 2 +- src/Symfony/Component/Validator/Constraints/File.php | 12 +++++++----- src/Symfony/Component/Validator/composer.json | 2 +- 10 files changed, 21 insertions(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 76e38fcb1b..500da3ee93 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,8 +26,9 @@ matrix: - php: 5.4 - php: 5.5 - php: 5.6 - env: deps=high - php: 7.0 + env: deps=high + - php: 7.1 env: deps=low fast_finish: true @@ -50,13 +51,12 @@ before_install: - if [[ ! $skip ]]; then echo session.gc_probability = 0 >> $INI_FILE; fi - if [[ ! $skip && $PHP = 5.* ]]; then echo extension = mongo.so >> $INI_FILE; fi - if [[ ! $skip && $PHP = 5.* ]]; then echo extension = memcache.so >> $INI_FILE; fi - - if [[ ! $skip && $PHP = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.10 && echo apc.enable_cli = 1 >> $INI_FILE); fi - - if [[ ! $skip && $PHP = 7.* ]]; then (echo yes | pecl install -f apcu-5.1.2 && echo apc.enable_cli = 1 >> $INI_FILE); fi + - if [[ ! $skip && $PHP = 5.* ]]; then (echo yes | pecl install -f apcu-4.0.11 && echo apc.enable_cli = 1 >> $INI_FILE); fi + - if [[ ! $skip && $PHP = 7.0 ]]; then (echo yes | pecl install -f apcu-5.1.5 && echo apc.enable_cli = 1 >> $INI_FILE); fi - if [[ ! $deps && $PHP = 5.* ]]; then (cd src/Symfony/Component/Debug/Resources/ext && phpize && ./configure && make && echo extension = $(pwd)/modules/symfony_debug.so >> $INI_FILE); fi - if [[ ! $skip && $PHP = 5.* ]]; then pecl install -f memcached-2.1.0; fi - if [[ ! $skip && ! $PHP = hhvm* ]]; then echo extension = ldap.so >> $INI_FILE; fi - - if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini; fi - - if [[ ! $skip ]]; then composer self-update --stable; fi + - if [[ ! $skip && ! $PHP = hhvm* ]]; then phpenv config-rm xdebug.ini || echo "xdebug not available"; fi - if [[ ! $skip ]]; then cp .composer/* ~/.composer/; fi - if [[ ! $skip ]]; then ./phpunit install; fi - if [[ ! $skip ]]; then export PHPUNIT=$(readlink -f ./phpunit); fi diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt index e2775cfa5f..a0e3642f49 100644 --- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt +++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/Fixtures/php/lazy_service_structure.txt @@ -23,5 +23,5 @@ class ProjectServiceContainer extends Container } } -class stdClass_%s extends \stdClass implements \ProxyManager\%s -{%a}%A \ No newline at end of file +class stdClass_%s extends %SstdClass implements \ProxyManager\%s +{%a}%A diff --git a/src/Symfony/Bridge/Twig/composer.json b/src/Symfony/Bridge/Twig/composer.json index 1c0cc2f105..f62708cf97 100644 --- a/src/Symfony/Bridge/Twig/composer.json +++ b/src/Symfony/Bridge/Twig/composer.json @@ -33,7 +33,7 @@ "symfony/security-acl": "~2.6", "symfony/stopwatch": "~2.2", "symfony/console": "~2.7", - "symfony/var-dumper": "~2.6", + "symfony/var-dumper": "~2.7.16|~2.8.9", "symfony/expression-language": "~2.4" }, "suggest": { diff --git a/src/Symfony/Component/Console/Helper/Table.php b/src/Symfony/Component/Console/Helper/Table.php index c4e24a63d9..b1111fec65 100644 --- a/src/Symfony/Component/Console/Helper/Table.php +++ b/src/Symfony/Component/Console/Helper/Table.php @@ -396,7 +396,7 @@ class Table } // create a two dimensional array (rowspan x colspan) - $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, ''), $unmergedRows); + $unmergedRows = array_replace_recursive(array_fill($line + 1, $nbLines, array()), $unmergedRows); foreach ($unmergedRows as $unmergedRowKey => $unmergedRow) { $value = isset($lines[$unmergedRowKey - $line]) ? $lines[$unmergedRowKey - $line] : ''; $unmergedRows[$unmergedRowKey][$column] = new TableCell($value, array('colspan' => $cell->getColspan())); diff --git a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php index 7905e7f3c6..423c5db2ec 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/CrossCheckTest.php @@ -34,7 +34,7 @@ class CrossCheckTest extends \PHPUnit_Framework_TestCase $loaderClass = 'Symfony\\Component\\DependencyInjection\\Loader\\'.ucfirst($type).'FileLoader'; $dumperClass = 'Symfony\\Component\\DependencyInjection\\Dumper\\'.ucfirst($type).'Dumper'; - $tmp = tempnam('sf_service_container', 'sf'); + $tmp = tempnam(sys_get_temp_dir(), 'sf'); file_put_contents($tmp, file_get_contents(self::$fixturesPath.'/'.$type.'/'.$fixture)); diff --git a/src/Symfony/Component/DependencyInjection/composer.json b/src/Symfony/Component/DependencyInjection/composer.json index d42c7a0c6c..9c12d111f2 100644 --- a/src/Symfony/Component/DependencyInjection/composer.json +++ b/src/Symfony/Component/DependencyInjection/composer.json @@ -19,7 +19,7 @@ "php": ">=5.3.9" }, "require-dev": { - "symfony/yaml": "~2.1", + "symfony/yaml": "~2.3.42|~2.7.14|~2.8.7", "symfony/config": "~2.2", "symfony/expression-language": "~2.6" }, diff --git a/src/Symfony/Component/Form/Util/OrderedHashMap.php b/src/Symfony/Component/Form/Util/OrderedHashMap.php index a25df3214f..78687032fe 100644 --- a/src/Symfony/Component/Form/Util/OrderedHashMap.php +++ b/src/Symfony/Component/Form/Util/OrderedHashMap.php @@ -130,7 +130,7 @@ class OrderedHashMap implements \ArrayAccess, \IteratorAggregate, \Countable ? 0 // Imitate PHP's behavior of generating a key that equals // the highest existing integer key + 1 - : max($this->orderedKeys) + 1; + : 1 + (int) max($this->orderedKeys); } $this->orderedKeys[] = $key; diff --git a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php index 948b3ffd14..dba35a639a 100644 --- a/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php +++ b/src/Symfony/Component/HttpKernel/CacheWarmer/CacheWarmer.php @@ -20,7 +20,7 @@ abstract class CacheWarmer implements CacheWarmerInterface { protected function writeCacheFile($file, $content) { - $tmpFile = tempnam(dirname($file), basename($file)); + $tmpFile = @tempnam(dirname($file), basename($file)); if (false !== @file_put_contents($tmpFile, $content) && @rename($tmpFile, $file)) { @chmod($file, 0666 & ~umask()); diff --git a/src/Symfony/Component/Validator/Constraints/File.php b/src/Symfony/Component/Validator/Constraints/File.php index de9fc00763..b9c06bfdb1 100644 --- a/src/Symfony/Component/Validator/Constraints/File.php +++ b/src/Symfony/Component/Validator/Constraints/File.php @@ -88,20 +88,22 @@ class File extends Constraint private function normalizeBinaryFormat($maxSize) { + $sizeInt = (int) $maxSize; + if (ctype_digit((string) $maxSize)) { - $this->maxSize = (int) $maxSize; + $this->maxSize = $sizeInt; $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; } elseif (preg_match('/^\d++k$/i', $maxSize)) { - $this->maxSize = $maxSize * 1000; + $this->maxSize = $sizeInt * 1000; $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; } elseif (preg_match('/^\d++M$/i', $maxSize)) { - $this->maxSize = $maxSize * 1000000; + $this->maxSize = $sizeInt * 1000000; $this->binaryFormat = null === $this->binaryFormat ? false : $this->binaryFormat; } elseif (preg_match('/^\d++Ki$/i', $maxSize)) { - $this->maxSize = $maxSize << 10; + $this->maxSize = $sizeInt << 10; $this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat; } elseif (preg_match('/^\d++Mi$/i', $maxSize)) { - $this->maxSize = $maxSize << 20; + $this->maxSize = $sizeInt << 20; $this->binaryFormat = null === $this->binaryFormat ? true : $this->binaryFormat; } else { throw new ConstraintDefinitionException(sprintf('"%s" is not a valid maximum size', $this->maxSize)); diff --git a/src/Symfony/Component/Validator/composer.json b/src/Symfony/Component/Validator/composer.json index c74b46e68c..96563e4fa4 100644 --- a/src/Symfony/Component/Validator/composer.json +++ b/src/Symfony/Component/Validator/composer.json @@ -21,7 +21,7 @@ }, "require-dev": { "doctrine/common": "~2.3", - "symfony/http-foundation": "~2.1", + "symfony/http-foundation": "~2.3", "symfony/intl": "~2.7.4|~2.8", "symfony/yaml": "~2.0,>=2.0.5", "symfony/config": "~2.2",