Skip to content
Snippets Groups Projects
Commit a9f1dfe4 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2157045 by dawehner: Update doctrine/common to 2.5-dev.

parent a3d88883
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing
with 444 additions and 338 deletions
......@@ -3,7 +3,7 @@
"This file locks the dependencies of your project to a known state",
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
],
"hash": "414745173d1e926721e1d7511a65dcec",
"hash": "c0c7604f8c0ed6b60809dfe98015e8b8",
"packages": [
{
"name": "doctrine/annotations",
......@@ -207,16 +207,16 @@
},
{
"name": "doctrine/common",
"version": "2.4.0-RC4",
"version": "dev-master",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "2.4.0-RC4"
"reference": "ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/2.4.0-RC4",
"reference": "2.4.0-RC4",
"url": "https://api.github.com/repos/doctrine/common/zipball/ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0",
"reference": "ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0",
"shasum": ""
},
"require": {
......@@ -230,7 +230,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
"dev-master": "2.5.x-dev"
}
},
"autoload": {
......@@ -246,7 +246,8 @@
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
......@@ -262,9 +263,9 @@
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes M. Schmitt",
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
......@@ -277,7 +278,7 @@
"persistence",
"spl"
],
"time": "2013-06-21 12:11:28"
"time": "2013-12-03 21:02:18"
},
{
"name": "doctrine/inflector",
......@@ -2056,7 +2057,7 @@
],
"minimum-stability": "stable",
"stability-flags": {
"doctrine/common": 10,
"doctrine/common": 20,
"doctrine/annotations": 20,
"kriswallsmith/assetic": 15,
"symfony-cmf/routing": 15,
......
......@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInite23e221879b77f56988466576fc63488::getLoader();
return ComposerAutoloaderInit0fa08cab46efc8ac2870c28f0a4fd5aa::getLoader();
......@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
class ComposerAutoloaderInite23e221879b77f56988466576fc63488
class ComposerAutoloaderInit0fa08cab46efc8ac2870c28f0a4fd5aa
{
private static $loader;
......@@ -19,9 +19,9 @@ public static function getLoader()
return self::$loader;
}
spl_autoload_register(array('ComposerAutoloaderInite23e221879b77f56988466576fc63488', 'loadClassLoader'), true, true);
spl_autoload_register(array('ComposerAutoloaderInit0fa08cab46efc8ac2870c28f0a4fd5aa', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
spl_autoload_unregister(array('ComposerAutoloaderInite23e221879b77f56988466576fc63488', 'loadClassLoader'));
spl_autoload_unregister(array('ComposerAutoloaderInit0fa08cab46efc8ac2870c28f0a4fd5aa', 'loadClassLoader'));
$vendorDir = dirname(__DIR__);
$baseDir = dirname(dirname($vendorDir));
......
......@@ -932,82 +932,6 @@
"string"
]
},
{
"name": "doctrine/common",
"version": "2.4.0-RC4",
"version_normalized": "2.4.0.0-RC4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "2.4.0-RC4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/2.4.0-RC4",
"reference": "2.4.0-RC4",
"shasum": ""
},
"require": {
"doctrine/annotations": "1.*",
"doctrine/cache": "1.*",
"doctrine/collections": "1.*",
"doctrine/inflector": "1.*",
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"time": "2013-06-21 12:11:28",
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
}
},
"installation-source": "dist",
"autoload": {
"psr-0": {
"Doctrine\\Common\\": "lib/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes M. Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "https://github.com/schmittjoh",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"collections",
"eventmanager",
"persistence",
"spl"
]
},
{
"name": "guzzle/common",
"version": "v3.7.1",
......@@ -2116,5 +2040,82 @@
"docblock",
"parser"
]
},
{
"name": "doctrine/common",
"version": "dev-master",
"version_normalized": "9999999-dev",
"source": {
"type": "git",
"url": "https://github.com/doctrine/common.git",
"reference": "ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/common/zipball/ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0",
"reference": "ba2ad8a7db24adb37a33ff52ee64b02d59ccfee0",
"shasum": ""
},
"require": {
"doctrine/annotations": "1.*",
"doctrine/cache": "1.*",
"doctrine/collections": "1.*",
"doctrine/inflector": "1.*",
"doctrine/lexer": "1.*",
"php": ">=5.3.2"
},
"time": "2013-12-03 21:02:18",
"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": "Jonathan Wage",
"email": "jonwage@gmail.com",
"homepage": "http://www.jwage.com/",
"role": "Creator"
},
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com",
"homepage": "http://www.instaclick.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Benjamin Eberlei",
"email": "kontakt@beberlei.de"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com",
"homepage": "http://jmsyst.com",
"role": "Developer of wrapped JMSSerializerBundle"
}
],
"description": "Common Library for Doctrine projects",
"homepage": "http://www.doctrine-project.org",
"keywords": [
"annotations",
"collections",
"eventmanager",
"persistence",
"spl"
]
}
]
......@@ -5,3 +5,5 @@ dist/
tests/Doctrine/Tests/Common/Proxy/generated/
vendor/
.idea
doctrine-common-*.tar
doctrine-common-*.tar.gz
language: php
env:
- OPCODE_CACHE=apc
php:
- 5.3.3
- 5.3
......@@ -11,4 +8,3 @@ php:
before_script:
- composer --prefer-source install
- php ./bin/travis-setup.php $OPCODE_CACHE
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
/**
* Install PHP extensions required for testing by Travis CI.
*
* @author Victor Berchet <victor@suumit.com>
* @since 2.2
*/
$installer = new PhpExtensions();
if (isset($argv[1]) && 'APC' === strtoupper($argv[1])) {
$installer->install('apc');
} else {
$installer->install('xcache');
}
$installer->install('memcache');
$installer->install('memcached');
class PhpExtensions
{
protected $extensions;
protected $phpVersion;
protected $iniPath;
public function __construct()
{
$this->phpVersion = phpversion();
$this->iniPath = php_ini_loaded_file();
$this->extensions = array(
'memcache' => array(
'url' => 'http://pecl.php.net/get/memcache-2.2.6.tgz',
'php_version' => array(),
'cfg' => array('--enable-memcache'),
'ini' => array('extension=memcache.so'),
),
'memcached' => array(
'url' => 'http://pecl.php.net/get/memcached-1.0.2.tgz',
'php_version' => array(
// memcached 1.0.2 does not build on PHP 5.4
array('<', '5.4'),
),
'cfg' => array(),
'ini' => array('extension=memcached.so'),
),
'apc' => array(
'url' => 'http://pecl.php.net/get/APC-3.1.9.tgz',
'php_version' => array(
// apc 3.1.9 causes a segfault on PHP 5.4
array('<', '5.4'),
),
'cfg' => array(),
'ini' => array(
'extension=apc.so',
'apc.enabled=1',
'apc.enable_cli=1'
),
),
'xcache' => array(
'url' => 'http://xcache.lighttpd.net/pub/Releases/1.2.2/xcache-1.2.2.tar.gz',
'php_version' => array(
// xcache does not build with Travis CI (as of 2012-01-09)
array('<', '5'),
),
'cfg' => array('--enable-xcache'),
'ini' => array(
'extension=xcache.so',
'xcache.cacher=false',
'xcache.admin.enable_auth=0',
'xcache.var_size=1M',
),
),
);
}
public function install($name)
{
if (array_key_exists($name, $this->extensions)) {
$extension = $this->extensions[$name];
echo "== extension: $name ==\n";
foreach ($extension['php_version'] as $version) {
if (!version_compare($this->phpVersion, $version[1], $version[0])) {
printf(
"=> not installed, requires a PHP version %s %s (%s installed)\n",
$version[0],
$version[1],
$this->phpVersion
);
return;
}
}
$this->system(sprintf("wget %s > /dev/null 2>&1", $extension['url']));
$file = basename($extension['url']);
$this->system(sprintf("tar -xzf %s > /dev/null 2>&1", $file));
$folder = basename($file, ".tgz");
$folder = basename($folder, ".tar.gz");
$this->system(sprintf(
'sh -c "cd %s && phpize && ./configure %s && make && sudo make install" > /dev/null 2>&1',
$folder,
implode(' ', $extension['cfg'])
));
foreach ($extension['ini'] as $ini) {
$this->system(sprintf("echo %s >> %s", $ini, $this->iniPath));
}
printf("=> installed (%s)\n", $folder);
}
}
private function system($cmd)
{
$ret = 0;
system($cmd, $ret);
if (0 !== $ret) {
printf("=> Command '%s' failed !", $cmd);
exit($ret);
}
}
}
# Project Name
project.name=DoctrineCommon
# Version class and file
project.version_class = Doctrine\Common\Version
project.version_class = Doctrine\\Common\\Version
project.version_file = lib/Doctrine/Common/Version.php
<?xml version="1.0"?>
<project name="Doctrine2" default="build" basedir=".">
<taskdef classname="phing.tasks.ext.d51PearPkg2Task" name="d51pearpkg2" />
<import file="${project.basedir}/lib/vendor/doctrine-build-common/packaging.xml" />
<project name="DoctrineCommon" default="build" basedir=".">
<property file="build.properties" />
<!--
Fileset for artifacts shared across all distributed packages.
-->
<fileset id="shared-artifacts" dir=".">
<include name="LICENSE"/>
<include name="COPYRIGHT"/>
<include name="CHANGELOG"/>
</fileset>
<!--
Fileset for the sources of the Doctrine Common package.
-->
<fileset id="common-sources" dir="./lib">
<include name="Doctrine/Common/**"/>
</fileset>
<!--
Builds Common package, preparing it for distribution.
-->
<target name="copy-files" depends="prepare">
<copy todir="${build.dir}/${project.name}-${version}">
<fileset refid="shared-artifacts"/>
</copy>
<copy todir="${build.dir}/${project.name}-${version}">
<fileset refid="common-sources"/>
</copy>
</target>
<!--
Builds distributable PEAR packages.
-->
<target name="define-pear-package" depends="copy-files">
<d51pearpkg2 baseinstalldir="/" dir="${build.dir}/${project.name}-${version}">
<name>DoctrineCommon</name>
<summary>Doctrine Common PHP Extensions</summary>
<channel>pear.doctrine-project.org</channel>
<description>The Doctrine Common package contains shared code between the other packages.</description>
<lead user="jwage" name="Jonathan H. Wage" email="jonwage@gmail.com" />
<lead user="guilhermeblanco" name="Guilherme Blanco" email="guilhermeblanco@gmail.com" />
<lead user="romanb" name="Roman Borschel" email="roman@code-factory.org" />
<lead user="beberlei" name="Benjamin Eberlei" email="kontakt@beberlei.de" />
<license>MIT</license>
<version release="${pear.version}" api="${pear.version}" />
<stability release="${pear.stability}" api="${pear.stability}" />
<notes>-</notes>
<dependencies>
<php minimum_version="5.3.0" />
<pear minimum_version="1.6.0" recommended_version="1.6.1" />
</dependencies>
</d51pearpkg2>
<target name="php">
<exec executable="which" outputproperty="php_executable">
<arg value="php" />
</exec>
</target>
<target name="prepare">
<mkdir dir="build" />
</target>
<target name="build" depends="check-git-checkout-clean,prepare,php,composer">
<exec executable="${php_executable}">
<arg value="build/composer.phar" />
<arg value="archive" />
<arg value="--dir=build" />
</exec>
</target>
<target name="composer" depends="php,composer-check,composer-download">
<exec executable="${php_executable}">
<arg value="build/composer.phar" />
<arg value="install" />
</exec>
</target>
<target name="composer-check" depends="prepare">
<available file="build/composer.phar" property="composer.present"/>
</target>
<target name="composer-download" unless="composer.present">
<exec executable="wget">
<arg value="-Obuild/composer.phar" />
<arg value="http://getcomposer.org/composer.phar" />
</exec>
</target>
<target name="make-release" depends="check-git-checkout-clean,prepare,php">
<replace file="${project.version_file}" token="-DEV" value="" failOnNoReplacements="true" />
<exec executable="${php_executable}" outputproperty="doctrine.current_version" failonerror="true">
<arg value="-r" />
<arg value="require_once '${project.version_file}';echo ${project.version_class}::VERSION;" />
</exec>
<exec executable="${php_executable}" outputproperty="doctrine.next_version" failonerror="true">
<arg value="-r" />
<arg value="$parts = explode('.', str_ireplace(array('-DEV', '-ALPHA', '-BETA'), '', '${doctrine.current_version}'));
if (count($parts) != 3) {
throw new \InvalidArgumentException('Version is assumed in format x.y.z, ${doctrine.current_version} given');
}
$parts[2]++;
echo implode('.', $parts);
" />
</exec>
<git-commit file="${project.version_file}" message="Release ${doctrine.current_version}" />
<git-tag version="${doctrine.current_version}" />
<replace file="${project.version_file}" token="${doctrine.current_version}" value="${doctrine.next_version}-DEV" />
<git-commit file="${project.version_file}" message="Bump version to ${doctrine.next_version}" />
</target>
<target name="check-git-checkout-clean">
<exec executable="git" failonerror="true">
<arg value="diff-index" />
<arg value="--quiet" />
<arg value="HEAD" />
</exec>
</target>
<macrodef name="git-commit">
<attribute name="file" default="NOT SET"/>
<attribute name="message" default="NOT SET"/>
<sequential>
<exec executable="git">
<arg value="add" />
<arg value="@{file}" />
</exec>
<exec executable="git">
<arg value="commit" />
<arg value="-m" />
<arg value="@{message}" />
</exec>
</sequential>
</macrodef>
<macrodef name="git-tag">
<attribute name="version" default="NOT SET" />
<sequential>
<exec executable="git">
<arg value="tag" />
<arg value="-m" />
<arg value="v@{version}" />
<arg value="v@{version}" />
</exec>
</sequential>
</macrodef>
</project>
......@@ -25,7 +25,10 @@
},
"extra": {
"branch-alias": {
"dev-master": "2.4.x-dev"
"dev-master": "2.5.x-dev"
}
},
"archive": {
"exclude": ["!vendor", "tests", "*phpunit.xml", ".travis.yml", "build.xml", "build.properties", "composer.phar"]
}
}
......@@ -127,7 +127,7 @@ public function removeEventListener($events, $listener)
}
/**
* Adds an EventSubscriber. The subscriber is asked for all the events he is
* Adds an EventSubscriber. The subscriber is asked for all the events it is
* interested in and added as a listener for these events.
*
* @param \Doctrine\Common\EventSubscriber $subscriber The subscriber.
......
......@@ -30,7 +30,7 @@
interface ObjectManager
{
/**
* Finds a object by its identifier.
* Finds an object by its identifier.
*
* This is just a convenient shortcut for getRepository($className)->find($id).
*
......
......@@ -21,6 +21,7 @@
use Doctrine\Common\Persistence\Mapping\ClassMetadataFactory;
use Doctrine\Common\Proxy\Exception\InvalidArgumentException;
use Doctrine\Common\Proxy\Exception\OutOfBoundsException;
use Doctrine\Common\Util\ClassUtils;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;
......@@ -31,6 +32,43 @@
*/
abstract class AbstractProxyFactory
{
/**
* Never autogenerate a proxy and rely that it was generated by some
* process before deployment.
*
* @var integer
*/
const AUTOGENERATE_NEVER = 0;
/**
* Always generates a new proxy in every request.
*
* This is only sane during development.
*
* @var integer
*/
const AUTOGENERATE_ALWAYS = 1;
/**
* Autogenerate the proxy class when the proxy file does not exist.
*
* This strategy causes a file exists call whenever any proxy is used the
* first time in a request.
*
* @var integer
*/
const AUTOGENERATE_FILE_NOT_EXISTS = 2;
/**
* Generate the proxy classes using eval().
*
* This strategy is only sane for development, and even then it gives me
* the creeps a little.
*
* @var integer
*/
const AUTOGENERATE_EVAL = 3;
/**
* @var \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
*/
......@@ -54,13 +92,13 @@ abstract class AbstractProxyFactory
/**
* @param \Doctrine\Common\Proxy\ProxyGenerator $proxyGenerator
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory $metadataFactory
* @param bool $autoGenerate
* @param bool|int $autoGenerate
*/
public function __construct(ProxyGenerator $proxyGenerator, ClassMetadataFactory $metadataFactory, $autoGenerate)
{
$this->proxyGenerator = $proxyGenerator;
$this->metadataFactory = $metadataFactory;
$this->autoGenerate = $autoGenerate;
$this->autoGenerate = (int)$autoGenerate;
}
/**
......@@ -71,6 +109,8 @@ public function __construct(ProxyGenerator $proxyGenerator, ClassMetadataFactory
* @param array $identifier
*
* @return \Doctrine\Common\Proxy\Proxy
*
* @throws \Doctrine\Common\Proxy\Exception\OutOfBoundsException
*/
public function getProxy($className, array $identifier)
{
......@@ -81,6 +121,10 @@ public function getProxy($className, array $identifier)
$proxy = new $fqcn($definition->initializer, $definition->cloner);
foreach ($definition->identifierFields as $idField) {
if (! isset($identifier[$idField])) {
throw OutOfBoundsException::missingPrimaryKeyValue($className, $idField);
}
$definition->reflectionFields[$idField]->setValue($proxy, $identifier[$idField]);
}
......@@ -158,11 +202,27 @@ private function getProxyDefinition($className)
if ( ! class_exists($proxyClassName, false)) {
$fileName = $this->proxyGenerator->getProxyFileName($className);
if ($this->autoGenerate) {
$this->proxyGenerator->generateProxyClass($classMetadata);
switch ($this->autoGenerate) {
case self::AUTOGENERATE_NEVER:
require $fileName;
break;
case self::AUTOGENERATE_FILE_NOT_EXISTS:
if ( ! file_exists($fileName)) {
$this->proxyGenerator->generateProxyClass($classMetadata, $fileName);
}
require $fileName;
break;
case self::AUTOGENERATE_ALWAYS:
$this->proxyGenerator->generateProxyClass($classMetadata, $fileName);
require $fileName;
break;
case self::AUTOGENERATE_EVAL:
$this->proxyGenerator->generateProxyClass($classMetadata, false);
break;
}
}
return $this->definitions[$className];
......
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Common\Proxy\Exception;
use Doctrine\Common\Persistence\Proxy;
use OutOfBoundsException as BaseOutOfBoundsException;
/**
* Proxy Invalid Argument Exception.
*
* @link www.doctrine-project.org
* @author Fredrik Wendel <fredrik_w@users.sourceforge.net>
*/
class OutOfBoundsException extends BaseOutOfBoundsException implements ProxyException
{
/**
* @param string $className
* @param string $idField
*
* @return self
*/
public static function missingPrimaryKeyValue($className, $idField)
{
return new self(sprintf("Missing value for primary key %s on %s", $idField, $className));
}
}
......@@ -254,11 +254,11 @@ public function setProxyClassTemplate($proxyClassTemplate)
* Generates a proxy class file.
*
* @param \Doctrine\Common\Persistence\Mapping\ClassMetadata $class Metadata for the original class.
* @param string $fileName Filename (full path) for the generated class.
* @param string|bool $fileName Filename (full path) for the generated class. If none is given, eval() is used.
*
* @throws UnexpectedValueException
*/
public function generateProxyClass(ClassMetadata $class, $fileName = null)
public function generateProxyClass(ClassMetadata $class, $fileName = false)
{
preg_match_all('(<([a-zA-Z]+)>)', $this->proxyClassTemplate, $placeholderMatches);
......@@ -278,7 +278,17 @@ public function generateProxyClass(ClassMetadata $class, $fileName = null)
}
$proxyCode = strtr($this->proxyClassTemplate, $placeholders);
$fileName = $fileName ?: $this->getProxyFileName($class->getName());
if ( ! $fileName) {
$proxyClassName = $this->generateNamespace($class) . '\\' . $this->generateProxyShortClassName($class);
if ( ! class_exists($proxyClassName)) {
eval(substr($proxyCode, 5));
}
return;
}
$parentDirectory = dirname($fileName);
if ( ! is_dir($parentDirectory) && (false === @mkdir($parentDirectory, 0775, true))) {
......@@ -609,7 +619,13 @@ public function __sleep()
/* @var $prop \ReflectionProperty */
foreach ($class->getReflectionClass()->getProperties() as $prop) {
$allProperties[] = $prop->getName();
if ($prop->isStatic()) {
continue;
}
$allProperties[] = $prop->isPrivate()
? "\0" . $prop->getDeclaringClass()->getName() . "\0" . $prop->getName()
: $prop->getName();
}
$lazyPublicProperties = array_keys($this->getLazyLoadedPublicProperties($class));
......
......@@ -48,10 +48,17 @@ private function __construct()
* @param mixed $var The variable to dump.
* @param integer $maxDepth The maximum nesting level for object properties.
* @param boolean $stripTags Whether output should strip HTML tags.
* @param boolean $echo Send the dumped value to the output buffer
*
* @return string
*/
public static function dump($var, $maxDepth = 2, $stripTags = true)
public static function dump($var, $maxDepth = 2, $stripTags = true, $echo = true)
{
ini_set('html_errors', 'On');
$html = ini_get('html_errors');
if ($html !== true) {
ini_set('html_errors', true);
}
if (extension_loaded('xdebug')) {
ini_set('xdebug.var_display_max_depth', $maxDepth);
......@@ -61,12 +68,20 @@ public static function dump($var, $maxDepth = 2, $stripTags = true)
ob_start();
var_dump($var);
$dump = ob_get_contents();
ob_end_clean();
echo ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
$dumpText = ($stripTags ? strip_tags(html_entity_decode($dump)) : $dump);
ini_set('html_errors', $html);
if ($echo) {
echo $dumpText;
}
ini_set('html_errors', 'Off');
return $dumpText;
}
/**
......
......@@ -34,7 +34,7 @@ class Version
/**
* Current Doctrine Version.
*/
const VERSION = '2.4.1';
const VERSION = '2.5.0-DEV';
/**
* Compares a Doctrine version with the current one.
......
......@@ -114,5 +114,33 @@ public function testDisallowsResettingInitializedProxy()
$proxyFactory->resetUninitializedProxy($proxy);
}
public function testMissingPrimaryKeyValue()
{
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$proxy = $this->getMock('Doctrine\Common\Proxy\Proxy');
$definition = new ProxyDefinition(get_class($proxy), array('missingKey'), array(), null, null);
$proxyGenerator = $this->getMock('Doctrine\Common\Proxy\ProxyGenerator', array(), array(), '', false);
$metadataFactory = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadataFactory');
$metadataFactory
->expects($this->once())
->method('getMetadataFor')
->will($this->returnValue($metadata));
$proxyFactory = $this->getMockForAbstractClass(
'Doctrine\Common\Proxy\AbstractProxyFactory',
array($proxyGenerator, $metadataFactory, true)
);
$proxyFactory
->expects($this->any())
->method('createProxyDefinition')
->will($this->returnValue($definition));
$this->setExpectedException('\OutOfBoundsException');
$generatedProxy = $proxyFactory->getProxy('Class', array());
}
}
......@@ -61,8 +61,7 @@ protected function setUp()
return;
}
$this->proxyGenerator->generateProxyClass($this->metadata);
require_once $this->proxyGenerator->getProxyFileName($this->metadata->getName());
$this->generateAndRequire($this->proxyGenerator, $this->metadata);
}
public function testReferenceProxyRespectsMethodsParametersTypeHinting()
......@@ -107,14 +106,11 @@ public function testNonNamespacedProxyGeneration()
public function testClassWithSleepProxyGeneration()
{
if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\SleepClass', false)) {
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$reflClass = new ReflectionClass('Doctrine\Tests\Common\Proxy\SleepClass');
$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array('id')));
$metadata->expects($this->any())->method('getName')->will($this->returnValue($reflClass->getName()));
$className = 'Doctrine\Tests\Common\Proxy\SleepClass';
$metadata = $this->createClassMetadata($className, array('id'));
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$proxyGenerator->generateProxyClass($metadata);
require_once $proxyGenerator->getProxyFileName($metadata->getName());
$this->generateAndRequire($proxyGenerator, $metadata);
}
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxySleepClass.php');
......@@ -122,6 +118,32 @@ public function testClassWithSleepProxyGeneration()
$this->assertEquals(1, substr_count($classCode, 'parent::__sleep()'));
}
/**
* Check that the proxy doesn't serialize static properties (in __sleep() method)
* @group DCOM-212
*/
public function testClassWithStaticPropertyProxyGeneration()
{
if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\StaticPropertyClass', false)) {
$className = 'Doctrine\Tests\Common\Proxy\StaticPropertyClass';
$metadata = $this->createClassMetadata($className, array());
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$this->generateAndRequire($proxyGenerator, $metadata);
}
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyStaticPropertyClass.php');
$this->assertEquals(1, substr_count($classCode, 'function __sleep'));
$this->assertNotContains('protectedStaticProperty', $classCode);
}
private function generateAndRequire($proxyGenerator, $metadata)
{
$proxyGenerator->generateProxyClass($metadata, $proxyGenerator->getProxyFileName($metadata->getName()));
require_once $proxyGenerator->getProxyFileName($metadata->getName());
}
public function testClassWithCallableTypeHintOnProxiedMethod()
{
if (PHP_VERSION_ID < 50400) {
......@@ -129,16 +151,11 @@ public function testClassWithCallableTypeHintOnProxiedMethod()
}
if (!class_exists('Doctrine\Tests\Common\ProxyProxy\__CG__\CallableTypeHintClass', false)) {
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$reflClass = new ReflectionClass('Doctrine\Tests\Common\Proxy\CallableTypeHintClass');
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array('id')));
$metadata->expects($this->any())->method('getName')->will($this->returnValue($reflClass->getName()));
$className = 'Doctrine\Tests\Common\Proxy\CallableTypeHintClass';
$metadata = $this->createClassMetadata($className, array('id'));
$proxyGenerator->generateProxyClass($metadata);
require_once $proxyGenerator->getProxyFileName($metadata->getName());
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$this->generateAndRequire($proxyGenerator, $metadata);
}
$classCode = file_get_contents(__DIR__ . '/generated/__CG__DoctrineTestsCommonProxyCallableTypeHintClass.php');
......@@ -149,11 +166,7 @@ public function testClassWithCallableTypeHintOnProxiedMethod()
public function testClassWithInvalidTypeHintOnProxiedMethod()
{
$className = 'Doctrine\Tests\Common\Proxy\InvalidTypeHintClass';
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$reflClass = new ReflectionClass($className);
$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue(array()));
$metadata->expects($this->any())->method('getName')->will($this->returnValue($className));
$metadata = $this->createClassMetadata($className, array('id'));
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$this->setExpectedException(
......@@ -182,4 +195,34 @@ public function testInvalidPlaceholderThrowsException()
$generator = new ProxyGenerator(__DIR__ . '/generated', 'SomeNamespace');
$generator->setPlaceholder('<somePlaceholder>', array());
}
public function testUseEvalIfNoFilenameIsGiven()
{
$proxyGenerator = new ProxyGenerator(__DIR__ . '/generated', __NAMESPACE__ . 'Proxy', true);
$className = __NAMESPACE__ . '\\EvalBase';
$metadata = $this->createClassMetadata($className, array('id'));
$proxyGenerator->generateProxyClass($metadata);
$reflClass = new ReflectionClass('Doctrine\Tests\Common\ProxyProxy\__CG__\Doctrine\Tests\Common\Proxy\EvalBase');
$this->assertContains("eval()'d code", $reflClass->getFileName());
}
private function createClassMetadata($className, array $ids)
{
$metadata = $this->getMock('Doctrine\Common\Persistence\Mapping\ClassMetadata');
$reflClass = new ReflectionClass($className);
$metadata->expects($this->any())->method('getReflectionClass')->will($this->returnValue($reflClass));
$metadata->expects($this->any())->method('getIdentifierFieldNames')->will($this->returnValue($ids));
$metadata->expects($this->any())->method('getName')->will($this->returnValue($className));
return $metadata;
}
}
class EvalBase
{
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment