Commit 223daae2 authored by romanb's avatar romanb

added xsl stylesheet to generate changelogs from svn log. merged a few patches from 0.10

parent 82efe45c
...@@ -193,7 +193,7 @@ final class Doctrine ...@@ -193,7 +193,7 @@ final class Doctrine
const ATTR_EMULATE_DATABASE = 116; // manager/session attribute const ATTR_EMULATE_DATABASE = 116; // manager/session attribute
const ATTR_USE_NATIVE_ENUM = 117; // manager/session attribute const ATTR_USE_NATIVE_ENUM = 117; // manager/session attribute
const ATTR_DEFAULT_SEQUENCE = 133; // ?? 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_NAME_PREFIX = 121; // ??
const ATTR_CREATE_TABLES = 122; // manager/session attribute const ATTR_CREATE_TABLES = 122; // manager/session attribute
const ATTR_COLL_LIMIT = 123; // manager/session attribute const ATTR_COLL_LIMIT = 123; // manager/session attribute
...@@ -208,7 +208,6 @@ final class Doctrine ...@@ -208,7 +208,6 @@ final class Doctrine
const ATTR_QUERY_CACHE = 157; // manager/session attribute const ATTR_QUERY_CACHE = 157; // manager/session attribute
const ATTR_QUERY_CACHE_LIFESPAN = 158; // manager/session attribute const ATTR_QUERY_CACHE_LIFESPAN = 158; // manager/session attribute
const ATTR_MODEL_LOADING = 161; // manager/session attribute const ATTR_MODEL_LOADING = 161; // manager/session attribute
const ATTR_LOCK = 162; // ??
const ATTR_HYDRATE = 163; // ?? const ATTR_HYDRATE = 163; // ??
const ATTR_IDENTIFIER = 164; // ?? const ATTR_IDENTIFIER = 164; // ??
const ATTR_METADATA_CACHE = 165; // manager/session attribute const ATTR_METADATA_CACHE = 165; // manager/session attribute
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess abstract class Doctrine_Access implements ArrayAccess
{ {
/** /**
* setArray * setArray
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
abstract class Doctrine_Configurable extends Doctrine_Locator_Injectable abstract class Doctrine_Configurable
{ {
/** /**
* @var array $attributes an array of containing all attributes * @var array $attributes an array of containing all attributes
......
...@@ -84,6 +84,17 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection ...@@ -84,6 +84,17 @@ class Doctrine_Connection_Mssql extends Doctrine_Connection
if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) { if ($checkOption && ! $this->getAttribute(Doctrine::ATTR_QUOTE_IDENTIFIER)) {
return $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) . ']'; return '[' . str_replace(']', ']]', $identifier) . ']';
} }
......
...@@ -254,7 +254,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract ...@@ -254,7 +254,7 @@ class Doctrine_Hydrator extends Doctrine_Hydrator_Abstract
*/ */
protected function _setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne) protected function _setLastElement(&$prev, &$coll, $index, $dqlAlias, $oneToOne)
{ {
if ($coll === self::$_null) { if ($coll === $this->_nullObject) {
return false; return false;
} }
......
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
* @version $Revision: 3192 $ * @version $Revision: 3192 $
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
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 * @var array $_aliasMap two dimensional array containing the map for query aliases
...@@ -54,12 +54,17 @@ abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable ...@@ -54,12 +54,17 @@ abstract class Doctrine_Hydrator_Abstract extends Doctrine_Locator_Injectable
*/ */
protected $_hydrationMode = Doctrine::HYDRATE_RECORD; protected $_hydrationMode = Doctrine::HYDRATE_RECORD;
protected $_nullObject;
/** /**
* constructor * constructor
* *
* @param Doctrine_Connection|null $connection * @param Doctrine_Connection|null $connection
*/ */
public function __construct() {} public function __construct()
{
$this->_nullObject = Doctrine_Null::$INSTANCE;
}
/** /**
* Sets the fetchmode. * Sets the fetchmode.
......
...@@ -32,10 +32,16 @@ ...@@ -32,10 +32,16 @@
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org> * @author Roman Borschel <roman@code-factory.org>
*/ */
class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable class Doctrine_Hydrator_RecordDriver
{ {
protected $_collections = array(); protected $_collections = array();
protected $_mappers = array(); protected $_mappers = array();
private $_nullObject;
public function __construct()
{
$this->_nullObject = Doctrine_Null::$INSTANCE;
}
public function getElementCollection($component) public function getElementCollection($component)
{ {
...@@ -98,7 +104,7 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable ...@@ -98,7 +104,7 @@ class Doctrine_Hydrator_RecordDriver extends Doctrine_Locator_Injectable
public function getNullPointer() public function getNullPointer()
{ {
return self::$_null; return $this->_nullObject;
} }
public function getElement(array $data, $className) public function getElement(array $data, $className)
......
...@@ -77,7 +77,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -77,7 +77,6 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera
private function __construct() private function __construct()
{ {
$this->_root = dirname(__FILE__); $this->_root = dirname(__FILE__);
Doctrine_Locator_Injectable::initNullObject(new Doctrine_Null);
} }
/** /**
...@@ -543,7 +542,7 @@ class Doctrine_Manager extends Doctrine_Configurable implements Countable, Itera ...@@ -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 * @return Doctrine_RawSql
*/ */
......
...@@ -86,7 +86,7 @@ class Doctrine_Mapper ...@@ -86,7 +86,7 @@ class Doctrine_Mapper
$this->_domainClassName = $name; $this->_domainClassName = $name;
$this->_conn = $classMetadata->getConnection(); $this->_conn = $classMetadata->getConnection();
$this->_classMetadata = $classMetadata; $this->_classMetadata = $classMetadata;
$this->_nullObject = Doctrine_Null::getInstance(); $this->_nullObject = Doctrine_Null::$INSTANCE;
if ($classMetadata->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED) { if ($classMetadata->getInheritanceType() == Doctrine::INHERITANCETYPE_JOINED) {
$this->_mappingStrategy = new Doctrine_Mapper_JoinedStrategy($this); $this->_mappingStrategy = new Doctrine_Mapper_JoinedStrategy($this);
} else { } else {
......
...@@ -33,17 +33,16 @@ ...@@ -33,17 +33,16 @@
* @version $Revision$ * @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
// static initializer
Doctrine_Null::$INSTANCE = new Doctrine_Null();
final class Doctrine_Null final class Doctrine_Null
{ {
private static $_instance; public static $INSTANCE;
public function __construct() {} public function __construct() {}
public static function getInstance() public static function getInstance()
{ {
if (is_null(self::$_instance)) { return self::$INSTANCE;
self::$_instance = new Doctrine_Null();
}
return self::$_instance;
} }
public function exists() public function exists()
......
...@@ -208,7 +208,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -208,7 +208,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{ {
if (isset($mapper) && $mapper instanceof Doctrine_Mapper) { if (isset($mapper) && $mapper instanceof Doctrine_Mapper) {
$class = get_class($this); $class = get_class($this);
$this->_mapper = Doctrine_Manager::getInstance()->getMapper($class); $this->_mapper = $mapper;
$this->_class = $this->_mapper->getClassMetadata(); $this->_class = $this->_mapper->getClassMetadata();
$exists = ! $isNewEntry; $exists = ! $isNewEntry;
} else { } else {
...@@ -263,16 +263,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -263,16 +263,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return self::$_index; 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 * construct
* Empty template method to provide concrete Record classes with the possibility * Empty template method to provide concrete Record classes with the possibility
...@@ -485,7 +475,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -485,7 +475,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
continue; continue;
} }
if ($value === self::$_null || $overwrite) { if ($value === Doctrine_Null::$INSTANCE || $overwrite) {
$this->_data[$column] = $default; $this->_data[$column] = $default;
$this->_modified[] = $column; $this->_modified[] = $column;
$this->_state = Doctrine_Record::STATE_TDIRTY; $this->_state = Doctrine_Record::STATE_TDIRTY;
...@@ -513,9 +503,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -513,9 +503,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if (isset($tmp[$fieldName])) { if (isset($tmp[$fieldName])) {
$data[$fieldName] = $tmp[$fieldName]; $data[$fieldName] = $tmp[$fieldName];
} else if (array_key_exists($fieldName, $tmp)) { } else if (array_key_exists($fieldName, $tmp)) {
$data[$fieldName] = self::$_null; $data[$fieldName] = Doctrine_Null::$INSTANCE;
} else if (!isset($this->_data[$fieldName])) { } else if (!isset($this->_data[$fieldName])) {
$data[$fieldName] = self::$_null; $data[$fieldName] = Doctrine_Null::$INSTANCE;
} }
unset($tmp[$fieldName]); unset($tmp[$fieldName]);
} }
...@@ -554,7 +544,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -554,7 +544,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$name = (array)$this->_class->getIdentifier(); $name = (array)$this->_class->getIdentifier();
$name = $name[0]; $name = $name[0];
if ($exists) { 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]; $this->_id[$name] = $this->_data[$name];
} }
} }
...@@ -563,7 +553,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -563,7 +553,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$names = (array)$this->_class->getIdentifier(); $names = (array)$this->_class->getIdentifier();
foreach ($names as $name) { foreach ($names as $name) {
if ($this->_data[$name] === self::$_null) { if ($this->_data[$name] === Doctrine_Null::$INSTANCE) {
$this->_id[$name] = null; $this->_id[$name] = null;
} else { } else {
$this->_id[$name] = $this->_data[$name]; $this->_id[$name] = $this->_data[$name];
...@@ -600,7 +590,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -600,7 +590,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach ($this->_data as $k => $v) { foreach ($this->_data as $k => $v) {
if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') { if ($v instanceof Doctrine_Record && $this->_class->getTypeOf($k) != 'object') {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else if ($v === self::$_null) { } else if ($v === Doctrine_Null::$INSTANCE) {
unset($vars['_data'][$k]); unset($vars['_data'][$k]);
} else { } else {
switch ($this->_class->getTypeOf($k)) { switch ($this->_class->getTypeOf($k)) {
...@@ -838,7 +828,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -838,7 +828,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ( ! isset($this->_data[$fieldName])) { if ( ! isset($this->_data[$fieldName])) {
throw new Doctrine_Record_Exception('Unknown property '. $fieldName); throw new Doctrine_Record_Exception('Unknown property '. $fieldName);
} }
if ($this->_data[$fieldName] === self::$_null) { if ($this->_data[$fieldName] === Doctrine_Null::$INSTANCE) {
return null; return null;
} }
...@@ -895,15 +885,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -895,15 +885,16 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}*/ }*/
// Use built-in accessor functionality // Use built-in accessor functionality
$value = self::$_null; $nullObj = Doctrine_Null::$INSTANCE;
$value = $nullObj;
if (isset($this->_data[$fieldName])) { if (isset($this->_data[$fieldName])) {
if ($this->_data[$fieldName] !== self::$_null) { if ($this->_data[$fieldName] !== $nullObj) {
return $this->_data[$fieldName]; return $this->_data[$fieldName];
} }
if ($this->_data[$fieldName] === self::$_null && $load) { if ($this->_data[$fieldName] === $nullObj && $load) {
$this->load(); $this->load();
} }
if ($this->_data[$fieldName] === self::$_null) { if ($this->_data[$fieldName] === $nullObj) {
$value = null; $value = null;
} }
return $value; return $value;
...@@ -982,7 +973,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -982,7 +973,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if ($old !== $value) { if ($old !== $value) {
if ($value === null) { if ($value === null) {
$value = self::$_null; $value = Doctrine_Null::$INSTANCE;
} }
$this->_data[$fieldName] = $value; $this->_data[$fieldName] = $value;
...@@ -1032,7 +1023,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1032,7 +1023,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return $this; return $this;
} }
} else { } else {
if ($value !== self::$_null) { if ($value !== Doctrine_Null::$INSTANCE) {
$relatedTable = $value->getTable(); $relatedTable = $value->getTable();
$foreignFieldName = $rel->getForeignFieldName(); $foreignFieldName = $rel->getForeignFieldName();
$localFieldName = $rel->getLocalFieldName(); $localFieldName = $rel->getLocalFieldName();
...@@ -1083,7 +1074,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1083,7 +1074,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
return true; return true;
} }
if (isset($this->_references[$fieldName]) && if (isset($this->_references[$fieldName]) &&
$this->_references[$fieldName] !== self::$_null) { $this->_references[$fieldName] !== Doctrine_Null::$INSTANCE) {
return true; return true;
} }
return false; return false;
...@@ -1100,7 +1091,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1100,7 +1091,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
} else if (isset($this->_references[$fieldName])) { } else if (isset($this->_references[$fieldName])) {
if ($this->_references[$fieldName] instanceof Doctrine_Record) { if ($this->_references[$fieldName] instanceof Doctrine_Record) {
// todo: delete related record when saving $this // 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) { } else if ($this->_references[$fieldName] instanceof Doctrine_Collection) {
$this->_references[$fieldName]->setData(array()); $this->_references[$fieldName]->setData(array());
} }
...@@ -1211,7 +1202,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1211,7 +1202,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
foreach ($modifiedFields as $field) { foreach ($modifiedFields as $field) {
$type = $this->_class->getTypeOf($field); $type = $this->_class->getTypeOf($field);
if ($this->_data[$field] === self::$_null) { if ($this->_data[$field] === Doctrine_Null::$INSTANCE) {
$dataSet[$field] = null; $dataSet[$field] = null;
continue; continue;
} }
...@@ -1286,7 +1277,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite ...@@ -1286,7 +1277,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$a = array(); $a = array();
foreach ($this as $column => $value) { foreach ($this as $column => $value) {
if ($value === self::$_null || is_object($value)) { if ($value === Doctrine_Null::$INSTANCE || is_object($value)) {
$value = null; $value = null;
} }
$a[$column] = $value; $a[$column] = $value;
......
...@@ -138,7 +138,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence ...@@ -138,7 +138,7 @@ class Doctrine_Sequence_Mssql extends Doctrine_Sequence
$query = 'SELECT @@IDENTITY'; $query = 'SELECT @@IDENTITY';
} }
return $this->conn->fetchOne($query); return (string) floor((float) $this->conn->fetchOne($query));
} }
/** /**
......
...@@ -29,9 +29,10 @@ ...@@ -29,9 +29,10 @@
* @link www.phpdoctrine.org * @link www.phpdoctrine.org
* @since 1.0 * @since 1.0
* @version $Revision$ * @version $Revision$
* @author Roman Borschel <roman@code-factory.org>
* @author Konsta Vesterinen <kvesteri@cc.hut.fi> * @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/ */
class Doctrine_Validator extends Doctrine_Locator_Injectable class Doctrine_Validator
{ {
/** /**
* @var array $validators an array of validator objects * @var array $validators an array of validator objects
...@@ -50,6 +51,8 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable ...@@ -50,6 +51,8 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
$class = 'Doctrine_Validator_' . ucwords(strtolower($name)); $class = 'Doctrine_Validator_' . ucwords(strtolower($name));
if (class_exists($class)) { if (class_exists($class)) {
self::$validators[$name] = new $class; self::$validators[$name] = new $class;
} else if (class_exists($name)) {
self::$validators[$name] = new $name;
} else { } else {
throw new Doctrine_Exception("Validator named '$name' not available."); throw new Doctrine_Exception("Validator named '$name' not available.");
} }
...@@ -78,7 +81,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable ...@@ -78,7 +81,7 @@ class Doctrine_Validator extends Doctrine_Locator_Injectable
$fields = ($record->exists()) ? $record->getModified() : $record->getData(); $fields = ($record->exists()) ? $record->getModified() : $record->getData();
$err = array(); $err = array();
foreach ($fields as $fieldName => $value) { foreach ($fields as $fieldName => $value) {
if ($value === self::$_null) { if ($value === Doctrine_Null::$INSTANCE) {
$value = null; $value = null;
} else if ($value instanceof Doctrine_Record) { } else if ($value instanceof Doctrine_Record) {
$value = $value->getIncremented(); $value = $value->getIncremented();
......
This diff is collapsed.
...@@ -81,7 +81,7 @@ class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase ...@@ -81,7 +81,7 @@ class Doctrine_Relation_OneToOne_TestCase extends Doctrine_UnitTestCase
$user->Email = $email; $user->Email = $email;
$user->save(); $user->save();
$this->assertTrue($user->Email instanceOf Email); $this->assertTrue($user->Email instanceOf Email);
$user->Email = Email::getNullObject(); $user->Email = Doctrine_Null::$INSTANCE;
$user->save(); $user->save();
$this->assertTrue($user->Email instanceOf Doctrine_Null); $this->assertTrue($user->Email instanceOf Doctrine_Null);
} }
......
...@@ -303,6 +303,11 @@ $data->addTestCase(new Doctrine_Data_Import_TestCase()); ...@@ -303,6 +303,11 @@ $data->addTestCase(new Doctrine_Data_Import_TestCase());
$data->addTestCase(new Doctrine_Data_Export_TestCase()); $data->addTestCase(new Doctrine_Data_Export_TestCase());
$test->addTestCase($data); $test->addTestCase($data);
$s = microtime(true);
$test->run(); $test->run();
$e = microtime(true);
echo memory_get_peak_usage() / 1024 . "\n"; echo 'test run took: ' . ($e - $s) . ' seconds<br />';
echo "peak memory usage: " . memory_get_peak_usage() / 1024 . "KB\n";
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment