From 223daae2ec5c841bfb674b5d81ef904262dc87ba Mon Sep 17 00:00:00 2001 From: romanb Date: Wed, 19 Mar 2008 18:33:14 +0000 Subject: [PATCH] added xsl stylesheet to generate changelogs from svn log. merged a few patches from 0.10 --- lib/Doctrine.php | 3 +- lib/Doctrine/Access.php | 2 +- lib/Doctrine/Configurable.php | 2 +- lib/Doctrine/Connection/Mssql.php | 11 + lib/Doctrine/Hydrator.php | 2 +- lib/Doctrine/Hydrator/Abstract.php | 9 +- lib/Doctrine/Hydrator/RecordDriver.php | 10 +- lib/Doctrine/Manager.php | 3 +- lib/Doctrine/Mapper.php | 2 +- lib/Doctrine/Null.php | 9 +- lib/Doctrine/Record.php | 47 +-- lib/Doctrine/Sequence/Mssql.php | 2 +- lib/Doctrine/Validator.php | 9 +- svn2cl.xsl | 463 ++++++++++++++++++++++++ tests_old/Relation/OneToOneTestCase.php | 2 +- tests_old/run.php | 7 +- 16 files changed, 532 insertions(+), 51 deletions(-) create mode 100644 svn2cl.xsl diff --git a/lib/Doctrine.php b/lib/Doctrine.php index b6f853a0a..8053f0f85 100644 --- a/lib/Doctrine.php +++ b/lib/Doctrine.php @@ -193,7 +193,7 @@ final class Doctrine const ATTR_EMULATE_DATABASE = 116; // manager/session attribute const ATTR_USE_NATIVE_ENUM = 117; // manager/session attribute const ATTR_DEFAULT_SEQUENCE = 133; // ?? - const ATTR_FETCHMODE = 118; // deprecated + const ATTR_FETCHMODE = 118; // deprecated? might use them again for associations const ATTR_NAME_PREFIX = 121; // ?? const ATTR_CREATE_TABLES = 122; // manager/session attribute const ATTR_COLL_LIMIT = 123; // manager/session attribute @@ -208,7 +208,6 @@ final class Doctrine const ATTR_QUERY_CACHE = 157; // manager/session attribute const ATTR_QUERY_CACHE_LIFESPAN = 158; // manager/session attribute const ATTR_MODEL_LOADING = 161; // manager/session attribute - const ATTR_LOCK = 162; // ?? const ATTR_HYDRATE = 163; // ?? const ATTR_IDENTIFIER = 164; // ?? const ATTR_METADATA_CACHE = 165; // manager/session attribute diff --git a/lib/Doctrine/Access.php b/lib/Doctrine/Access.php index 601826188..abebadb0b 100644 --- a/lib/Doctrine/Access.php +++ b/lib/Doctrine/Access.php @@ -33,7 +33,7 @@ * @version $Revision$ * @author Konsta Vesterinen */ -abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess +abstract class Doctrine_Access implements ArrayAccess { /** * setArray diff --git a/lib/Doctrine/Configurable.php b/lib/Doctrine/Configurable.php index 955fd5d92..ee9ffec6f 100644 --- a/lib/Doctrine/Configurable.php +++ b/lib/Doctrine/Configurable.php @@ -31,7 +31,7 @@ * @version $Revision$ * @author Konsta Vesterinen */ -abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable +abstract class Doctrine_Configurable { /** * @var array $attributes an array of containing all attributes diff --git a/lib/Doctrine/Connection/Mssql.php b/lib/Doctrine/Connection/Mssql.php index ed4630f16..963f85187 100644 --- a/lib/Doctrine/Connection/Mssql.php +++ b/lib/Doctrine/Connection/Mssql.php @@ -84,6 +84,17 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { return $identifier; } + + if (strpos($identifier, '.') !== false) { + $parts = explode('.', $identifier); + $quotedParts = array(); + foreach ($parts as $p) { + $quotedParts[] = $this->quoteIdentifier($p); + } + + return implode('.', $quotedParts); + } + return '[' . str_replace(']', ']]', $identifier) . ']'; } diff --git a/lib/Doctrine/Hydrator.php b/lib/Doctrine/Hydrator.php index 1834ae726..481718049 100644 --- a/lib/Doctrine/Hydrator.php +++ b/lib/Doctrine/Hydrator.php @@ -254,7 +254,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract */ protected function _setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne) { - if ($coll === self::$_null) { + if ($coll === $this->_nullObject) { return false; } diff --git a/lib/Doctrine/Hydrator/Abstract.php b/lib/Doctrine/Hydrator/Abstract.php index 287fd17aa..7b54f074d 100644 --- a/lib/Doctrine/Hydrator/Abstract.php +++ b/lib/Doctrine/Hydrator/Abstract.php @@ -30,7 +30,7 @@ * @version $Revision: 3192 $ * @author Konsta Vesterinen */ -abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable +abstract class Doctrine_Hydrator_Abstract { /** * @var array $_aliasMap two dimensional array containing the map for query aliases @@ -53,13 +53,18 @@ abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable * The current hydration mode. */ protected $_hydrationMode = Doctrine::HYDRATE_RECORD; + + protected $_nullObject; /** * constructor * * @param Doctrine_Connection|null $connection */ - public function __construct() {} + public function __construct() + { + $this->_nullObject = Doctrine_Null::$INSTANCE; + } /** * Sets the fetchmode. diff --git a/lib/Doctrine/Hydrator/RecordDriver.php b/lib/Doctrine/Hydrator/RecordDriver.php index 4e3fd96bc..06b5c0262 100644 --- a/lib/Doctrine/Hydrator/RecordDriver.php +++ b/lib/Doctrine/Hydrator/RecordDriver.php @@ -32,10 +32,16 @@ * @author Konsta Vesterinen * @author Roman Borschel */ -class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable +class Doctrine_Hydrator_RecordDriver { protected $_collections = array(); protected $_mappers = array(); + private $_nullObject; + + public function __construct() + { + $this->_nullObject = Doctrine_Null::$INSTANCE; + } public function getElementCollection($component) { @@ -98,7 +104,7 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable public function getNullPointer() { - return self::$_null; + return $this->_nullObject; } public function getElement(array $data, $className) diff --git a/lib/Doctrine/Manager.php b/lib/Doctrine/Manager.php index 0c9170bc2..491f2655c 100644 --- a/lib/Doctrine/Manager.php +++ b/lib/Doctrine/Manager.php @@ -77,7 +77,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera private function __construct() { $this->_root = dirname(__FILE__); - Doctrine_Locator_Injectable::initNullObject(new Doctrine_Null); } /** @@ -543,7 +542,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera } /** - * Creates a new native query (instance of Doctrine_RawSql). + * Creates a new native (SQL) query. * * @return Doctrine_RawSql */ diff --git a/lib/Doctrine/Mapper.php b/lib/Doctrine/Mapper.php index 313754004..cb525d013 100644 --- a/lib/Doctrine/Mapper.php +++ b/lib/Doctrine/Mapper.php @@ -86,7 +86,7 @@ class Doctrine_Mapper $this->_domainClassName = $name; $this->_conn = $classMetadata->getConnection(); $this->_classMetadata = $classMetadata; - $this->_nullObject = Doctrine_Null::getInstance(); + $this->_nullObject = Doctrine_Null::$INSTANCE; if ($classMetadata->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED) { $this->_mappingStrategy = new Doctrine_Mapper_JoinedStrategy($this); } else { diff --git a/lib/Doctrine/Null.php b/lib/Doctrine/Null.php index 4539b7592..18e3ab601 100644 --- a/lib/Doctrine/Null.php +++ b/lib/Doctrine/Null.php @@ -33,17 +33,16 @@ * @version $Revision$ * @author Konsta Vesterinen */ +// static initializer +Doctrine_Null::$INSTANCE = new Doctrine_Null(); final class Doctrine_Null { - private static $_instance; + public static $INSTANCE; public function __construct() {} public static function getInstance() { - if (is_null(self::$_instance)) { - self::$_instance = new Doctrine_Null(); - } - return self::$_instance; + return self::$INSTANCE; } public function exists() diff --git a/lib/Doctrine/Record.php b/lib/Doctrine/Record.php index 39704f92a..89bf5105b 100644 --- a/lib/Doctrine/Record.php +++ b/lib/Doctrine/Record.php @@ -208,7 +208,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite { if (isset($mapper) && $mapper instanceof Doctrine_Mapper) { $class = get_class($this); - $this->_mapper = Doctrine_Manager::getInstance()->getMapper($class); + $this->_mapper = $mapper; $this->_class = $this->_mapper->getClassMetadata(); $exists = ! $isNewEntry; } else { @@ -262,16 +262,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite { return self::$_index; } - - /** - * setUp - * this method is used for setting up relations and attributes - * it should be implemented by child classes - * - * @return void - */ - /*public function setUp() - { }*/ /** * construct @@ -485,7 +475,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite continue; } - if ($value === self::$_null || $overwrite) { + if ($value === Doctrine_Null::$INSTANCE || $overwrite) { $this->_data[$column] = $default; $this->_modified[] = $column; $this->_state = Doctrine_Record::STATE_TDIRTY; @@ -513,9 +503,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if (isset($tmp[$fieldName])) { $data[$fieldName] = $tmp[$fieldName]; } else if (array_key_exists($fieldName, $tmp)) { - $data[$fieldName] = self::$_null; + $data[$fieldName] = Doctrine_Null::$INSTANCE; } else if (!isset($this->_data[$fieldName])) { - $data[$fieldName] = self::$_null; + $data[$fieldName] = Doctrine_Null::$INSTANCE; } unset($tmp[$fieldName]); } @@ -554,7 +544,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $name = (array)$this->_class->getIdentifier(); $name = $name[0]; if ($exists) { - if (isset($this->_data[$name]) && $this->_data[$name] !== self::$_null) { + if (isset($this->_data[$name]) && $this->_data[$name] !== Doctrine_Null::$INSTANCE) { $this->_id[$name] = $this->_data[$name]; } } @@ -563,7 +553,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $names = (array)$this->_class->getIdentifier(); foreach ($names as $name) { - if ($this->_data[$name] === self::$_null) { + if ($this->_data[$name] === Doctrine_Null::$INSTANCE) { $this->_id[$name] = null; } else { $this->_id[$name] = $this->_data[$name]; @@ -600,7 +590,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite foreach ($this->_data as $k => $v) { if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') { unset($vars['_data'][$k]); - } else if ($v === self::$_null) { + } else if ($v === Doctrine_Null::$INSTANCE) { unset($vars['_data'][$k]); } else { switch ($this->_class->getTypeOf($k)) { @@ -838,7 +828,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if ( ! isset($this->_data[$fieldName])) { throw new Doctrine_Record_Exception('Unknown property '. $fieldName); } - if ($this->_data[$fieldName] === self::$_null) { + if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) { return null; } @@ -895,15 +885,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite }*/ // Use built-in accessor functionality - $value = self::$_null; + $nullObj = Doctrine_Null::$INSTANCE; + $value = $nullObj; if (isset($this->_data[$fieldName])) { - if ($this->_data[$fieldName] !== self::$_null) { + if ($this->_data[$fieldName] !== $nullObj) { return $this->_data[$fieldName]; } - if ($this->_data[$fieldName] === self::$_null && $load) { + if ($this->_data[$fieldName] === $nullObj && $load) { $this->load(); } - if ($this->_data[$fieldName] === self::$_null) { + if ($this->_data[$fieldName] === $nullObj) { $value = null; } return $value; @@ -982,7 +973,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite if ($old !== $value) { if ($value === null) { - $value = self::$_null; + $value = Doctrine_Null::$INSTANCE; } $this->_data[$fieldName] = $value; @@ -1032,7 +1023,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite return $this; } } else { - if ($value !== self::$_null) { + if ($value !== Doctrine_Null::$INSTANCE) { $relatedTable = $value->getTable(); $foreignFieldName = $rel->getForeignFieldName(); $localFieldName = $rel->getLocalFieldName(); @@ -1083,7 +1074,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite return true; } if (isset($this->_references[$fieldName]) && - $this->_references[$fieldName] !== self::$_null) { + $this->_references[$fieldName] !== Doctrine_Null::$INSTANCE) { return true; } return false; @@ -1100,7 +1091,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite } else if (isset($this->_references[$fieldName])) { if ($this->_references[$fieldName] instanceof Doctrine_Record) { // todo: delete related record when saving $this - $this->_references[$fieldName] = self::$_null; + $this->_references[$fieldName] = Doctrine_Null::$INSTANCE; } else if ($this->_references[$fieldName] instanceof Doctrine_Collection) { $this->_references[$fieldName]->setData(array()); } @@ -1211,7 +1202,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite foreach ($modifiedFields as $field) { $type = $this->_class->getTypeOf($field); - if ($this->_data[$field] === self::$_null) { + if ($this->_data[$field] === Doctrine_Null::$INSTANCE) { $dataSet[$field] = null; continue; } @@ -1286,7 +1277,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite $a = array(); foreach ($this as $column => $value) { - if ($value === self::$_null || is_object($value)) { + if ($value === Doctrine_Null::$INSTANCE || is_object($value)) { $value = null; } $a[$column] = $value; diff --git a/lib/Doctrine/Sequence/Mssql.php b/lib/Doctrine/Sequence/Mssql.php index e62a0c034..957829fdb 100644 --- a/lib/Doctrine/Sequence/Mssql.php +++ b/lib/Doctrine/Sequence/Mssql.php @@ -138,7 +138,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence $query = 'SELECT @@IDENTITY'; } - return $this->conn->fetchOne($query); + return (string) floor((float) $this->conn->fetchOne($query)); } /** diff --git a/lib/Doctrine/Validator.php b/lib/Doctrine/Validator.php index fba9dee61..da4f9bd11 100644 --- a/lib/Doctrine/Validator.php +++ b/lib/Doctrine/Validator.php @@ -29,14 +29,15 @@ * @link www.phpdoctrine.org * @since 1.0 * @version $Revision$ + * @author Roman Borschel * @author Konsta Vesterinen */ -class Doctrine_Validator extends Doctrine_Locator_Injectable +class Doctrine_Validator { /** * @var array $validators an array of validator objects */ - private static $validators = array(); + private static $validators = array(); /** * returns a validator object @@ -50,6 +51,8 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable $class = 'Doctrine_Validator_' . ucwords(strtolower($name)); if (class_exists($class)) { self::$validators[$name] = new $class; + } else if (class_exists($name)) { + self::$validators[$name] = new $name; } else { throw new Doctrine_Exception("Validator named '$name' not available."); } @@ -78,7 +81,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable $fields = ($record->exists()) ? $record->getModified() : $record->getData(); $err = array(); foreach ($fields as $fieldName => $value) { - if ($value === self::$_null) { + if ($value === Doctrine_Null::$INSTANCE) { $value = null; } else if ($value instanceof Doctrine_Record) { $value = $value->getIncremented(); diff --git a/svn2cl.xsl b/svn2cl.xsl new file mode 100644 index 000000000..146842848 --- /dev/null +++ b/svn2cl.xsl @@ -0,0 +1,463 @@ + + + + + + + +]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &newl; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &newl; + + + + + &space;&space; + + + + &newl; + &newl; + + + + + + + &newl; + + + + + &space;&space; + + + + &newl;&newl; + + + + + + :&space; + + + + + [r + + ]&space; + + + + + + + + &newl; + + + + + + + + + + + + + &newl; + + &tab;*&space; + + + + + + + + + + + + + + &space; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ,&space; + + + + + + + + + + + + + + ,&space; + + + + + + + + + + + + + + + + + + + + + + + + + + + . + + + + + + + + + + + + + + + + + + + &tab;&space;&space; + + + + + + + + + + &newl; + + + + + + + + + + + + + + + + + + + + + + &newl;&tab;&space;&space; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + &newl;&newl; + + + + + + + + + + + + + + + + + + + + &newl; + + + + + + + + diff --git a/tests_old/Relation/OneToOneTestCase.php b/tests_old/Relation/OneToOneTestCase.php index 4a7b9b591..a29939bc5 100644 --- a/tests_old/Relation/OneToOneTestCase.php +++ b/tests_old/Relation/OneToOneTestCase.php @@ -81,7 +81,7 @@ class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase $user->Email = $email; $user->save(); $this->assertTrue($user->Email instanceOf Email); - $user->Email = Email::getNullObject(); + $user->Email = Doctrine_Null::$INSTANCE; $user->save(); $this->assertTrue($user->Email instanceOf Doctrine_Null); } diff --git a/tests_old/run.php b/tests_old/run.php index f45a262ae..92a24fde4 100644 --- a/tests_old/run.php +++ b/tests_old/run.php @@ -303,6 +303,11 @@ $data->addTestCase(new Doctrine_Data_Import_TestCase()); $data->addTestCase(new Doctrine_Data_Export_TestCase()); $test->addTestCase($data); +$s = microtime(true); $test->run(); +$e = microtime(true); -echo memory_get_peak_usage() / 1024 . "\n"; +echo 'test run took: ' . ($e - $s) . ' seconds
'; + + +echo "peak memory usage: " . memory_get_peak_usage() / 1024 . "KB\n";