Skip to content

Commit

Permalink
[2.0] Code cleanups. Preparations for DDC-193. Fixed DDC-399, type co…
Browse files Browse the repository at this point in the history
…nfiguration remains global for now but the irritating instance methods on the Configuration have been removed. Use Type::addType et al. Added TODOs for naming standards.
  • Loading branch information
romanb committed Mar 15, 2010
1 parent ed94a34 commit a53c2fb
Show file tree
Hide file tree
Showing 50 changed files with 498 additions and 903 deletions.
93 changes: 8 additions & 85 deletions UPGRADE_TO_2_0
Original file line number Diff line number Diff line change
@@ -1,102 +1,25 @@
> **NOTE**
> This document does not describe how to upgrade from Doctrine 1.x to Doctrine 2 as this is a more
> complicated process.

# Upgrade from 2.0-ALPHA4 to 2.0 ...
# Upgrade from 2.0-ALPHA4 to 2.0-BETA1

## Default Property for Field Mappings removed
## Default Property for Field Mappings

The "default" option for database column defaults has been removed. If desired database column defaults can
be implemented by using the @columnDefinition annotation (or the approriate XML and YAML equivalents).

Additionally keep in mind that Doctrine's focus in on objects and you can specifiy default values for an Entitiy's
mapped fields inside PHP easily. Upon persist() invocation these values are saved as if they were default values.
The "default" option for database column defaults has been removed. If desired, database column defaults can
be implemented by using the columnDefinition attribute of the @Column annotation (or the approriate XML and YAML equivalents).
Prefer PHP default values, if possible.

## Partial Objects

xxx

## XML Mapping Driver

The 'inheritance-type' attribute changed to take last bit of ClassMetadata constant names, i.e.
NONE, SINGLE_TABLE, INHERITANCE_TYPE_JOINED

## Change of PreUpdate Event Listener
## PreUpdate Event Listeners

Event Listeners listening to the 'preUpdate' event can only affect the primitive values of entity changesets
by using the API on the `PreUpdateEventArgs` instance passed to the preUpdate listener method. Any changes
to the state of the entitys properties won't affect the database UPDATE statement anymore. This gives drastic
performance benefits for the preUpdate event.

# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4

## CLI Controller changes

CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:

[php]
$cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');


## CLI Tasks documentation

Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.

## Changes in Method Signatures

* A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
have changed quite significantly by adopting the new Schema instance objects.

## Renamed Methods

* Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
* Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()

## SchemaTool Changes

* "doctrine schema-tool --drop" now always drops the complete database instead of
only those tables defined by the current database model. The previous method had
problems when foreign keys of orphaned tables pointed to tables that were schedulded
for deletion.
* Use "doctrine schema-tool --update" to get a save incremental update for your
database schema without deleting any unused tables, sequences or foreign keys.
* Use "doctrine schema-tool --complete-update" to do a full incremental update of
your schema.


# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3

This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
to upgrade your projects to use this version.

## CLI Changes

The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.

## Proxy class changes

You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:

[php]
// step 1: configure directory for proxy classes
// $config instanceof Doctrine\ORM\Configuration
$config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
$config->setProxyNamespace('MyProject\Generated\Proxies');

Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
Generating the proxy classes into a namespace within your class library is the recommended setup.

Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.

For more details refer to the Configuration section of the manual.

## Removed allowPartialObjects configuration option

The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.

## Renamed Methods

* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)

35 changes: 35 additions & 0 deletions UPGRADE_TO_ALPHA3
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Upgrade from 2.0-ALPHA2 to 2.0-ALPHA3

This section details the changes made to Doctrine 2.0-ALPHA3 to make it easier for you
to upgrade your projects to use this version.

## CLI Changes

The $args variable used in the cli-config.php for configuring the Doctrine CLI has been renamed to $globalArguments.

## Proxy class changes

You are now required to make supply some minimalist configuration with regards to proxy objects. That involves 2 new configuration options. First, the directory where generated proxy classes should be placed needs to be specified. Secondly, you need to configure the namespace used for proxy classes. The following snippet shows an example:

[php]
// step 1: configure directory for proxy classes
// $config instanceof Doctrine\ORM\Configuration
$config->setProxyDir('/path/to/myproject/lib/MyProject/Generated/Proxies');
$config->setProxyNamespace('MyProject\Generated\Proxies');

