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
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
......
......@@ -33,7 +33,7 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
abstract class Doctrine_Access extends Doctrine_Locator_Injectable implements ArrayAccess
abstract class Doctrine_Access implements ArrayAccess
{
/**
* setArray
......
......@@ -31,7 +31,7 @@
* @version $Revision$
* @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
......
......@@ -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) . ']';
}
......
......@@ -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;
}
......
......@@ -30,7 +30,7 @@
* @version $Revision: 3192 $
* @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
......@@ -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.
......
......@@ -32,10 +32,16 @@
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
*/
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)
......
......@@ -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
*/
......
......@@ -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 {
......
......@@ -33,17 +33,16 @@
* @version $Revision$
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
*/
// 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()
......
......@@ -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;
......
......@@ -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));
}
/**
......
......@@ -29,14 +29,15 @@
* @link www.phpdoctrine.org
* @since 1.0
* @version $Revision$
* @author Roman Borschel <roman@code-factory.org>
* @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
*/
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();
......
This diff is collapsed.
......@@ -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);
}
......
......@@ -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<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