diff --git a/composer.json b/composer.json index 848f0521d..d930d27f5 100644 --- a/composer.json +++ b/composer.json @@ -8,7 +8,7 @@ "classmap-authoritative": true }, "require": { - "doctrine/dbal": "2.5.4", + "doctrine/dbal": "2.5.5", "mcnetic/zipstreamer": "^1.0", "phpseclib/phpseclib": "2.0.3", "rackspace/php-opencloud": "v1.9.2", diff --git a/composer.lock b/composer.lock index c6f7b7e22..cb9405b3c 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "223aeddebd1fad634a94f284a0c4d2e2", - "content-hash": "64913ca1f9ccf0088f4b087d740c7988", + "hash": "41a7cb3cbc77445056509eacd88175bc", + "content-hash": "9269dbe6f0b5171867d083022b51c380", "packages": [ { "name": "bantu/ini-get-wrapper", @@ -149,33 +149,33 @@ }, { "name": "doctrine/cache", - "version": "v1.5.4", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/doctrine/cache.git", - "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136" + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/47cdc76ceb95cc591d9c79a36dc3794975b5d136", - "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136", + "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", "shasum": "" }, "require": { - "php": ">=5.3.2" + "php": "~5.5|~7.0" }, "conflict": { "doctrine/common": ">2.2,<2.4" }, "require-dev": { - "phpunit/phpunit": ">=3.7", + "phpunit/phpunit": "~4.8|~5.0", "predis/predis": "~1.0", "satooshi/php-coveralls": "~0.6" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "1.5.x-dev" + "dev-master": "1.6.x-dev" } }, "autoload": { @@ -215,7 +215,7 @@ "cache", "caching" ], - "time": "2015-12-19 05:03:47" + "time": "2015-12-31 16:37:02" }, { "name": "doctrine/collections", @@ -285,16 +285,16 @@ }, { "name": "doctrine/common", - "version": "v2.5.3", + "version": "v2.6.1", "source": { "type": "git", "url": "https://github.com/doctrine/common.git", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e" + "reference": "a579557bc689580c19fee4e27487a67fe60defc0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/10f1f19651343f87573129ca970aef1a47a6f29e", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e", + "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0", "shasum": "" }, "require": { @@ -303,20 +303,20 @@ "doctrine/collections": "1.*", "doctrine/inflector": "1.*", "doctrine/lexer": "1.*", - "php": ">=5.3.2" + "php": "~5.5|~7.0" }, "require-dev": { - "phpunit/phpunit": "~3.7" + "phpunit/phpunit": "~4.8|~5.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "2.5.x-dev" + "dev-master": "2.7.x-dev" } }, "autoload": { - "psr-0": { - "Doctrine\\Common\\": "lib/" + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" } }, "notification-url": "https://packagist.org/downloads/", @@ -354,20 +354,20 @@ "persistence", "spl" ], - "time": "2015-12-25 13:10:16" + "time": "2015-12-25 13:18:31" }, { "name": "doctrine/dbal", - "version": "v2.5.4", + "version": "v2.5.5", "source": { "type": "git", "url": "https://github.com/doctrine/dbal.git", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769" + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/abbdfd1cff43a7b99d027af3be709bc8fc7d4769", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", "shasum": "" }, "require": { @@ -376,7 +376,7 @@ }, "require-dev": { "phpunit/phpunit": "4.*", - "symfony/console": "2.*" + "symfony/console": "2.*||^3.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." @@ -425,7 +425,7 @@ "persistence", "queryobject" ], - "time": "2016-01-05 22:11:12" + "time": "2016-09-09 19:13:33" }, { "name": "doctrine/inflector", diff --git a/composer/autoload_classmap.php b/composer/autoload_classmap.php index 6c46bd88e..14ebb5c50 100644 --- a/composer/autoload_classmap.php +++ b/composer/autoload_classmap.php @@ -89,6 +89,7 @@ 'Doctrine\\Common\\Annotations\\SimpleAnnotationReader' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php', 'Doctrine\\Common\\Annotations\\TokenParser' => $vendorDir . '/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php', 'Doctrine\\Common\\Cache\\ApcCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php', + 'Doctrine\\Common\\Cache\\ApcuCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php', 'Doctrine\\Common\\Cache\\ArrayCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php', 'Doctrine\\Common\\Cache\\Cache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php', 'Doctrine\\Common\\Cache\\CacheProvider' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php', @@ -102,6 +103,7 @@ 'Doctrine\\Common\\Cache\\MemcachedCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php', 'Doctrine\\Common\\Cache\\MongoDBCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php', 'Doctrine\\Common\\Cache\\MultiGetCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php', + 'Doctrine\\Common\\Cache\\MultiPutCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php', 'Doctrine\\Common\\Cache\\PhpFileCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php', 'Doctrine\\Common\\Cache\\PredisCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php', 'Doctrine\\Common\\Cache\\RedisCache' => $vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php', diff --git a/composer/autoload_namespaces.php b/composer/autoload_namespaces.php index 375abc749..7f7685a8b 100644 --- a/composer/autoload_namespaces.php +++ b/composer/autoload_namespaces.php @@ -18,7 +18,6 @@ 'Doctrine\\Common\\Inflector\\' => array($vendorDir . '/doctrine/inflector/lib'), 'Doctrine\\Common\\Collections\\' => array($vendorDir . '/doctrine/collections/lib'), 'Doctrine\\Common\\Annotations\\' => array($vendorDir . '/doctrine/annotations/lib'), - 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib'), 'Console' => array($vendorDir . '/pear/console_getopt'), 'Archive_Tar' => array($vendorDir . '/pear/archive_tar'), '' => array($vendorDir . '/pear/pear-core-minimal/src'), diff --git a/composer/autoload_psr4.php b/composer/autoload_psr4.php index 98ad467c8..e7c52b1e8 100644 --- a/composer/autoload_psr4.php +++ b/composer/autoload_psr4.php @@ -39,4 +39,5 @@ 'GuzzleHttp\\Ring\\' => array($vendorDir . '/guzzlehttp/ringphp/src'), 'GuzzleHttp\\' => array($vendorDir . '/guzzlehttp/guzzle/src'), 'Doctrine\\Common\\Cache\\' => array($vendorDir . '/doctrine/cache/lib/Doctrine/Common/Cache'), + 'Doctrine\\Common\\' => array($vendorDir . '/doctrine/common/lib/Doctrine/Common'), ); diff --git a/composer/autoload_static.php b/composer/autoload_static.php index 426c872e2..39037fb0d 100644 --- a/composer/autoload_static.php +++ b/composer/autoload_static.php @@ -86,6 +86,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'D' => array ( 'Doctrine\\Common\\Cache\\' => 22, + 'Doctrine\\Common\\' => 16, ), ); @@ -223,6 +224,10 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 array ( 0 => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache', ), + 'Doctrine\\Common\\' => + array ( + 0 => __DIR__ . '/..' . '/doctrine/common/lib/Doctrine/Common', + ), ); public static $prefixesPsr0 = array ( @@ -286,10 +291,6 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 array ( 0 => __DIR__ . '/..' . '/doctrine/annotations/lib', ), - 'Doctrine\\Common\\' => - array ( - 0 => __DIR__ . '/..' . '/doctrine/common/lib', - ), ), 'C' => array ( @@ -395,6 +396,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\Common\\Annotations\\SimpleAnnotationReader' => __DIR__ . '/..' . '/doctrine/annotations/lib/Doctrine/Common/Annotations/SimpleAnnotationReader.php', 'Doctrine\\Common\\Annotations\\TokenParser' => __DIR__ . '/..' . '/doctrine/annotations/lib/Doctrine/Common/Annotations/TokenParser.php', 'Doctrine\\Common\\Cache\\ApcCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php', + 'Doctrine\\Common\\Cache\\ApcuCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/ApcuCache.php', 'Doctrine\\Common\\Cache\\ArrayCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php', 'Doctrine\\Common\\Cache\\Cache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/Cache.php', 'Doctrine\\Common\\Cache\\CacheProvider' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php', @@ -408,6 +410,7 @@ class ComposerStaticInit2f23f73bc0cc116b4b1eee1521aa8652 'Doctrine\\Common\\Cache\\MemcachedCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php', 'Doctrine\\Common\\Cache\\MongoDBCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/MongoDBCache.php', 'Doctrine\\Common\\Cache\\MultiGetCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/MultiGetCache.php', + 'Doctrine\\Common\\Cache\\MultiPutCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/MultiPutCache.php', 'Doctrine\\Common\\Cache\\PhpFileCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/PhpFileCache.php', 'Doctrine\\Common\\Cache\\PredisCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php', 'Doctrine\\Common\\Cache\\RedisCache' => __DIR__ . '/..' . '/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php', diff --git a/composer/installed.json b/composer/installed.json index 42a82adae..5d74c0941 100644 --- a/composer/installed.json +++ b/composer/installed.json @@ -1697,226 +1697,6 @@ "zip" ] }, - { - "name": "doctrine/cache", - "version": "v1.5.4", - "version_normalized": "1.5.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/cache.git", - "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/cache/zipball/47cdc76ceb95cc591d9c79a36dc3794975b5d136", - "reference": "47cdc76ceb95cc591d9c79a36dc3794975b5d136", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "conflict": { - "doctrine/common": ">2.2,<2.4" - }, - "require-dev": { - "phpunit/phpunit": ">=3.7", - "predis/predis": "~1.0", - "satooshi/php-coveralls": "~0.6" - }, - "time": "2015-12-19 05:03:47", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.5.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-4": { - "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Caching library offering an object-oriented API for many cache backends", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "cache", - "caching" - ] - }, - { - "name": "doctrine/common", - "version": "v2.5.3", - "version_normalized": "2.5.3.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/common.git", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/common/zipball/10f1f19651343f87573129ca970aef1a47a6f29e", - "reference": "10f1f19651343f87573129ca970aef1a47a6f29e", - "shasum": "" - }, - "require": { - "doctrine/annotations": "1.*", - "doctrine/cache": "1.*", - "doctrine/collections": "1.*", - "doctrine/inflector": "1.*", - "doctrine/lexer": "1.*", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~3.7" - }, - "time": "2015-12-25 13:10:16", - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\Common\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - }, - { - "name": "Johannes Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Common Library for Doctrine projects", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "annotations", - "collections", - "eventmanager", - "persistence", - "spl" - ] - }, - { - "name": "doctrine/dbal", - "version": "v2.5.4", - "version_normalized": "2.5.4.0", - "source": { - "type": "git", - "url": "https://github.com/doctrine/dbal.git", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/dbal/zipball/abbdfd1cff43a7b99d027af3be709bc8fc7d4769", - "reference": "abbdfd1cff43a7b99d027af3be709bc8fc7d4769", - "shasum": "" - }, - "require": { - "doctrine/common": ">=2.4,<2.7-dev", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "4.*", - "symfony/console": "2.*" - }, - "suggest": { - "symfony/console": "For helpful console commands such as SQL execution and import of files." - }, - "time": "2016-01-05 22:11:12", - "bin": [ - "bin/doctrine-dbal" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5.x-dev" - } - }, - "installation-source": "dist", - "autoload": { - "psr-0": { - "Doctrine\\DBAL\\": "lib/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Roman Borschel", - "email": "roman@code-factory.org" - }, - { - "name": "Benjamin Eberlei", - "email": "kontakt@beberlei.de" - }, - { - "name": "Guilherme Blanco", - "email": "guilhermeblanco@gmail.com" - }, - { - "name": "Jonathan Wage", - "email": "jonwage@gmail.com" - } - ], - "description": "Database Abstraction Layer", - "homepage": "http://www.doctrine-project.org", - "keywords": [ - "database", - "dbal", - "persistence", - "queryobject" - ] - }, { "name": "sabre/uri", "version": "1.1.0", @@ -2899,5 +2679,225 @@ } ], "description": "Automatic BASH completion for Symfony Console Component based applications." + }, + { + "name": "doctrine/cache", + "version": "v1.6.0", + "version_normalized": "1.6.0.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/cache.git", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/cache/zipball/f8af318d14bdb0eff0336795b428b547bd39ccb6", + "reference": "f8af318d14bdb0eff0336795b428b547bd39ccb6", + "shasum": "" + }, + "require": { + "php": "~5.5|~7.0" + }, + "conflict": { + "doctrine/common": ">2.2,<2.4" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0", + "predis/predis": "~1.0", + "satooshi/php-coveralls": "~0.6" + }, + "time": "2015-12-31 16:37:02", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.6.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Doctrine\\Common\\Cache\\": "lib/Doctrine/Common/Cache" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Caching library offering an object-oriented API for many cache backends", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "cache", + "caching" + ] + }, + { + "name": "doctrine/common", + "version": "v2.6.1", + "version_normalized": "2.6.1.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/common.git", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/common/zipball/a579557bc689580c19fee4e27487a67fe60defc0", + "reference": "a579557bc689580c19fee4e27487a67fe60defc0", + "shasum": "" + }, + "require": { + "doctrine/annotations": "1.*", + "doctrine/cache": "1.*", + "doctrine/collections": "1.*", + "doctrine/inflector": "1.*", + "doctrine/lexer": "1.*", + "php": "~5.5|~7.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.8|~5.0" + }, + "time": "2015-12-25 13:18:31", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.7.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Doctrine\\Common\\": "lib/Doctrine/Common" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "Common Library for Doctrine projects", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "annotations", + "collections", + "eventmanager", + "persistence", + "spl" + ] + }, + { + "name": "doctrine/dbal", + "version": "v2.5.5", + "version_normalized": "2.5.5.0", + "source": { + "type": "git", + "url": "https://github.com/doctrine/dbal.git", + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/dbal/zipball/9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", + "reference": "9f8c05cd5225a320d56d4bfdb4772f10d045a0c9", + "shasum": "" + }, + "require": { + "doctrine/common": ">=2.4,<2.7-dev", + "php": ">=5.3.2" + }, + "require-dev": { + "phpunit/phpunit": "4.*", + "symfony/console": "2.*||^3.0" + }, + "suggest": { + "symfony/console": "For helpful console commands such as SQL execution and import of files." + }, + "time": "2016-09-09 19:13:33", + "bin": [ + "bin/doctrine-dbal" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.5.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Doctrine\\DBAL\\": "lib/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + } + ], + "description": "Database Abstraction Layer", + "homepage": "http://www.doctrine-project.org", + "keywords": [ + "database", + "dbal", + "persistence", + "queryobject" + ] } ] diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php index 036583ee8..7c617f33d 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/ApcCache.php @@ -22,13 +22,14 @@ /** * APC cache provider. * - * @link www.doctrine-project.org - * @since 2.0 - * @author Benjamin Eberlei - * @author Guilherme Blanco - * @author Jonathan Wage - * @author Roman Borschel - * @author David Abdemoulaie + * @link www.doctrine-project.org + * @deprecated since version 1.6, use ApcuCache instead + * @since 2.0 + * @author Benjamin Eberlei + * @author Guilherme Blanco + * @author Jonathan Wage + * @author Roman Borschel + * @author David Abdemoulaie */ class ApcCache extends CacheProvider { @@ -81,6 +82,16 @@ protected function doFetchMultiple(array $keys) return apc_fetch($keys); } + /** + * {@inheritdoc} + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + $result = apc_store($keysAndValues, null, $lifetime); + + return empty($result); + } + /** * {@inheritdoc} */ diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php index 31a072901..6610cc217 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/ArrayCache.php @@ -33,16 +33,47 @@ class ArrayCache extends CacheProvider { /** - * @var array $data + * @var array[] $data each element being a tuple of [$data, $expiration], where the expiration is int|bool */ - private $data = array(); + private $data = []; + + /** + * @var int + */ + private $hitsCount = 0; + + /** + * @var int + */ + private $missesCount = 0; + + /** + * @var int + */ + private $upTime; + + /** + * {@inheritdoc} + */ + public function __construct() + { + $this->upTime = time(); + } /** * {@inheritdoc} */ protected function doFetch($id) { - return $this->doContains($id) ? $this->data[$id] : false; + if (! $this->doContains($id)) { + $this->missesCount += 1; + + return false; + } + + $this->hitsCount += 1; + + return $this->data[$id][0]; } /** @@ -50,8 +81,19 @@ protected function doFetch($id) */ protected function doContains($id) { - // isset() is required for performance optimizations, to avoid unnecessary function calls to array_key_exists. - return isset($this->data[$id]) || array_key_exists($id, $this->data); + if (! isset($this->data[$id])) { + return false; + } + + $expiration = $this->data[$id][1]; + + if ($expiration && $expiration < time()) { + $this->doDelete($id); + + return false; + } + + return true; } /** @@ -59,7 +101,7 @@ protected function doContains($id) */ protected function doSave($id, $data, $lifeTime = 0) { - $this->data[$id] = $data; + $this->data[$id] = [$data, $lifeTime ? time() + $lifeTime : false]; return true; } @@ -79,7 +121,7 @@ protected function doDelete($id) */ protected function doFlush() { - $this->data = array(); + $this->data = []; return true; } @@ -89,6 +131,12 @@ protected function doFlush() */ protected function doGetStats() { - return null; + return [ + Cache::STATS_HITS => $this->hitsCount, + Cache::STATS_MISSES => $this->missesCount, + Cache::STATS_UPTIME => $this->upTime, + Cache::STATS_MEMORY_USAGE => null, + Cache::STATS_MEMORY_AVAILABLE => null, + ]; } } diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php b/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php index b1d4d67ca..9f579237a 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/CacheProvider.php @@ -29,7 +29,7 @@ * @author Roman Borschel * @author Fabio B. Silva */ -abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache +abstract class CacheProvider implements Cache, FlushableCache, ClearableCache, MultiGetCache, MultiPutCache { const DOCTRINE_NAMESPACE_CACHEKEY = 'DoctrineNamespaceCacheKey[%s]'; @@ -103,6 +103,19 @@ public function fetchMultiple(array $keys) return $foundItems; } + /** + * {@inheritdoc} + */ + public function saveMultiple(array $keysAndValues, $lifetime = 0) + { + $namespacedKeysAndValues = array(); + foreach ($keysAndValues as $key => $value) { + $namespacedKeysAndValues[$this->getNamespacedId($key)] = $value; + } + + return $this->doSaveMultiple($namespacedKeysAndValues, $lifetime); + } + /** * {@inheritdoc} */ @@ -238,6 +251,28 @@ abstract protected function doFetch($id); */ abstract protected function doContains($id); + /** + * Default implementation of doSaveMultiple. Each driver that supports multi-put should override it. + * + * @param array $keysAndValues Array of keys and values to save in cache + * @param int $lifetime The lifetime. If != 0, sets a specific lifetime for these + * cache entries (0 => infinite lifeTime). + * + * @return bool TRUE if the operation was successful, FALSE if it wasn't. + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + $success = true; + + foreach ($keysAndValues as $key => $value) { + if (!$this->doSave($key, $value, $lifetime)) { + $success = false; + } + } + + return $success; + } + /** * Puts data into the cache. * diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php index deebe5abe..408e452b9 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/MemcachedCache.php @@ -77,6 +77,18 @@ protected function doFetchMultiple(array $keys) return $this->memcached->getMulti($keys); } + /** + * {@inheritdoc} + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + if ($lifetime > 30 * 24 * 3600) { + $lifetime = time() + $lifetime; + } + + return $this->memcached->setMulti($keysAndValues, null, $lifetime); + } + /** * {@inheritdoc} */ diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php index e7da2a658..980e26606 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/PredisCache.php @@ -49,6 +49,34 @@ protected function doFetchMultiple(array $keys) return array_map('unserialize', array_filter(array_combine($keys, $fetchedItems))); } + /** + * {@inheritdoc} + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + if ($lifetime) { + $success = true; + + // Keys have lifetime, use SETEX for each of them + foreach ($keysAndValues as $key => $value) { + $response = $this->client->setex($key, $lifetime, serialize($value)); + + if ((string) $response != 'OK') { + $success = false; + } + } + + return $success; + } + + // No lifetime, use MSET + $response = $this->client->mset(array_map(function ($value) { + return serialize($value); + }, $keysAndValues)); + + return (string) $response == 'OK'; + } + /** * {@inheritdoc} */ diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php index 9b182c9d6..a4f0e6e41 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/RedisCache.php @@ -85,6 +85,28 @@ protected function doFetchMultiple(array $keys) return $foundItems; } + /** + * {@inheritdoc} + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + if ($lifetime) { + $success = true; + + // Keys have lifetime, use SETEX for each of them + foreach ($keysAndValues as $key => $value) { + if (!$this->redis->setex($key, $lifetime, $value)) { + $success = false; + } + } + + return $success; + } + + // No lifetime, use MSET + return (bool) $this->redis->mset($keysAndValues); + } + /** * {@inheritdoc} */ diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/Version.php b/doctrine/cache/lib/Doctrine/Common/Cache/Version.php index ac452385f..eff259ae3 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/Version.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/Version.php @@ -21,5 +21,5 @@ class Version { - const VERSION = '1.5.4'; + const VERSION = '1.6.0'; } diff --git a/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php b/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php index 6f563aa89..8a250b29a 100644 --- a/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php +++ b/doctrine/cache/lib/Doctrine/Common/Cache/WinCacheCache.php @@ -80,6 +80,16 @@ protected function doFetchMultiple(array $keys) return wincache_ucache_get($keys); } + /** + * {@inheritdoc} + */ + protected function doSaveMultiple(array $keysAndValues, $lifetime = 0) + { + $result = wincache_ucache_set($keysAndValues, null, $lifetime); + + return empty($result); + } + /** * {@inheritdoc} */ diff --git a/doctrine/common/.gitignore b/doctrine/common/.gitignore deleted file mode 100644 index b15c686b4..000000000 --- a/doctrine/common/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -build/ -logs/ -reports/ -dist/ -tests/Doctrine/Tests/Common/Proxy/generated/ -vendor/ -.idea -composer.lock -doctrine-common-*.tar -doctrine-common-*.tar.gz diff --git a/doctrine/common/.gitmodules b/doctrine/common/.gitmodules deleted file mode 100644 index 51f084351..000000000 --- a/doctrine/common/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/vendor/doctrine-build-common"] - path = lib/vendor/doctrine-build-common - url = git://github.com/doctrine/doctrine-build-common.git diff --git a/doctrine/common/LICENSE b/doctrine/common/LICENSE index 4a91f0bf2..8c38cc1bc 100644 --- a/doctrine/common/LICENSE +++ b/doctrine/common/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2006-2012 Doctrine Project +Copyright (c) 2006-2015 Doctrine Project Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in diff --git a/doctrine/common/build.properties b/doctrine/common/build.properties deleted file mode 100644 index ef51d207f..000000000 --- a/doctrine/common/build.properties +++ /dev/null @@ -1,3 +0,0 @@ -# Version class and file -project.version_class = Doctrine\\Common\\Version -project.version_file = lib/Doctrine/Common/Version.php diff --git a/doctrine/common/build.xml b/doctrine/common/build.xml deleted file mode 100644 index 429b7688f..000000000 --- a/doctrine/common/build.xml +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/doctrine/common/lib/Doctrine/Common/ClassLoader.php b/doctrine/common/lib/Doctrine/Common/ClassLoader.php index d65b9a631..78eeb35d3 100644 --- a/doctrine/common/lib/Doctrine/Common/ClassLoader.php +++ b/doctrine/common/lib/Doctrine/Common/ClassLoader.php @@ -153,7 +153,7 @@ public function getFileExtension() */ public function register() { - spl_autoload_register(array($this, 'loadClass')); + spl_autoload_register([$this, 'loadClass']); } /** @@ -163,7 +163,7 @@ public function register() */ public function unregister() { - spl_autoload_unregister(array($this, 'loadClass')); + spl_autoload_unregister([$this, 'loadClass']); } /** @@ -275,6 +275,6 @@ private static function typeExists($type, $autoload = false) { return class_exists($type, $autoload) || interface_exists($type, $autoload) - || (function_exists('trait_exists') && trait_exists($type, $autoload)); + || trait_exists($type, $autoload); } } diff --git a/doctrine/common/lib/Doctrine/Common/EventManager.php b/doctrine/common/lib/Doctrine/Common/EventManager.php index 69eb17ec6..0ee04a15a 100644 --- a/doctrine/common/lib/Doctrine/Common/EventManager.php +++ b/doctrine/common/lib/Doctrine/Common/EventManager.php @@ -38,7 +38,7 @@ class EventManager * * @var array */ - private $_listeners = array(); + private $_listeners = []; /** * Dispatches an event to all registered listeners. diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php b/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php index 5334d2ae1..12de46294 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/AbstractManagerRegistry.php @@ -141,7 +141,7 @@ public function getConnectionNames() */ public function getConnections() { - $connections = array(); + $connections = []; foreach ($this->connections as $name => $id) { $connections[$name] = $this->getService($id); } @@ -226,7 +226,7 @@ public function getManagerNames() */ public function getManagers() { - $dms = array(); + $dms = []; foreach ($this->managers as $name => $id) { $dms[$name] = $this->getService($id); } diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php index 404fea91a..586b2da2c 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php @@ -53,7 +53,7 @@ abstract class AbstractClassMetadataFactory implements ClassMetadataFactory /** * @var ClassMetadata[] */ - private $loadedMetadata = array(); + private $loadedMetadata = []; /** * @var bool @@ -110,7 +110,7 @@ public function getAllMetadata() } $driver = $this->getDriver(); - $metadata = array(); + $metadata = []; foreach ($driver->getAllClassNames() as $className) { $metadata[] = $this->getMetadataFor($className); } @@ -277,7 +277,7 @@ public function setMetadataFor($className, $class) protected function getParentClasses($name) { // Collect parent classes, ignoring transient (not-mapped) classes. - $parentClasses = array(); + $parentClasses = []; foreach (array_reverse($this->getReflectionService()->getParentClasses($name)) as $parentClass) { if ( ! $this->getDriver()->isTransient($parentClass)) { $parentClasses[] = $parentClass; @@ -306,7 +306,7 @@ protected function loadMetadata($name) $this->initialize(); } - $loaded = array(); + $loaded = []; $parentClasses = $this->getParentClasses($name); $parentClasses[] = $name; @@ -314,7 +314,7 @@ protected function loadMetadata($name) // Move down the hierarchy of parent classes, starting from the topmost class $parent = null; $rootEntityFound = false; - $visited = array(); + $visited = []; $reflService = $this->getReflectionService(); foreach ($parentClasses as $className) { if (isset($this->loadedMetadata[$className])) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php index 8bb574d92..deb82c0c9 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php @@ -45,14 +45,14 @@ abstract class AnnotationDriver implements MappingDriver * * @var array */ - protected $paths = array(); + protected $paths = []; /** * The paths excluded from path where to look for mapping files. * * @var array */ - protected $excludePaths = array(); + protected $excludePaths = []; /** * The file extension of mapping documents. @@ -73,7 +73,7 @@ abstract class AnnotationDriver implements MappingDriver * * @var array */ - protected $entityAnnotationClasses = array(); + protected $entityAnnotationClasses = []; /** * Initializes a new AnnotationDriver that uses the given AnnotationReader for reading @@ -200,8 +200,8 @@ public function getAllClassNames() throw MappingException::pathRequired(); } - $classes = array(); - $includedFiles = array(); + $classes = []; + $includedFiles = []; foreach ($this->paths as $path) { if ( ! is_dir($path)) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php index 58a740b57..6ed7f6d0d 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/DefaultFileLocator.php @@ -37,7 +37,7 @@ class DefaultFileLocator implements FileLocator * * @var array */ - protected $paths = array(); + protected $paths = []; /** * The file extension of mapping documents. @@ -125,7 +125,7 @@ public function findMappingFile($className) */ public function getAllClassNames($globalBasename) { - $classes = array(); + $classes = []; if ($this->paths) { foreach ($this->paths as $path) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php index ccc64faf8..dc799d5cc 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/FileDriver.php @@ -145,11 +145,14 @@ public function getAllClassNames() $this->initialize(); } - $classNames = (array)$this->locator->getAllClassNames($this->globalBasename); - if ($this->classCache) { - $classNames = array_merge(array_keys($this->classCache), $classNames); + if (! $this->classCache) { + return (array) $this->locator->getAllClassNames($this->globalBasename); } - return $classNames; + + return array_merge( + array_keys($this->classCache), + (array) $this->locator->getAllClassNames($this->globalBasename) + ); } /** @@ -175,7 +178,7 @@ abstract protected function loadMappingFile($file); */ protected function initialize() { - $this->classCache = array(); + $this->classCache = []; if (null !== $this->globalBasename) { foreach ($this->locator->getPaths() as $path) { $file = $path.'/'.$this->globalBasename.$this->locator->getFileExtension(); diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php index 26a9f3e2c..50d9785bc 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/MappingDriverChain.php @@ -39,12 +39,12 @@ class MappingDriverChain implements MappingDriver * * @var MappingDriver|null */ - private $defaultDriver = null; + private $defaultDriver; /** * @var array */ - private $drivers = array(); + private $drivers = []; /** * Gets the default driver. @@ -117,8 +117,8 @@ public function loadMetadataForClass($className, ClassMetadata $metadata) */ public function getAllClassNames() { - $classNames = array(); - $driverClasses = array(); + $classNames = []; + $driverClasses = []; /* @var $driver MappingDriver */ foreach ($this->drivers AS $namespace => $driver) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php index 6df54b0f7..efffa6aa4 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/PHPDriver.php @@ -44,8 +44,7 @@ class PHPDriver extends FileDriver */ public function __construct($locator, $fileExtension = null) { - $fileExtension = ".php"; - parent::__construct($locator, $fileExtension); + parent::__construct($locator, '.php'); } /** @@ -54,6 +53,7 @@ public function __construct($locator, $fileExtension = null) public function loadMetadataForClass($className, ClassMetadata $metadata) { $this->metadata = $metadata; + $this->loadMappingFile($this->locator->findMappingFile($className)); } @@ -65,6 +65,6 @@ protected function loadMappingFile($file) $metadata = $this->metadata; include $file; - return array($metadata->getName() => $metadata); + return [$metadata->getName() => $metadata]; } } diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php index df8f47700..8e37e5a7a 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/StaticPHPDriver.php @@ -40,7 +40,7 @@ class StaticPHPDriver implements MappingDriver * * @var array */ - private $paths = array(); + private $paths = []; /** * Map of all class names. @@ -93,8 +93,8 @@ public function getAllClassNames() throw MappingException::pathRequired(); } - $classes = array(); - $includedFiles = array(); + $classes = []; + $includedFiles = []; foreach ($this->paths as $path) { if (!is_dir($path)) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php index 635f1af6d..4588cfec8 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php @@ -37,14 +37,14 @@ class SymfonyFileLocator implements FileLocator * * @var array */ - protected $paths = array(); + protected $paths = []; /** * A map of mapping directory path to namespace prefix used to expand class shortnames. * * @var array */ - protected $prefixes = array(); + protected $prefixes = []; /** * File extension that is searched for. @@ -166,7 +166,7 @@ public function fileExists($className) */ public function getAllClassNames($globalBasename = null) { - $classes = array(); + $classes = []; if ($this->paths) { foreach ((array) $this->paths as $path) { diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php index e5bcb06e7..7d0176649 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/StaticReflectionService.php @@ -31,7 +31,7 @@ class StaticReflectionService implements ReflectionService */ public function getParentClasses($class) { - return array(); + return []; } /** diff --git a/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php b/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php index a35b71a28..990642e78 100644 --- a/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php +++ b/doctrine/common/lib/Doctrine/Common/Persistence/PersistentObject.php @@ -198,7 +198,7 @@ private function add($field, $args) throw new \InvalidArgumentException("Expected persistent object of type '".$targetClass."'"); } if (!($this->$field instanceof Collection)) { - $this->$field = new ArrayCollection($this->$field ?: array()); + $this->$field = new ArrayCollection($this->$field ?: []); } $this->$field->add($args[0]); $this->completeOwningSide($field, $targetClass, $args[0]); diff --git a/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php b/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php index bc546902e..7eb216bfc 100644 --- a/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php +++ b/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php @@ -87,7 +87,7 @@ abstract class AbstractProxyFactory /** * @var \Doctrine\Common\Proxy\ProxyDefinition[] */ - private $definitions = array(); + private $definitions = []; /** * @param \Doctrine\Common\Proxy\ProxyGenerator $proxyGenerator diff --git a/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php b/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php index 2fdeb95aa..925dcd1b7 100644 --- a/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php +++ b/doctrine/common/lib/Doctrine/Common/Proxy/ProxyGenerator.php @@ -58,10 +58,10 @@ class ProxyGenerator * * @var string[]|callable[] */ - protected $placeholders = array( - 'baseProxyInterface' => 'Doctrine\Common\Proxy\Proxy', + protected $placeholders = [ + 'baseProxyInterface' => Proxy::class, 'additionalProperties' => '', - ); + ]; /** * Template used as a blueprint to generate proxies. @@ -106,7 +106,7 @@ class extends \ implements \); + public static $lazyPropertiesDefaults = []; @@ -129,7 +129,7 @@ class extends \ implements \__initializer__ && $this->__initializer__->__invoke($this, \'__load\', array()); + $this->__initializer__ && $this->__initializer__->__invoke($this, \'__load\', []); } /** @@ -263,12 +263,12 @@ public function generateProxyClass(ClassMetadata $class, $fileName = false) preg_match_all('(<([a-zA-Z]+)>)', $this->proxyClassTemplate, $placeholderMatches); $placeholderMatches = array_combine($placeholderMatches[0], $placeholderMatches[1]); - $placeholders = array(); + $placeholders = []; foreach ($placeholderMatches as $placeholder => $name) { $placeholders[$placeholder] = isset($this->placeholders[$name]) ? $this->placeholders[$name] - : array($this, 'generate' . $name); + : [$this, 'generate' . $name]; } foreach ($placeholders as & $placeholder) { @@ -358,7 +358,7 @@ private function generateClassName(ClassMetadata $class) private function generateLazyPropertiesDefaults(ClassMetadata $class) { $lazyPublicProperties = $this->getLazyLoadedPublicProperties($class); - $values = array(); + $values = []; foreach ($lazyPublicProperties as $key => $value) { $values[] = var_export($key, true) . ' => ' . var_export($value, true); @@ -385,7 +385,7 @@ public function __construct($initializer = null, $cloner = null) { EOT; - $toUnset = array(); + $toUnset = []; foreach ($this->getLazyLoadedPublicProperties($class) as $lazyPublicProperty => $unused) { $toUnset[] = '$this->' . $lazyPublicProperty; @@ -443,7 +443,7 @@ public function {$returnReference}__get(\$name) if ( ! empty($lazyPublicProperties)) { $magicGet .= <<<'EOT' if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', [$name]); return $this->$name; } @@ -454,7 +454,7 @@ public function {$returnReference}__get(\$name) if ($hasParentGet) { $magicGet .= <<<'EOT' - $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', array($name)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__get', [$name]); return parent::__get($name); @@ -502,7 +502,7 @@ public function __set(\$name, \$value) if ( ! empty($lazyPublicProperties)) { $magicSet .= <<<'EOT' if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', [$name, $value]); $this->$name = $value; @@ -515,7 +515,7 @@ public function __set(\$name, \$value) if ($hasParentSet) { $magicSet .= <<<'EOT' - $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', array($name, $value)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__set', [$name, $value]); return parent::__set($name, $value); EOT; @@ -559,7 +559,7 @@ public function __isset(\$name) if ( ! empty($lazyPublicProperties)) { $magicIsset .= <<<'EOT' if (array_key_exists($name, $this->__getLazyProperties())) { - $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]); return isset($this->$name); } @@ -570,7 +570,7 @@ public function __isset(\$name) if ($hasParentIsset) { $magicIsset .= <<<'EOT' - $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', array($name)); + $this->__initializer__ && $this->__initializer__->__invoke($this, '__isset', [$name]); return parent::__isset($name); @@ -605,7 +605,7 @@ public function __sleep() if ($hasParentSleep) { return $sleepImpl . <<<'EOT' - $properties = array_merge(array('__isInitialized__'), parent::__sleep()); + $properties = array_merge(['__isInitialized__'], parent::__sleep()); if ($this->__isInitialized__) { $properties = array_diff($properties, array_keys($this->__getLazyProperties())); @@ -616,7 +616,7 @@ public function __sleep() EOT; } - $allProperties = array('__isInitialized__'); + $allProperties = ['__isInitialized__']; /* @var $prop \ReflectionProperty */ foreach ($class->getReflectionClass()->getProperties() as $prop) { @@ -645,10 +645,10 @@ public function __sleep() return $sleepImpl . <<__isInitialized__) { - return array($allProperties); + return [$allProperties]; } - return array($protectedProperties); + return [$protectedProperties]; } EOT; } @@ -662,7 +662,7 @@ public function __sleep() */ private function generateWakeupImpl(ClassMetadata $class) { - $unsetPublicProperties = array(); + $unsetPublicProperties = []; $hasWakeup = $class->getReflectionClass()->hasMethod('__wakeup'); foreach (array_keys($this->getLazyLoadedPublicProperties($class)) as $lazyPublicProperty) { @@ -727,7 +727,7 @@ private function generateCloneImpl(ClassMetadata $class) */ public function __clone() { - \$this->__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', array()); + \$this->__cloner__ && \$this->__cloner__->__invoke(\$this, '__clone', []); $callParentClone } EOT; } @@ -742,16 +742,16 @@ public function __clone() private function generateMethods(ClassMetadata $class) { $methods = ''; - $methodNames = array(); + $methodNames = []; $reflectionMethods = $class->getReflectionClass()->getMethods(\ReflectionMethod::IS_PUBLIC); - $skippedMethods = array( + $skippedMethods = [ '__sleep' => true, '__clone' => true, '__wakeup' => true, '__get' => true, '__set' => true, '__isset' => true, - ); + ]; foreach ($reflectionMethods as $method) { $name = $method->getName(); @@ -778,12 +778,13 @@ private function generateMethods(ClassMetadata $class) } $methods .= $name . '(' . $this->buildParametersString($class, $method, $method->getParameters()) . ')'; + $methods .= $this->getMethodReturnType($method); $methods .= "\n" . ' {' . "\n"; if ($this->isShortIdentifierGetter($method, $class)) { $identifier = lcfirst(substr($name, 3)); $fieldType = $class->getTypeOfField($identifier); - $cast = in_array($fieldType, array('integer', 'smallint')) ? '(int) ' : ''; + $cast = in_array($fieldType, ['integer', 'smallint']) ? '(int) ' : ''; $methods .= ' if ($this->__isInitialized__ === false) {' . "\n"; $methods .= ' return ' . $cast . ' parent::' . $method->getName() . "();\n"; @@ -795,7 +796,7 @@ private function generateMethods(ClassMetadata $class) $methods .= "\n \$this->__initializer__ " . "&& \$this->__initializer__->__invoke(\$this, " . var_export($name, true) - . ", array(" . $invokeParamsString . "));" + . ", [" . $invokeParamsString . "]);" . "\n\n return parent::" . $name . '(' . $callParamsString . ');' . "\n" . ' }' . "\n"; } @@ -872,7 +873,7 @@ private function isShortIdentifierGetter($method, ClassMetadata $class) private function getLazyLoadedPublicProperties(ClassMetadata $class) { $defaultProperties = $class->getReflectionClass()->getDefaultProperties(); - $properties = array(); + $properties = []; foreach ($class->getReflectionClass()->getProperties(\ReflectionProperty::IS_PUBLIC) as $property) { $name = $property->getName(); @@ -894,7 +895,7 @@ private function getLazyLoadedPublicProperties(ClassMetadata $class) */ private function buildParametersString(ClassMetadata $class, \ReflectionMethod $method, array $parameters) { - $parameterDefinitions = array(); + $parameterDefinitions = []; /* @var $param \ReflectionParameter */ foreach ($parameters as $param) { @@ -908,10 +909,8 @@ private function buildParametersString(ClassMetadata $class, \ReflectionMethod $ $parameterDefinition .= '&'; } - if (method_exists($param, 'isVariadic')) { - if ($param->isVariadic()) { - $parameterDefinition .= '...'; - } + if (method_exists($param, 'isVariadic') && $param->isVariadic()) { + $parameterDefinition .= '...'; } $parameters[] = '$' . $param->getName(); @@ -942,10 +941,14 @@ private function getParameterType(ClassMetadata $class, \ReflectionMethod $metho return 'array'; } - if (method_exists($parameter, 'isCallable') && $parameter->isCallable()) { + if ($parameter->isCallable()) { return 'callable'; } + if (method_exists($parameter, 'hasType') && $parameter->hasType() && $parameter->getType()->isBuiltin()) { + return (string) $parameter->getType(); + } + try { $parameterClass = $parameter->getClass(); @@ -990,10 +993,8 @@ private function getParameterNamesForParentCall(array $parameters) function (\ReflectionParameter $parameter) { $name = ''; - if (method_exists($parameter, 'isVariadic')) { - if ($parameter->isVariadic()) { - $name .= '...'; - } + if (method_exists($parameter, 'isVariadic') && $parameter->isVariadic()) { + $name .= '...'; } $name .= '$' . $parameter->getName(); @@ -1003,4 +1004,34 @@ function (\ReflectionParameter $parameter) { $parameters ); } + + /** + * @Param \ReflectionMethod $method + * + * @return string + */ + private function getMethodReturnType(\ReflectionMethod $method) + { + if (! (method_exists($method, 'hasReturnType') && $method->hasReturnType())) { + return ''; + } + + $returnType = $method->getReturnType(); + + if ($returnType->isBuiltin()) { + return ': ' . $returnType; + } + + $nameLower = strtolower((string) $returnType); + + if ('self' === $nameLower) { + return ': \\' . $method->getDeclaringClass()->getName(); + } + + if ('parent' === $nameLower) { + return ': \\' . $method->getDeclaringClass()->getParentClass()->getName(); + } + + return ': \\' . (string) $returnType; + } } diff --git a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php index b65979add..2d0f5b007 100644 --- a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php +++ b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionClass.php @@ -402,7 +402,7 @@ public function newInstance($args) /** * {@inheritDoc} */ - public function newInstanceArgs(array $args = array()) + public function newInstanceArgs(array $args = []) { throw new ReflectionException('Method not implemented'); } diff --git a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php index 922404d98..c48e9ba73 100644 --- a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php +++ b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionParser.php @@ -69,18 +69,18 @@ class StaticReflectionParser implements ReflectionProviderInterface * * @var array */ - protected $useStatements = array(); + protected $useStatements = []; /** * The docComment of the class. * * @var string */ - protected $docComment = array( + protected $docComment = [ 'class' => '', - 'property' => array(), - 'method' => array() - ); + 'property' => [], + 'method' => [] + ]; /** * The name of the class this class extends, if any. diff --git a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php index 79b40d4a0..7f6522bba 100644 --- a/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php +++ b/doctrine/common/lib/Doctrine/Common/Reflection/StaticReflectionProperty.php @@ -91,7 +91,7 @@ public function getUseStatements() /** * {@inheritDoc} */ - public static function export ($class, $name, $return = false) + public static function export($class, $name, $return = false) { throw new ReflectionException('Method not implemented'); } @@ -155,7 +155,7 @@ public function isStatic() /** * {@inheritDoc} */ - public function setAccessible ($accessible) + public function setAccessible($accessible) { throw new ReflectionException('Method not implemented'); } @@ -163,7 +163,7 @@ public function setAccessible ($accessible) /** * {@inheritDoc} */ - public function setValue ($object, $value = null) + public function setValue($object, $value = null) { throw new ReflectionException('Method not implemented'); } diff --git a/doctrine/common/lib/Doctrine/Common/Util/Debug.php b/doctrine/common/lib/Doctrine/Common/Util/Debug.php index 0959ce5d5..7f675328f 100644 --- a/doctrine/common/lib/Doctrine/Common/Util/Debug.php +++ b/doctrine/common/lib/Doctrine/Common/Util/Debug.php @@ -19,6 +19,7 @@ namespace Doctrine\Common\Util; +use Doctrine\Common\Collections\Collection; use Doctrine\Common\Persistence\Proxy; /** @@ -95,13 +96,13 @@ public static function export($var, $maxDepth) $return = null; $isObj = is_object($var); - if ($isObj && in_array('Doctrine\Common\Collections\Collection', class_implements($var))) { + if ($var instanceof Collection) { $var = $var->toArray(); } if ($maxDepth) { if (is_array($var)) { - $return = array(); + $return = []; foreach ($var as $k => $v) { $return[$k] = self::export($v, $maxDepth - 1); diff --git a/doctrine/common/lib/Doctrine/Common/Version.php b/doctrine/common/lib/Doctrine/Common/Version.php index 06f4a77c6..7baa65438 100644 --- a/doctrine/common/lib/Doctrine/Common/Version.php +++ b/doctrine/common/lib/Doctrine/Common/Version.php @@ -34,7 +34,7 @@ class Version /** * Current Doctrine Version. */ - const VERSION = '2.5.3'; + const VERSION = '2.6.1'; /** * Compares a Doctrine version with the current one. diff --git a/doctrine/common/phpunit.xml.dist b/doctrine/common/phpunit.xml.dist deleted file mode 100644 index f6fcf8498..000000000 --- a/doctrine/common/phpunit.xml.dist +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - ./tests/Doctrine/ - - - - - - ./lib/Doctrine/ - - - diff --git a/doctrine/dbal/composer.json b/doctrine/dbal/composer.json index 049019ef1..7b10ef51c 100644 --- a/doctrine/dbal/composer.json +++ b/doctrine/dbal/composer.json @@ -17,7 +17,7 @@ }, "require-dev": { "phpunit/phpunit": "4.*", - "symfony/console": "2.*" + "symfony/console": "2.*||^3.0" }, "suggest": { "symfony/console": "For helpful console commands such as SQL execution and import of files." diff --git a/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php b/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php index d85dec8d7..b0eac0b36 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php @@ -76,10 +76,22 @@ public static function invalidPdoInstance() } /** + * @param string|null $url The URL that was provided in the connection parameters (if any). + * * @return \Doctrine\DBAL\DBALException */ - public static function driverRequired() + public static function driverRequired($url = null) { + if ($url) { + return new self( + sprintf( + "The options 'driver' or 'driverClass' are mandatory if a connection URL without scheme " . + "is given to DriverManager::getConnection(). Given URL: %s", + $url + ) + ); + } + return new self("The options 'driver' or 'driverClass' are mandatory if no PDO ". "instance is given to DriverManager::getConnection()."); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php index edc02dff5..7e2bf5359 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/Mysqli/MysqliStatement.php @@ -242,7 +242,7 @@ public function fetch($fetchMode = null) { $values = $this->_fetch(); if (null === $values) { - return null; + return false; } if (false === $values) { @@ -282,7 +282,7 @@ public function fetchAll($fetchMode = null) $rows[] = $row; } } else { - while (($row = $this->fetch($fetchMode)) !== null) { + while (($row = $this->fetch($fetchMode)) !== false) { $rows[] = $row; } } @@ -296,7 +296,7 @@ public function fetchAll($fetchMode = null) public function fetchColumn($columnIndex = 0) { $row = $this->fetch(PDO::FETCH_NUM); - if (null === $row) { + if (false === $row) { return false; } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php index 3270a0b39..21b06fa16 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php @@ -71,6 +71,15 @@ class OCI8Statement implements \IteratorAggregate, Statement */ protected $_paramMap = array(); + /** + * Holds references to bound parameter values. + * + * This is a new requirement for PHP7's oci8 extension that prevents bound values from being garbage collected. + * + * @var array + */ + private $boundValues = array(); + /** * Creates a new OCI8Statement that uses the given connection handle and SQL statement. * @@ -148,11 +157,17 @@ public function bindParam($column, &$variable, $type = null, $length = null) $lob = oci_new_descriptor($this->_dbh, OCI_D_LOB); $lob->writeTemporary($variable, OCI_TEMP_BLOB); + $this->boundValues[$column] =& $lob; + return oci_bind_by_name($this->_sth, $column, $lob, -1, OCI_B_BLOB); } elseif ($length !== null) { + $this->boundValues[$column] =& $variable; + return oci_bind_by_name($this->_sth, $column, $variable, $length); } + $this->boundValues[$column] =& $variable; + return oci_bind_by_name($this->_sth, $column, $variable); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php index cc93a9b7e..d5b0b8dd9 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOPgSql/Driver.php @@ -90,9 +90,9 @@ private function _constructPdoDsn(array $params) $dsn .= 'dbname=' . $params['dbname'] . ' '; } else { // Used for temporary connections to allow operations like dropping the database currently connected to. - // Connecting without an explicit database does not work, therefore "template1" database is used - // as it is certainly present in every server setup. - $dsn .= 'dbname=template1' . ' '; + // Connecting without an explicit database does not work, therefore "postgres" database is used + // as it is certainly present in every server setup. + $dsn .= 'dbname=postgres' . ' '; } if (isset($params['sslmode'])) { diff --git a/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php b/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php index 75004a407..19aedc378 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/DriverManager.php @@ -142,7 +142,7 @@ public static function getConnection( } $params = self::parseDatabaseUrl($params); - + // check for existing pdo object if (isset($params['pdo']) && ! $params['pdo'] instanceof \PDO) { throw DBALException::invalidPdoInstance(); @@ -212,6 +212,19 @@ private static function _checkParams(array $params) } } + /** + * Normalizes the given connection URL path. + * + * @param string $urlPath + * + * @return string The normalized connection URL path + */ + private static function normalizeDatabaseUrlPath($urlPath) + { + // Trim leading slash from URL path. + return substr($urlPath, 1); + } + /** * Extracts parts from a database URL, if present, and returns an * updated list of parameters. @@ -227,23 +240,30 @@ private static function parseDatabaseUrl(array $params) if (!isset($params['url'])) { return $params; } - + // (pdo_)?sqlite3?:///... => (pdo_)?sqlite3?://localhost/... or else the URL will be invalid $url = preg_replace('#^((?:pdo_)?sqlite3?):///#', '$1://localhost/', $params['url']); - - $url = parse_url($url); - + + // PHP < 5.4.8 doesn't parse schemeless urls properly. + // See: https://php.net/parse-url#refsect1-function.parse-url-changelog + if (PHP_VERSION_ID < 50408 && strpos($url, '//') === 0) { + $url = parse_url('fake:' . $url); + + unset($url['scheme']); + } else { + $url = parse_url($url); + } + if ($url === false) { throw new DBALException('Malformed parameter "url".'); } - - if (isset($url['scheme'])) { - $params['driver'] = str_replace('-', '_', $url['scheme']); // URL schemes must not contain underscores, but dashes are ok - if (isset(self::$driverSchemeAliases[$params['driver']])) { - $params['driver'] = self::$driverSchemeAliases[$params['driver']]; // use alias like "postgres", else we just let checkParams decide later if the driver exists (for literal "pdo-pgsql" etc) - } - } - + + // If we have a connection URL, we have to unset the default PDO instance connection parameter (if any) + // as we cannot merge connection details from the URL into the PDO instance (URL takes precedence). + unset($params['pdo']); + + $params = self::parseDatabaseUrlScheme($url, $params); + if (isset($url['host'])) { $params['host'] = $url['host']; } @@ -256,21 +276,149 @@ private static function parseDatabaseUrl(array $params) if (isset($url['pass'])) { $params['password'] = $url['pass']; } - - if (isset($url['path'])) { - if (!isset($url['scheme']) || (strpos($url['scheme'], 'sqlite') !== false && $url['path'] == ':memory:')) { - $params['dbname'] = $url['path']; // if the URL was just "sqlite::memory:", which parses to scheme and path only - } else { - $params['dbname'] = substr($url['path'], 1); // strip the leading slash from the URL - } + + $params = self::parseDatabaseUrlPath($url, $params); + $params = self::parseDatabaseUrlQuery($url, $params); + + return $params; + } + + /** + * Parses the given connection URL and resolves the given connection parameters. + * + * Assumes that the connection URL scheme is already parsed and resolved into the given connection parameters + * via {@link parseDatabaseUrlScheme}. + * + * @param array $url The URL parts to evaluate. + * @param array $params The connection parameters to resolve. + * + * @return array The resolved connection parameters. + * + * @see parseDatabaseUrlScheme + */ + private static function parseDatabaseUrlPath(array $url, array $params) + { + if (! isset($url['path'])) { + return $params; + } + + $url['path'] = self::normalizeDatabaseUrlPath($url['path']); + + // If we do not have a known DBAL driver, we do not know any connection URL path semantics to evaluate + // and therefore treat the path as regular DBAL connection URL path. + if (! isset($params['driver'])) { + return self::parseRegularDatabaseUrlPath($url, $params); } - - if (isset($url['query'])) { - $query = array(); - parse_str($url['query'], $query); // simply ingest query as extra params, e.g. charset or sslmode - $params = array_merge($params, $query); // parse_str wipes existing array elements + + if (strpos($params['driver'], 'sqlite') !== false) { + return self::parseSqliteDatabaseUrlPath($url, $params); } - + + return self::parseRegularDatabaseUrlPath($url, $params); + } + + /** + * Parses the query part of the given connection URL and resolves the given connection parameters. + * + * @param array $url The connection URL parts to evaluate. + * @param array $params The connection parameters to resolve. + * + * @return array The resolved connection parameters. + */ + private static function parseDatabaseUrlQuery(array $url, array $params) + { + if (! isset($url['query'])) { + return $params; + } + + $query = array(); + + parse_str($url['query'], $query); // simply ingest query as extra params, e.g. charset or sslmode + + return array_merge($params, $query); // parse_str wipes existing array elements + } + + /** + * Parses the given regular connection URL and resolves the given connection parameters. + * + * Assumes that the "path" URL part is already normalized via {@link normalizeDatabaseUrlPath}. + * + * @param array $url The regular connection URL parts to evaluate. + * @param array $params The connection parameters to resolve. + * + * @return array The resolved connection parameters. + * + * @see normalizeDatabaseUrlPath + */ + private static function parseRegularDatabaseUrlPath(array $url, array $params) + { + $params['dbname'] = $url['path']; + + return $params; + } + + /** + * Parses the given SQLite connection URL and resolves the given connection parameters. + * + * Assumes that the "path" URL part is already normalized via {@link normalizeDatabaseUrlPath}. + * + * @param array $url The SQLite connection URL parts to evaluate. + * @param array $params The connection parameters to resolve. + * + * @return array The resolved connection parameters. + * + * @see normalizeDatabaseUrlPath + */ + private static function parseSqliteDatabaseUrlPath(array $url, array $params) + { + if ($url['path'] === ':memory:') { + $params['memory'] = true; + + return $params; + } + + $params['path'] = $url['path']; // pdo_sqlite driver uses 'path' instead of 'dbname' key + + return $params; + } + + /** + * Parses the scheme part from given connection URL and resolves the given connection parameters. + * + * @param array $url The connection URL parts to evaluate. + * @param array $params The connection parameters to resolve. + * + * @return array The resolved connection parameters. + * + * @throws DBALException if parsing failed or resolution is not possible. + */ + private static function parseDatabaseUrlScheme(array $url, array $params) + { + if (isset($url['scheme'])) { + // The requested driver from the URL scheme takes precedence + // over the default custom driver from the connection parameters (if any). + unset($params['driverClass']); + + // URL schemes must not contain underscores, but dashes are ok + $driver = str_replace('-', '_', $url['scheme']); + + // The requested driver from the URL scheme takes precedence + // over the default driver from the connection parameters (if any). + $params['driver'] = isset(self::$driverSchemeAliases[$driver]) + // use alias like "postgres", else we just let checkParams decide later + // if the driver exists (for literal "pdo-pgsql" etc) + ? self::$driverSchemeAliases[$driver] + : $driver; + + return $params; + } + + // If a schemeless connection URL is given, we require a default driver or default custom driver + // as connection parameter. + if (! isset($params['driverClass']) && ! isset($params['driver'])) { + throw DBALException::driverRequired($params['url']); + } + return $params; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php index e19540eb6..1c7ddec2f 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php @@ -69,7 +69,11 @@ public function postConnect(ConnectionEventArgs $args) array_change_key_case($this->_defaultSessionVars, \CASE_UPPER); $vars = array(); foreach ($this->_defaultSessionVars as $option => $value) { - $vars[] = $option." = '".$value."'"; + if ($option === 'CURRENT_SCHEMA') { + $vars[] = $option . " = " . $value; + } else { + $vars[] = $option . " = '" . $value . "'"; + } } $sql = "ALTER SESSION SET ".implode(" ", $vars); $args->getConnection()->executeUpdate($sql); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php index f0ace993e..192879ad5 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/AbstractPlatform.php @@ -1450,14 +1450,17 @@ public function getDropIndexSQL($index, $table = null) */ public function getDropConstraintSQL($constraint, $table) { - if ($constraint instanceof Constraint) { - $constraint = $constraint->getQuotedName($this); + if (! $constraint instanceof Constraint) { + $constraint = new Identifier($constraint); } - if ($table instanceof Table) { - $table = $table->getQuotedName($this); + if (! $table instanceof Table) { + $table = new Identifier($table); } + $constraint = $constraint->getQuotedName($this); + $table = $table->getQuotedName($this); + return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $constraint; } @@ -1471,14 +1474,17 @@ public function getDropConstraintSQL($constraint, $table) */ public function getDropForeignKeySQL($foreignKey, $table) { - if ($foreignKey instanceof ForeignKeyConstraint) { - $foreignKey = $foreignKey->getQuotedName($this); + if (! $foreignKey instanceof ForeignKeyConstraint) { + $foreignKey = new Identifier($foreignKey); } - if ($table instanceof Table) { - $table = $table->getQuotedName($this); + if (! $table instanceof Table) { + $table = new Identifier($table); } + $foreignKey = $foreignKey->getQuotedName($this); + $table = $table->getQuotedName($this); + return 'ALTER TABLE ' . $table . ' DROP FOREIGN KEY ' . $foreignKey; } @@ -3412,7 +3418,9 @@ public function getEmptyIdentityInsertSQL($tableName, $identifierColumnName) */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE '.$tableName; + $tableIdentifier = new Identifier($tableName); + + return 'TRUNCATE ' . $tableIdentifier->getQuotedName($this); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php index 9cc794d16..57eed254c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/DB2Platform.php @@ -26,6 +26,7 @@ use Doctrine\DBAL\Schema\Index; use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\TableDiff; +use Doctrine\DBAL\Types\Type; class DB2Platform extends AbstractPlatform { @@ -78,6 +79,20 @@ public function initializeDoctrineTypeMappings() ); } + /** + * {@inheritdoc} + */ + public function isCommentedDoctrineType(Type $doctrineType) + { + if ($doctrineType->getName() === Type::BOOLEAN) { + // We require a commented boolean type in order to distinguish between boolean and smallint + // as both (have to) map to the same native type. + return true; + } + + return parent::isCommentedDoctrineType($doctrineType); + } + /** * {@inheritDoc} */ @@ -234,7 +249,9 @@ public function getTimeTypeDeclarationSQL(array $fieldDeclaration) */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE ' . $tableName . ' IMMEDIATE'; + $tableIdentifier = new Identifier($tableName); + + return 'TRUNCATE ' . $tableIdentifier->getQuotedName($this) . ' IMMEDIATE'; } /** @@ -249,6 +266,8 @@ public function getTruncateTableSQL($tableName, $cascade = false) */ public function getListTableColumnsSQL($table, $database = null) { + $table = $this->quoteStringLiteral($table); + // We do the funky subquery and join syscat.columns.default this crazy way because // as of db2 v10, the column is CLOB(64k) and the distinct operator won't allow a CLOB, // it wants shorter stuff like a varchar. @@ -268,6 +287,7 @@ public function getListTableColumnsSQL($table, $database = null) c.scale, c.identity, tc.type AS tabconsttype, + c.remarks AS comment, k.colseq, CASE WHEN c.generated = 'D' THEN 1 @@ -281,7 +301,7 @@ public function getListTableColumnsSQL($table, $database = null) ON (c.tabschema = k.tabschema AND c.tabname = k.tabname AND c.colname = k.colname) - WHERE UPPER(c.tabname) = UPPER('" . $table . "') + WHERE UPPER(c.tabname) = UPPER(" . $table . ") ORDER BY c.colno ) subq JOIN syscat.columns cols @@ -313,6 +333,8 @@ public function getListViewsSQL($database) */ public function getListTableIndexesSQL($table, $currentDatabase = null) { + $table = $this->quoteStringLiteral($table); + return "SELECT idx.INDNAME AS key_name, idxcol.COLNAME AS column_name, CASE @@ -326,7 +348,7 @@ public function getListTableIndexesSQL($table, $currentDatabase = null) FROM SYSCAT.INDEXES AS idx JOIN SYSCAT.INDEXCOLUSE AS idxcol ON idx.INDSCHEMA = idxcol.INDSCHEMA AND idx.INDNAME = idxcol.INDNAME - WHERE idx.TABNAME = UPPER('" . $table . "') + WHERE idx.TABNAME = UPPER(" . $table . ") ORDER BY idxcol.COLSEQ ASC"; } @@ -335,6 +357,8 @@ public function getListTableIndexesSQL($table, $currentDatabase = null) */ public function getListTableForeignKeysSQL($table) { + $table = $this->quoteStringLiteral($table); + return "SELECT fkcol.COLNAME AS local_column, fk.REFTABNAME AS foreign_table, pkcol.COLNAME AS foreign_column, @@ -358,7 +382,7 @@ public function getListTableForeignKeysSQL($table) ON fk.REFKEYNAME = pkcol.CONSTNAME AND fk.REFTABSCHEMA = pkcol.TABSCHEMA AND fk.REFTABNAME = pkcol.TABNAME - WHERE fk.TABNAME = UPPER('" . $table . "') + WHERE fk.TABNAME = UPPER(" . $table . ") ORDER BY fkcol.COLSEQ ASC"; } @@ -410,6 +434,14 @@ public function supportsReleaseSavepoints() return false; } + /** + * {@inheritdoc} + */ + public function supportsCommentOnStatement() + { + return true; + } + /** * {@inheritDoc} */ @@ -748,7 +780,7 @@ protected function doModifyLimitQuery($query, $limit, $offset = null) $offset = (int) (($offset)?:0); // Todo OVER() needs ORDER BY data! - $sql = 'SELECT db22.* FROM (SELECT ROW_NUMBER() OVER() AS DC_ROWNUM, db21.* '. + $sql = 'SELECT db22.* FROM (SELECT db21.*, ROW_NUMBER() OVER() AS DC_ROWNUM '. 'FROM (' . $query . ') db21) db22 WHERE db22.DC_ROWNUM BETWEEN ' . ($offset+1) .' AND ' . ($offset+$limit); return $sql; diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php index e22851b95..15d9df394 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/MySqlPlatform.php @@ -153,11 +153,14 @@ public function getListTableConstraintsSQL($table) public function getListTableIndexesSQL($table, $currentDatabase = null) { if ($currentDatabase) { + $currentDatabase = $this->quoteStringLiteral($currentDatabase); + $table = $this->quoteStringLiteral($table); + return "SELECT TABLE_NAME AS `Table`, NON_UNIQUE AS Non_Unique, INDEX_NAME AS Key_name, ". "SEQ_IN_INDEX AS Seq_in_index, COLUMN_NAME AS Column_Name, COLLATION AS Collation, ". "CARDINALITY AS Cardinality, SUB_PART AS Sub_Part, PACKED AS Packed, " . "NULLABLE AS `Null`, INDEX_TYPE AS Index_Type, COMMENT AS Comment " . - "FROM information_schema.STATISTICS WHERE TABLE_NAME = '" . $table . "' AND TABLE_SCHEMA = '" . $currentDatabase . "'"; + "FROM information_schema.STATISTICS WHERE TABLE_NAME = " . $table . " AND TABLE_SCHEMA = " . $currentDatabase; } return 'SHOW INDEX FROM ' . $table; @@ -168,7 +171,9 @@ public function getListTableIndexesSQL($table, $currentDatabase = null) */ public function getListViewsSQL($database) { - return "SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = '".$database."'"; + $database = $this->quoteStringLiteral($database); + + return "SELECT * FROM information_schema.VIEWS WHERE TABLE_SCHEMA = " . $database; } /** @@ -176,17 +181,22 @@ public function getListViewsSQL($database) */ public function getListTableForeignKeysSQL($table, $database = null) { + $table = $this->quoteStringLiteral($table); + + if (null !== $database) { + $database = $this->quoteStringLiteral($database); + } + $sql = "SELECT DISTINCT k.`CONSTRAINT_NAME`, k.`COLUMN_NAME`, k.`REFERENCED_TABLE_NAME`, ". "k.`REFERENCED_COLUMN_NAME` /*!50116 , c.update_rule, c.delete_rule */ ". "FROM information_schema.key_column_usage k /*!50116 ". "INNER JOIN information_schema.referential_constraints c ON ". " c.constraint_name = k.constraint_name AND ". - " c.table_name = '$table' */ WHERE k.table_name = '$table'"; + " c.table_name = $table */ WHERE k.table_name = $table"; - if ($database) { - $sql .= " AND k.table_schema = '$database' /*!50116 AND c.constraint_schema = '$database' */"; - } + $databaseNameSql = null === $database ? 'DATABASE()' : $database; + $sql .= " AND k.table_schema = $databaseNameSql /*!50116 AND c.constraint_schema = $databaseNameSql */"; $sql .= " AND k.`REFERENCED_COLUMN_NAME` is not NULL"; return $sql; @@ -356,8 +366,10 @@ public function getListTablesSQL() */ public function getListTableColumnsSQL($table, $database = null) { + $table = $this->quoteStringLiteral($table); + if ($database) { - $database = "'" . $database . "'"; + $database = $this->quoteStringLiteral($database); } else { $database = 'DATABASE()'; } @@ -365,7 +377,7 @@ public function getListTableColumnsSQL($table, $database = null) return "SELECT COLUMN_NAME AS Field, COLUMN_TYPE AS Type, IS_NULLABLE AS `Null`, ". "COLUMN_KEY AS `Key`, COLUMN_DEFAULT AS `Default`, EXTRA AS Extra, COLUMN_COMMENT AS Comment, " . "CHARACTER_SET_NAME AS CharacterSet, COLLATION_NAME AS Collation ". - "FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = " . $database . " AND TABLE_NAME = '" . $table . "'"; + "FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = " . $database . " AND TABLE_NAME = " . $table; } /** @@ -614,23 +626,12 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) $sql = array(); $table = $diff->getName($this)->getQuotedName($this); - foreach ($diff->removedIndexes as $remKey => $remIndex) { - // Dropping primary keys requires to unset autoincrement attribute on the particular column first. - if ($remIndex->isPrimary() && $diff->fromTable instanceof Table) { - foreach ($remIndex->getColumns() as $columnName) { - $column = $diff->fromTable->getColumn($columnName); - - if ($column->getAutoincrement() === true) { - $column->setAutoincrement(false); - - $sql[] = 'ALTER TABLE ' . $table . ' MODIFY ' . - $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + foreach ($diff->changedIndexes as $changedIndex) { + $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $changedIndex)); + } - // original autoincrement information might be needed later on by other parts of the table alteration - $column->setAutoincrement(true); - } - } - } + foreach ($diff->removedIndexes as $remKey => $remIndex) { + $sql = array_merge($sql, $this->getPreAlterTableAlterPrimaryKeySQL($diff, $remIndex)); foreach ($diff->addedIndexes as $addKey => $addIndex) { if ($remIndex->getColumns() == $addIndex->getColumns()) { @@ -680,6 +681,40 @@ protected function getPreAlterTableIndexForeignKeySQL(TableDiff $diff) return $sql; } + /** + * @param TableDiff $diff + * @param Index $index + * + * @return string[] + */ + private function getPreAlterTableAlterPrimaryKeySQL(TableDiff $diff, Index $index) + { + $sql = array(); + + if (! $index->isPrimary() || ! $diff->fromTable instanceof Table) { + return $sql; + } + + $tableName = $diff->getName($this)->getQuotedName($this); + + // Dropping primary keys requires to unset autoincrement attribute on the particular column first. + foreach ($index->getColumns() as $columnName) { + $column = $diff->fromTable->getColumn($columnName); + + if ($column->getAutoincrement() === true) { + $column->setAutoincrement(false); + + $sql[] = 'ALTER TABLE ' . $tableName . ' MODIFY ' . + $this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray()); + + // original autoincrement information might be needed later on by other parts of the table alteration + $column->setAutoincrement(true); + } + } + + return $sql; + } + /** * @param TableDiff $diff The table diff to gather the SQL for. * @@ -1045,4 +1080,14 @@ public function getBlobTypeDeclarationSQL(array $field) return 'LONGBLOB'; } + + /** + * {@inheritdoc} + */ + public function quoteStringLiteral($str) + { + $str = str_replace('\\', '\\\\', $str); // MySQL requires backslashes to be escaped aswell. + + return parent::quoteStringLiteral($str); + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php index a58c747e9..4125b620b 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/OraclePlatform.php @@ -375,9 +375,10 @@ public function getListDatabasesSQL() public function getListSequencesSQL($database) { $database = $this->normalizeIdentifier($database); + $database = $this->quoteStringLiteral($database->getName()); return "SELECT sequence_name, min_value, increment_by FROM sys.all_sequences ". - "WHERE SEQUENCE_OWNER = '" . $database->getName() . "'"; + "WHERE SEQUENCE_OWNER = " . $database; } /** @@ -418,16 +419,35 @@ protected function _getCreateTableSQL($table, array $columns, array $options = a public function getListTableIndexesSQL($table, $currentDatabase = null) { $table = $this->normalizeIdentifier($table); - - return "SELECT uind.index_name AS name, " . - " uind.index_type AS type, " . - " decode( uind.uniqueness, 'NONUNIQUE', 0, 'UNIQUE', 1 ) AS is_unique, " . - " uind_col.column_name AS column_name, " . - " uind_col.column_position AS column_pos, " . - " (SELECT ucon.constraint_type FROM user_constraints ucon WHERE ucon.constraint_name = uind.index_name) AS is_primary ". - "FROM user_indexes uind, user_ind_columns uind_col " . - "WHERE uind.index_name = uind_col.index_name AND uind_col.table_name = '" . $table->getName() . "' " . - "ORDER BY uind_col.column_position ASC"; + $table = $this->quoteStringLiteral($table->getName()); + + return "SELECT uind_col.index_name AS name, + ( + SELECT uind.index_type + FROM user_indexes uind + WHERE uind.index_name = uind_col.index_name + ) AS type, + decode( + ( + SELECT uind.uniqueness + FROM user_indexes uind + WHERE uind.index_name = uind_col.index_name + ), + 'NONUNIQUE', + 0, + 'UNIQUE', + 1 + ) AS is_unique, + uind_col.column_name AS column_name, + uind_col.column_position AS column_pos, + ( + SELECT ucon.constraint_type + FROM user_constraints ucon + WHERE ucon.constraint_name = uind_col.index_name + ) AS is_primary + FROM user_ind_columns uind_col + WHERE uind_col.table_name = " . $table . " + ORDER BY uind_col.column_position ASC"; } /** @@ -590,7 +610,8 @@ private function getAutoincrementIdentifierName(Identifier $table) */ public function getListTableForeignKeysSQL($table) { - $table = $table = $this->normalizeIdentifier($table); + $table = $this->normalizeIdentifier($table); + $table = $this->quoteStringLiteral($table->getName()); return "SELECT alc.constraint_name, alc.DELETE_RULE, @@ -609,8 +630,8 @@ public function getListTableForeignKeysSQL($table) AND cols.position = r_cols.position WHERE alc.constraint_name = cols.constraint_name AND alc.constraint_type = 'R' - AND alc.table_name = '" . $table->getName() . "' - ORDER BY alc.constraint_name ASC, cols.position ASC"; + AND alc.table_name = " . $table . " + ORDER BY cols.constraint_name ASC, cols.position ASC"; } /** @@ -619,8 +640,9 @@ public function getListTableForeignKeysSQL($table) public function getListTableConstraintsSQL($table) { $table = $this->normalizeIdentifier($table); + $table = $this->quoteStringLiteral($table->getName()); - return "SELECT * FROM user_constraints WHERE table_name = '" . $table->getName() . "'"; + return "SELECT * FROM user_constraints WHERE table_name = " . $table; } /** @@ -629,21 +651,30 @@ public function getListTableConstraintsSQL($table) public function getListTableColumnsSQL($table, $database = null) { $table = $this->normalizeIdentifier($table); + $table = $this->quoteStringLiteral($table->getName()); $tabColumnsTableName = "user_tab_columns"; $colCommentsTableName = "user_col_comments"; $ownerCondition = ''; - if (null !== $database) { + if (null !== $database && '/' !== $database) { $database = $this->normalizeIdentifier($database); + $database = $this->quoteStringLiteral($database->getName()); $tabColumnsTableName = "all_tab_columns"; $colCommentsTableName = "all_col_comments"; - $ownerCondition = "AND c.owner = '" . $database->getName() . "'"; + $ownerCondition = "AND c.owner = " . $database; } - return "SELECT c.*, d.comments FROM $tabColumnsTableName c ". - "INNER JOIN " . $colCommentsTableName . " d ON d.TABLE_NAME = c.TABLE_NAME AND d.COLUMN_NAME = c.COLUMN_NAME ". - "WHERE c.table_name = '" . $table->getName() . "' ".$ownerCondition." ORDER BY c.column_name"; + return "SELECT c.*, + ( + SELECT d.comments + FROM $colCommentsTableName d + WHERE d.TABLE_NAME = c.TABLE_NAME + AND d.COLUMN_NAME = c.COLUMN_NAME + ) AS comments + FROM $tabColumnsTableName c + WHERE c.table_name = " . $table . " $ownerCondition + ORDER BY c.column_name"; } /** @@ -663,14 +694,17 @@ public function getDropSequenceSQL($sequence) */ public function getDropForeignKeySQL($foreignKey, $table) { - if ($foreignKey instanceof ForeignKeyConstraint) { - $foreignKey = $foreignKey->getQuotedName($this); + if (! $foreignKey instanceof ForeignKeyConstraint) { + $foreignKey = new Identifier($foreignKey); } - if ($table instanceof Table) { - $table = $table->getQuotedName($this); + if (! $table instanceof Table) { + $table = new Identifier($table); } + $foreignKey = $foreignKey->getQuotedName($this); + $table = $table->getQuotedName($this); + return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $foreignKey; } @@ -1054,7 +1088,9 @@ public function supportsReleaseSavepoints() */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE TABLE '.$tableName; + $tableIdentifier = new Identifier($tableName); + + return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this); } /** @@ -1120,4 +1156,14 @@ public function getBlobTypeDeclarationSQL(array $field) { return 'BLOB'; } + + /** + * {@inheritdoc} + */ + public function quoteStringLiteral($str) + { + $str = str_replace('\\', '\\\\', $str); // Oracle requires backslashes to be escaped aswell. + + return parent::quoteStringLiteral($str); + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php index 19cf80356..af1de90cd 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSQL92Platform.php @@ -78,6 +78,8 @@ protected function initializeDoctrineTypeMappings() */ public function getCloseActiveDatabaseConnectionsSQL($database) { - return "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = '$database'"; + $database = $this->quoteStringLiteral($database); + + return "SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = $database"; } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php index 681eb59f0..2f31b9d00 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php @@ -318,7 +318,7 @@ public function getDropViewSQL($name) public function getListTableConstraintsSQL($table) { $table = new Identifier($table); - $table = $table->getName(); + $table = $this->quoteStringLiteral($table->getName()); return "SELECT quote_ident(relname) as relname @@ -327,7 +327,7 @@ public function getListTableConstraintsSQL($table) WHERE oid IN ( SELECT indexrelid FROM pg_index, pg_class - WHERE pg_class.relname = '$table' + WHERE pg_class.relname = $table AND pg_class.oid = pg_index.indrelid AND (indisunique = 't' OR indisprimary = 't') )"; @@ -364,13 +364,14 @@ private function getTableWhereClause($table, $classAlias = 'c', $namespaceAlias $whereClause = $namespaceAlias.".nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND "; if (strpos($table, ".") !== false) { list($schema, $table) = explode(".", $table); - $schema = "'" . $schema . "'"; + $schema = $this->quoteStringLiteral($schema); } else { $schema = "ANY(string_to_array((select replace(replace(setting,'\"\$user\"',user),' ','') from pg_catalog.pg_settings where name = 'search_path'),','))"; } $table = new Identifier($table); - $whereClause .= "$classAlias.relname = '" . $table->getName() . "' AND $namespaceAlias.nspname = $schema"; + $table = $this->quoteStringLiteral($table->getName()); + $whereClause .= "$classAlias.relname = " . $table . " AND $namespaceAlias.nspname = $schema"; return $whereClause; } @@ -445,7 +446,9 @@ public function getDisallowDatabaseConnectionsSQL($database) */ public function getCloseActiveDatabaseConnectionsSQL($database) { - return "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = '$database'"; + $database = $this->quoteStringLiteral($database); + + return "SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = $database"; } /** @@ -1068,7 +1071,14 @@ public function getEmptyIdentityInsertSQL($quotedTableName, $quotedIdentifierCol */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE '.$tableName.' '.(($cascade)?'CASCADE':''); + $tableIdentifier = new Identifier($tableName); + $sql = 'TRUNCATE ' . $tableIdentifier->getQuotedName($this); + + if ($cascade) { + $sql .= ' CASCADE'; + } + + return $sql; } /** @@ -1165,4 +1175,14 @@ public function getBlobTypeDeclarationSQL(array $field) { return 'BYTEA'; } + + /** + * {@inheritdoc} + */ + public function quoteStringLiteral($str) + { + $str = str_replace('\\', '\\\\', $str); // PostgreSQL requires backslashes to be escaped aswell. + + return parent::quoteStringLiteral($str); + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php index 36debc390..841bdadb2 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLAnywherePlatform.php @@ -724,7 +724,7 @@ public function getListTableColumnsSQL($table, $database = null) if (strpos($table, '.') !== false) { list($user, $table) = explode('.', $table); - $user = "'" . $user . "'"; + $user = $this->quoteStringLiteral($user); } return "SELECT col.column_name, @@ -756,13 +756,16 @@ public function getListTableConstraintsSQL($table) if (strpos($table, '.') !== false) { list($user, $table) = explode('.', $table); - $user = "'" . $user . "'"; + $user = $this->quoteStringLiteral($user); + $table = $this->quoteStringLiteral($table); + } else { + $table = $this->quoteStringLiteral($table); } return "SELECT con.* FROM SYS.SYSCONSTRAINT AS con JOIN SYS.SYSTAB AS tab ON con.table_object_id = tab.object_id - WHERE tab.table_name = '$table' + WHERE tab.table_name = $table AND tab.creator = USER_ID($user)"; } @@ -775,7 +778,10 @@ public function getListTableForeignKeysSQL($table) if (strpos($table, '.') !== false) { list($user, $table) = explode('.', $table); - $user = "'" . $user . "'"; + $user = $this->quoteStringLiteral($user); + $table = $this->quoteStringLiteral($table); + } else { + $table = $this->quoteStringLiteral($table); } return "SELECT fcol.column_name AS local_column, @@ -844,7 +850,7 @@ public function getListTableForeignKeysSQL($table) ON fk.foreign_table_id = dt.foreign_table_id AND fk.foreign_index_id = dt.foreign_key_id AND dt.event = 'D' - WHERE ftbl.table_name = '$table' + WHERE ftbl.table_name = $table AND ftbl.creator = USER_ID($user) ORDER BY fk.foreign_index_id ASC, idxcol.sequence ASC"; } @@ -858,7 +864,10 @@ public function getListTableIndexesSQL($table, $currentDatabase = null) if (strpos($table, '.') !== false) { list($user, $table) = explode('.', $table); - $user = "'" . $user . "'"; + $user = $this->quoteStringLiteral($user); + $table = $this->quoteStringLiteral($table); + } else { + $table = $this->quoteStringLiteral($table); } return "SELECT idx.index_name AS key_name, @@ -893,7 +902,7 @@ public function getListTableIndexesSQL($table, $currentDatabase = null) ON idxcol.table_id = col.table_id AND idxcol.column_id = col.column_id JOIN SYS.SYSTAB AS tbl ON idx.table_id = tbl.table_id - WHERE tbl.table_name = '$table' + WHERE tbl.table_name = $table AND tbl.creator = USER_ID($user) AND idx.index_category != 2 -- exclude indexes implicitly created by foreign key constraints ORDER BY idx.index_id ASC, idxcol.sequence ASC"; @@ -1124,7 +1133,9 @@ public function getTrimExpression($str, $pos = self::TRIM_UNSPECIFIED, $char = f */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE TABLE ' . $tableName; + $tableIdentifier = new Identifier($tableName); + + return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php index fb78a80e0..c9bceaffd 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServer2012Platform.php @@ -102,4 +102,57 @@ protected function getReservedKeywordsClass() { return 'Doctrine\DBAL\Platforms\Keywords\SQLServer2012Keywords'; } + + /** + * {@inheritdoc} + */ + protected function doModifyLimitQuery($query, $limit, $offset = null) + { + if ($limit === null && $offset === null) { + return $query; + } + + // Queries using OFFSET... FETCH MUST have an ORDER BY clause + // Find the position of the last instance of ORDER BY and ensure it is not within a parenthetical statement + // but can be in a newline + $matches = array(); + $matchesCount = preg_match_all("/[\\s]+order by /i", $query, $matches, PREG_OFFSET_CAPTURE); + $orderByPos = false; + + if ($matchesCount > 0) { + $orderByPos = $matches[0][($matchesCount - 1)][1]; + } + + if ($orderByPos === false + || substr_count($query, "(", $orderByPos) - substr_count($query, ")", $orderByPos) + ) { + if (stripos($query, 'SELECT DISTINCT') === 0) { + // SQL Server won't let us order by a non-selected column in a DISTINCT query, + // so we have to do this madness. This says, order by the first column in the + // result. SQL Server's docs say that a nonordered query's result order is non- + // deterministic anyway, so this won't do anything that a bunch of update and + // deletes to the table wouldn't do anyway. + $query .= " ORDER BY 1"; + } else { + // In another DBMS, we could do ORDER BY 0, but SQL Server gets angry if you + // use constant expressions in the order by list. + $query .= " ORDER BY (SELECT 0)"; + } + } + + if ($offset === null) { + $offset = 0; + } + + // This looks somewhat like MYSQL, but limit/offset are in inverse positions + // Supposedly SQL:2008 core standard. + // Per TSQL spec, FETCH NEXT n ROWS ONLY is not valid without OFFSET n ROWS. + $query .= " OFFSET " . (int) $offset . " ROWS"; + + if ($limit !== null) { + $query .= " FETCH NEXT " . (int) $limit . " ROWS ONLY"; + } + + return $query; + } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php index 1a5f99ceb..d0af579a5 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SQLServerPlatform.php @@ -160,14 +160,17 @@ public function getCreateSchemaSQL($schemaName) */ public function getDropForeignKeySQL($foreignKey, $table) { - if ($foreignKey instanceof ForeignKeyConstraint) { - $foreignKey = $foreignKey->getQuotedName($this); + if (! $foreignKey instanceof ForeignKeyConstraint) { + $foreignKey = new Identifier($foreignKey); } - if ($table instanceof Table) { - $table = $table->getQuotedName($this); + if (! $table instanceof Table) { + $table = new Identifier($table); } + $foreignKey = $foreignKey->getQuotedName($this); + $table = $table->getQuotedName($this); + return 'ALTER TABLE ' . $table . ' DROP CONSTRAINT ' . $foreignKey; } @@ -925,12 +928,14 @@ private function getTableWhereClause($table, $schemaColumn, $tableColumn) { if (strpos($table, ".") !== false) { list($schema, $table) = explode(".", $table); - $schema = "'" . $schema . "'"; + $schema = $this->quoteStringLiteral($schema); + $table = $this->quoteStringLiteral($table); } else { $schema = "SCHEMA_NAME()"; + $table = $this->quoteStringLiteral($table); } - return "({$tableColumn} = '{$table}' AND {$schemaColumn} = {$schema})"; + return "({$tableColumn} = {$table} AND {$schemaColumn} = {$schema})"; } /** @@ -1490,7 +1495,9 @@ public function quoteSingleIdentifier($str) */ public function getTruncateTableSQL($tableName, $cascade = false) { - return 'TRUNCATE TABLE '.$tableName; + $tableIdentifier = new Identifier($tableName); + + return 'TRUNCATE TABLE ' . $tableIdentifier->getQuotedName($this); } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php index 3d8a09b63..4711d99de 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Platforms/SqlitePlatform.php @@ -405,8 +405,9 @@ public function getClobTypeDeclarationSQL(array $field) public function getListTableConstraintsSQL($table) { $table = str_replace('.', '__', $table); + $table = $this->quoteStringLiteral($table); - return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = '$table' AND sql NOT NULL ORDER BY name"; + return "SELECT sql FROM sqlite_master WHERE type='index' AND tbl_name = $table AND sql NOT NULL ORDER BY name"; } /** @@ -415,8 +416,9 @@ public function getListTableConstraintsSQL($table) public function getListTableColumnsSQL($table, $currentDatabase = null) { $table = str_replace('.', '__', $table); + $table = $this->quoteStringLiteral($table); - return "PRAGMA table_info('$table')"; + return "PRAGMA table_info($table)"; } /** @@ -425,8 +427,9 @@ public function getListTableColumnsSQL($table, $currentDatabase = null) public function getListTableIndexesSQL($table, $currentDatabase = null) { $table = str_replace('.', '__', $table); + $table = $this->quoteStringLiteral($table); - return "PRAGMA index_list('$table')"; + return "PRAGMA index_list($table)"; } /** @@ -505,7 +508,8 @@ public function getName() */ public function getTruncateTableSQL($tableName, $cascade = false) { - $tableName = str_replace('.', '__', $tableName); + $tableIdentifier = new Identifier($tableName); + $tableName = str_replace('.', '__', $tableIdentifier->getQuotedName($this)); return 'DELETE FROM ' . $tableName; } @@ -757,8 +761,9 @@ public function getCreateTableSQL(Table $table, $createFlags = null) public function getListTableForeignKeysSQL($table, $database = null) { $table = str_replace('.', '__', $table); + $table = $this->quoteStringLiteral($table); - return "PRAGMA foreign_key_list('$table')"; + return "PRAGMA foreign_key_list($table)"; } /** diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php index 0a6d59e37..5c46f1aa7 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Query/QueryBuilder.php @@ -1107,9 +1107,9 @@ public function resetQueryPart($queryPartName) */ private function getSQLForSelect() { - $query = 'SELECT ' . implode(', ', $this->sqlParts['select']) . ' FROM '; + $query = 'SELECT ' . implode(', ', $this->sqlParts['select']); - $query .= implode(', ', $this->getFromClauses()) + $query .= ($this->sqlParts['from'] ? ' FROM ' . implode(', ', $this->getFromClauses()) : '') . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '') . ($this->sqlParts['groupBy'] ? ' GROUP BY ' . implode(', ', $this->sqlParts['groupBy']) : '') . ($this->sqlParts['having'] !== null ? ' HAVING ' . ((string) $this->sqlParts['having']) : '') diff --git a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php index a9037ffc5..cdfb63645 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/SQLParserUtils.php @@ -32,7 +32,7 @@ class SQLParserUtils const NAMED_TOKEN = '(?oldColumnName); + $quote = $this->fromColumn && $this->fromColumn->isQuoted(); + + return new Identifier($this->oldColumnName, $quote); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php index 4f11e6c8d..abedfc062 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Comparator.php @@ -116,6 +116,10 @@ public function compare(Schema $fromSchema, Schema $toSchema) $localTableName = strtolower($foreignKey->getLocalTableName()); if (isset($diff->changedTables[$localTableName])) { foreach ($diff->changedTables[$localTableName]->removedForeignKeys as $key => $removedForeignKey) { + // We check if the key is from the removed table if not we skip. + if ($tableName !== strtolower($removedForeignKey->getForeignTableName())) { + continue; + } unset($diff->changedTables[$localTableName]->removedForeignKeys[$key]); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index ff914c60f..df6cf538c 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -65,6 +65,11 @@ protected function _getPortableTableColumnDefinition($tableColumn) $type = $this->_platform->getDoctrineTypeMapping($tableColumn['typename']); + if (isset($tableColumn['comment'])) { + $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); + $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); + } + switch (strtolower($tableColumn['typename'])) { case 'varchar': $length = $tableColumn['length']; @@ -94,6 +99,9 @@ protected function _getPortableTableColumnDefinition($tableColumn) 'notnull' => (bool) ($tableColumn['nulls'] == 'N'), 'scale' => null, 'precision' => null, + 'comment' => isset($tableColumn['comment']) && $tableColumn['comment'] !== '' + ? $tableColumn['comment'] + : null, 'platformOptions' => array(), ); diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php index 1e4861466..babe583e4 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/Identifier.php @@ -35,9 +35,14 @@ class Identifier extends AbstractAsset * Constructor. * * @param string $identifier Identifier name to wrap. + * @param bool $quote Whether to force quoting the given identifier. */ - public function __construct($identifier) + public function __construct($identifier, $quote = false) { $this->_setName($identifier); + + if ($quote && ! $this->_quoted) { + $this->_setName('"' . $this->getName() . '"'); + } } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php index 35afe1feb..23eccdad8 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Schema/SchemaDiff.php @@ -154,7 +154,7 @@ protected function _toSql(AbstractPlatform $platform, $saveMode = false) if ($platform->supportsForeignKeyConstraints() && $saveMode == false) { foreach ($this->orphanedForeignKeys as $orphanedForeignKey) { - $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTableName()); + $sql[] = $platform->getDropForeignKeySQL($orphanedForeignKey, $orphanedForeignKey->getLocalTable()); } } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Statement.php b/doctrine/dbal/lib/Doctrine/DBAL/Statement.php index 25ec652d2..77d0584ef 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Statement.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Statement.php @@ -138,6 +138,9 @@ public function bindValue($name, $value, $type = null) */ public function bindParam($name, &$var, $type = PDO::PARAM_STR, $length = null) { + $this->params[$name] = $var; + $this->types[$name] = $type; + return $this->stmt->bindParam($name, $var, $type, $length); } diff --git a/doctrine/dbal/lib/Doctrine/DBAL/Version.php b/doctrine/dbal/lib/Doctrine/DBAL/Version.php index d80287740..1175aef34 100644 --- a/doctrine/dbal/lib/Doctrine/DBAL/Version.php +++ b/doctrine/dbal/lib/Doctrine/DBAL/Version.php @@ -34,7 +34,7 @@ class Version /** * Current Doctrine Version. */ - const VERSION = '2.5.4'; + const VERSION = '2.5.5-DEV'; /** * Compares a Doctrine version with the current one. diff --git a/patches.txt b/patches.txt index 6485a1e9a..a3251f111 100644 --- a/patches.txt +++ b/patches.txt @@ -1,5 +1,4 @@ Patches: -- Doctrine: fix postgres column escaping when using reserved keyword: https://github.com/doctrine/dbal/pull/627 - patchwork/utf8: Remove trigger_error() that spammed the error log - Doctrine: fix error handling for not null columns on some mysql servers https://github.com/doctrine/dbal/pull/2422