Note that proxy classes behave exactly like any other classes when it comes to class loading. Therefore you need to make sure the proxy classes can be loaded by some class loader. If you place the generated proxy classes in a namespace and directory under your projects class files, like in the example above, it would be sufficient to register the MyProject namespace on a class loader. Since the proxy classes are contained in that namespace and adhere to the standards for class loading, no additional work is required.
Generating the proxy classes into a namespace within your class library is the recommended setup.

Entities with initialized proxy objects can now be serialized and unserialized properly from within the same application.

For more details refer to the Configuration section of the manual.

## Removed allowPartialObjects configuration option

The allowPartialObjects configuration option together with the `Configuration#getAllowPartialObjects` and `Configuration#setAllowPartialObjects` methods have been removed.
The new behavior is as if the option were set to FALSE all the time, basically disallowing partial objects globally. However, you can still use the `Query::HINT_FORCE_PARTIAL_LOAD` query hint to force a query to return partial objects for optimization purposes.

## Renamed Methods

* Doctrine\ORM\Configuration#getCacheDir() to getProxyDir()
* Doctrine\ORM\Configuration#setCacheDir($dir) to setProxyDir($dir)
36 changes: 36 additions & 0 deletions UPGRADE_TO_ALPHA4
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Upgrade from 2.0-ALPHA3 to 2.0-ALPHA4

## CLI Controller changes

CLI main object changed its name and namespace. Renamed from Doctrine\ORM\Tools\Cli to Doctrine\Common\Cli\CliController.
Doctrine\Common\Cli\CliController now only deals with namespaces. Ready to go, Core, Dbal and Orm are available and you can subscribe new tasks by retrieving the namespace and including new task. Example:

[php]
$cli->getNamespace('Core')->addTask('my-example', '\MyProject\Tools\Cli\Tasks\MyExampleTask');


## CLI Tasks documentation

Tasks have implemented a new way to build documentation. Although it is still possible to define the help manually by extending the basicHelp and extendedHelp, they are now optional.
With new required method AbstractTask::buildDocumentation, its implementation defines the TaskDocumentation instance (accessible through AbstractTask::getDocumentation()), basicHelp and extendedHelp are now not necessary to be implemented.

## Changes in Method Signatures

* A bunch of Methods on both Doctrine\DBAL\Platforms\AbstractPlatform and Doctrine\DBAL\Schema\AbstractSchemaManager
have changed quite significantly by adopting the new Schema instance objects.

## Renamed Methods

* Doctrine\ORM\AbstractQuery::setExpireResultCache() -> expireResultCache()
* Doctrine\ORM\Query::setExpireQueryCache() -> expireQueryCache()

## SchemaTool Changes

* "doctrine schema-tool --drop" now always drops the complete database instead of
only those tables defined by the current database model. The previous method had
problems when foreign keys of orphaned tables pointed to tables that were schedulded
for deletion.
* Use "doctrine schema-tool --update" to get a save incremental update for your
database schema without deleting any unused tables, sequences or foreign keys.
* Use "doctrine schema-tool --complete-update" to do a full incremental update of
your schema.
1 change: 1 addition & 0 deletions lib/Doctrine/Common/Cache/ApcCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @author Jonathan Wage <[email protected]>
* @author Roman Borschel <[email protected]>
* @author David Abdemoulaie <[email protected]>
* @todo Rename: APCCache
*/
class ApcCache extends AbstractCache
{
Expand Down
33 changes: 3 additions & 30 deletions lib/Doctrine/DBAL/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Configuration
* @var array
*/
protected $_attributes = array();

/**
* Creates a new DBAL configuration instance.
*/
Expand All @@ -56,7 +56,7 @@ public function __construct()
'sqlLogger' => null
);
}

/**
* Sets the SQL logger to use. Defaults to NULL which means SQL logging is disabled.
*
Expand All @@ -66,7 +66,7 @@ public function setSqlLogger($logger)
{
$this->_attributes['sqlLogger'] = $logger;
}

/**
* Gets the SQL logger that is used.
*
Expand All @@ -76,31 +76,4 @@ public function getSqlLogger()
{
return $this->_attributes['sqlLogger'];
}

/**
* Defines new custom types to be supported by Doctrine
*
* @param array $types Key-value map of types to include
* @param boolean $override Optional flag to support only inclusion or also override
*/
public function setCustomTypes(array $types, $override = false)
{
foreach ($types as $name => $typeClassName) {
$method = (Type::hasType($name) && $override ? 'override' : 'add') . 'Type';

Type::$method($name, $typeClassName);
}
}

/**
* Overrides existent types in Doctrine
*
* @param array $types Key-value map of types to override
*/
public function setTypeOverrides(array $overrides)
{
foreach ($override as $name => $typeClassName) {
Type::overrideType($name, $typeClassName);
}
}
}
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Connection
*/
const FETCH_ASSOC = 2;
const FETCH_BOTH = 4;
const FETCH_COLUMN = 7;
//const FETCH_COLUMN = 7; Apparently not used.
const FETCH_NUM = 3;
const ATTR_AUTOCOMMIT = 0;

Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Logging/EchoSqlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Roman Borschel <[email protected]>
* @since 2.0
* @todo Rename: EchoSQLLogger
*/
class EchoSqlLogger implements SqlLogger
{
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Logging/SqlLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*
* @author Roman Borschel <[email protected]>
* @since 2.0
* @todo Rename: SQLLogger
*/
interface SqlLogger
{
Expand Down
2 changes: 1 addition & 1 deletion lib/Doctrine/DBAL/Platforms/AbstractPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,7 +579,7 @@ public function getDropForeignKeySQL($foreignKey, $table)
*/
public function getCreateTableSQL(Table $table, $createFlags=self::CREATE_INDEXES)
{
if (!is_int($createFlags)) {
if ( ! is_int($createFlags)) {
throw new \InvalidArgumentException("Second argument of AbstractPlatform::getCreateTableSQL() has to be integer.");
}

Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Platforms/MsSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @author Roman Borschel <[email protected]>
* @author Jonathan H. Wage <[email protected]>
* @author Benjamin Eberlei <[email protected]>
* @todo Rename: MsSQLPlatform
*/
class MsSqlPlatform extends AbstractPlatform
{
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Platforms/MySqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
* @since 2.0
* @author Roman Borschel <[email protected]>
* @author Benjamin Eberlei <[email protected]>
* @todo Rename: MySQLPlatform
*/
class MySqlPlatform extends AbstractPlatform
{
Expand Down
9 changes: 5 additions & 4 deletions lib/Doctrine/DBAL/Platforms/PostgreSqlPlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@

namespace Doctrine\DBAL\Platforms;

use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Schema\TableDiff,
Doctrine\DBAL\Schema\Table;

/**
* PostgreSqlPlatform.
Expand All @@ -30,6 +31,7 @@
* @author Roman Borschel <[email protected]>
* @author Lukas Smith <[email protected]> (PEAR MDB2 library)
* @author Benjamin Eberlei <[email protected]>
* @todo Rename: PostgreSQLPlatform
*/
class PostgreSqlPlatform extends AbstractPlatform
{
Expand Down Expand Up @@ -281,7 +283,7 @@ public function getCreateDatabaseSQL($name)
{
return 'CREATE DATABASE ' . $name;
}

/**
* drop an existing database
*
Expand All @@ -293,9 +295,8 @@ public function getDropDatabaseSQL($name)
{
return 'DROP DATABASE ' . $name;
}

/**
* getAdvancedForeignKeyOptions
* Return the FOREIGN KEY query section dealing with non-standard options
* as MATCH, INITIALLY DEFERRED, ON UPDATE, ...
*
Expand Down
1 change: 1 addition & 0 deletions lib/Doctrine/DBAL/Platforms/SqlitePlatform.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @since 2.0
* @author Roman Borschel <[email protected]>
* @author Benjamin Eberlei <[email protected]>
* @todo Rename: SQLitePlatform
*/
class SqlitePlatform extends AbstractPlatform
{
Expand Down
6 changes: 3 additions & 3 deletions lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@

namespace Doctrine\DBAL\Schema;

use \Doctrine\DBAL\Types;
use \Doctrine\DBAL\DBALException;
use \Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Platforms\AbstractPlatform;

/**
* Base class for schema managers. Schema managers are used to inspect and/or
Expand Down
19 changes: 19 additions & 0 deletions lib/Doctrine/DBAL/Types/StringType.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
<?php
/*
* $Id$
*
* 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 LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/

namespace Doctrine\DBAL\Types;

Expand Down
Loading

0 comments on commit a53c2fb

Please sign in to comment.