From dca09148ca8558c93fcbb3dc3c074eac94cdfe19 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Sun, 22 Sep 2013 02:12:30 +0200 Subject: [PATCH 01/12] CS fixes --- lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php | 2 +- lib/Doctrine/ORM/Persisters/BasicEntityPersister.php | 2 +- lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php | 2 +- lib/Doctrine/ORM/Query/Parser.php | 6 +++--- lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php | 2 +- .../ORM/Tools/Pagination/LimitSubqueryOutputWalker.php | 4 ++-- lib/Doctrine/ORM/UnitOfWork.php | 2 +- 7 files changed, 10 insertions(+), 10 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php index fafc497c0..859bd0b00 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ObjectHydrator.php @@ -477,7 +477,7 @@ class ObjectHydrator extends AbstractHydrator $targetClass = $this->ce[$relation['targetEntity']]; if ($relation['isOwningSide']) { - //TODO: Just check hints['fetched'] here? + // TODO: Just check hints['fetched'] here? // If there is an inverse mapping on the target class its bidirectional if ($relation['inversedBy']) { $inverseAssoc = $targetClass->associationMappings[$relation['inversedBy']]; diff --git a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php index 00b00cfa2..fc9b5cbe0 100644 --- a/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php +++ b/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php @@ -328,7 +328,7 @@ class BasicEntityPersister $identifier = $this->quoteStrategy->getIdentifierColumnNames($versionedClass, $this->platform); $columnName = $this->quoteStrategy->getColumnName($versionField, $versionedClass, $this->platform); - //FIXME: Order with composite keys might not be correct + // FIXME: Order with composite keys might not be correct $sql = 'SELECT ' . $columnName . ' FROM ' . $tableName . ' WHERE ' . implode(' = ? AND ', $identifier) . ' = ?'; diff --git a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php index 58f0dde13..242a38bcf 100644 --- a/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php +++ b/lib/Doctrine/ORM/Query/AST/Functions/IdentityFunction.php @@ -82,7 +82,7 @@ class IdentityFunction extends FunctionNode } } - //The table with the relation may be a subclass, so get the table name from the association definition + // The table with the relation may be a subclass, so get the table name from the association definition $tableName = $sqlWalker->getEntityManager()->getClassMetadata($assoc['sourceEntity'])->getTableName(); $tableAlias = $sqlWalker->getSQLTableAlias($tableName, $dqlAlias); diff --git a/lib/Doctrine/ORM/Query/Parser.php b/lib/Doctrine/ORM/Query/Parser.php index 5c721a1d5..8ee9fed92 100644 --- a/lib/Doctrine/ORM/Query/Parser.php +++ b/lib/Doctrine/ORM/Query/Parser.php @@ -1878,7 +1878,7 @@ class Parser case ($lookahead === Lexer::T_OPEN_PARENTHESIS): return $this->SimpleArithmeticExpression(); - //this check must be done before checking for a filed path expression + // this check must be done before checking for a filed path expression case ($this->isFunction()): $this->lexer->peek(); // "(" @@ -1896,7 +1896,7 @@ class Parser } break; - //it is no function, so it must be a field path + // it is no function, so it must be a field path case ($lookahead === Lexer::T_IDENTIFIER): $this->lexer->peek(); // lookahead => '.' $this->lexer->peek(); // lookahead => token after '.' @@ -2431,7 +2431,7 @@ class Parser switch ($peek['value']) { case '(': - //Peeks beyond the matched closing parenthesis. + // Peeks beyond the matched closing parenthesis. $token = $this->peekBeyondClosingParenthesis(false); if ($token['type'] === Lexer::T_NOT) { diff --git a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php index d40d0786e..a0216bf91 100644 --- a/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php +++ b/lib/Doctrine/ORM/Tools/Export/Driver/AbstractExporter.php @@ -134,7 +134,7 @@ abstract class AbstractExporter } foreach ($this->_metadata as $metadata) { - //In case output is returned, write it to a file, skip otherwise + // In case output is returned, write it to a file, skip otherwise if($output = $this->exportClassMetadata($metadata)){ $path = $this->_generateOutputPath($metadata); $dir = dirname($path); diff --git a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php index 2ee5f9056..97140ecf1 100644 --- a/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php +++ b/lib/Doctrine/ORM/Tools/Pagination/LimitSubqueryOutputWalker.php @@ -162,7 +162,7 @@ class LimitSubqueryOutputWalker extends SqlWalker if ($this->platform instanceof PostgreSqlPlatform || $this->platform instanceof OraclePlatform) { - //http://www.doctrine-project.org/jira/browse/DDC-1958 + // http://www.doctrine-project.org/jira/browse/DDC-1958 $this->preserveSqlOrdering($AST, $sqlIdentifier, $innerSql, $sql); } @@ -211,7 +211,7 @@ class LimitSubqueryOutputWalker extends SqlWalker } } } - //remove identifier aliases + // remove identifier aliases $sqlOrderColumns = array_diff($sqlOrderColumns, $sqlIdentifier); } diff --git a/lib/Doctrine/ORM/UnitOfWork.php b/lib/Doctrine/ORM/UnitOfWork.php index 5de769f63..d00a87af7 100644 --- a/lib/Doctrine/ORM/UnitOfWork.php +++ b/lib/Doctrine/ORM/UnitOfWork.php @@ -2406,7 +2406,7 @@ class UnitOfWork implements PropertyChangedListener { $coid = spl_object_hash($coll); - //TODO: if $coll is already scheduled for recreation ... what to do? + // TODO: if $coll is already scheduled for recreation ... what to do? // Just remove $coll from the scheduled recreations? if (isset($this->collectionUpdates[$coid])) { unset($this->collectionUpdates[$coid]); From 195b1169aeb6ddf8f9e6ea0fcbd4662b005561ea Mon Sep 17 00:00:00 2001 From: flack Date: Wed, 23 Oct 2013 11:32:04 +0200 Subject: [PATCH 02/12] Spelling fix --- docs/en/reference/unitofwork.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/unitofwork.rst b/docs/en/reference/unitofwork.rst index f01c3f91d..cdfb6e0be 100644 --- a/docs/en/reference/unitofwork.rst +++ b/docs/en/reference/unitofwork.rst @@ -157,7 +157,7 @@ wishes to be hydrated. Default result-types include: - SQL to a single result variable Hydration to entities and arrays is one of most complex parts of Doctrine -algorithm-wise. It can built results with for example: +algorithm-wise. It can build results with for example: - Single table selects - Joins with n:1 or 1:n cardinality, grouping belonging to the same parent. From 7249804e3fbdac1d8e57851600d3f34d43a5828e Mon Sep 17 00:00:00 2001 From: Chris Collins Date: Thu, 24 Oct 2013 13:02:42 +0100 Subject: [PATCH 03/12] Added a failing test case for DDC-2759. --- .../ORM/Functional/Ticket/DDC2759Test.php | 121 ++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php new file mode 100644 index 000000000..a071d4c0c --- /dev/null +++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC2759Test.php @@ -0,0 +1,121 @@ +_schemaTool->createSchema(array( + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2759Qualification'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2759Category'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2759QualificationMetadata'), + $this->_em->getClassMetadata(__NAMESPACE__ . '\DDC2759MetadataCategory'), + )); + } catch(\Exception $e) { + return; + } + + $qualification = new DDC2759Qualification(); + $qualificationMetadata = new DDC2759QualificationMetadata($qualification); + + $category1 = new DDC2759Category(); + $category2 = new DDC2759Category(); + + $metadataCategory1 = new DDC2759MetadataCategory($qualificationMetadata, $category1); + $metadataCategory2 = new DDC2759MetadataCategory($qualificationMetadata, $category2); + + $this->_em->persist($qualification); + $this->_em->persist($qualificationMetadata); + + $this->_em->persist($category1); + $this->_em->persist($category2); + + $this->_em->persist($metadataCategory1); + $this->_em->persist($metadataCategory2); + + $this->_em->flush(); + $this->_em->clear(); + } + + public function testCorrectNumberOfAssociationsIsReturned() + { + $repository = $this->_em->getRepository(__NAMESPACE__ . '\DDC2759Qualification'); + + $builder = $repository->createQueryBuilder('q') + ->select('q, qm, qmc') + ->innerJoin('q.metadata', 'qm') + ->innerJoin('qm.metadataCategories', 'qmc'); + + $result = $builder->getQuery() + ->getArrayResult(); + + $this->assertCount(2, $result[0]['metadata']['metadataCategories']); + } +} + +/** @Entity @Table(name="ddc_2759_qualification") */ +class DDC2759Qualification +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** @OneToOne(targetEntity="DDC2759QualificationMetadata", mappedBy="content") */ + public $metadata; +} + +/** @Entity @Table(name="ddc_2759_category") */ +class DDC2759Category +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** @OneToMany(targetEntity="DDC2759MetadataCategory", mappedBy="category") */ + public $metadataCategories; +} + +/** @Entity @Table(name="ddc_2759_qualification_metadata") */ +class DDC2759QualificationMetadata +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** @OneToOne(targetEntity="DDC2759Qualification", inversedBy="metadata") */ + public $content; + + /** @OneToMany(targetEntity="DDC2759MetadataCategory", mappedBy="metadata") */ + protected $metadataCategories; + + public function __construct(DDC2759Qualification $content) + { + $this->content = $content; + } +} + +/** @Entity @Table(name="ddc_2759_metadata_category") */ +class DDC2759MetadataCategory +{ + /** @Id @Column(type="integer") @GeneratedValue */ + public $id; + + /** @ManyToOne(targetEntity="DDC2759QualificationMetadata", inversedBy="metadataCategories") */ + public $metadata; + + /** @ManyToOne(targetEntity="DDC2759Category", inversedBy="metadataCategories") */ + public $category; + + public function __construct(DDC2759QualificationMetadata $metadata, DDC2759Category $category) + { + $this->metadata = $metadata; + $this->category = $category; + } +} From 9a3298347c5319eed73805d13ca4f75d87736b9c Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 26 Oct 2013 11:16:07 +0200 Subject: [PATCH 04/12] [DDC-2759] Fix regression in ArrayHydrator introduced in DDC-1884 at SHA c7b4c9bf0fbc5dca830e0a797cea470510def994 --- lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php index 5688d8652..c336e7a5d 100644 --- a/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php +++ b/lib/Doctrine/ORM/Internal/Hydration/ArrayHydrator.php @@ -190,17 +190,14 @@ class ArrayHydrator extends AbstractHydrator ( ! isset($baseElement[$relationAlias])) ) { $baseElement[$relationAlias] = null; - } else if ( - ( ! isset($baseElement[$relationAlias])) || - ( ! isset($this->_identifierMap[$path][$id[$parent]][$id[$dqlAlias]])) - ) { + } else if ( ! isset($baseElement[$relationAlias])) { $baseElement[$relationAlias] = $data; } } $coll =& $baseElement[$relationAlias]; - if ($coll !== null) { + if (is_array($coll)) { $this->updateResultPointer($coll, $index, $dqlAlias, $oneToOne); } } else { From 514dd4e8528c47c47d97765ac041ce91d8147a36 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Sat, 26 Oct 2013 12:32:53 +0200 Subject: [PATCH 05/12] [DDC-2757] Update documentation with regard to manually closing the EntityManager when an Exception occurs. --- .../transactions-and-concurrency.rst | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/docs/en/reference/transactions-and-concurrency.rst b/docs/en/reference/transactions-and-concurrency.rst index 1b06156e9..4dc18318e 100644 --- a/docs/en/reference/transactions-and-concurrency.rst +++ b/docs/en/reference/transactions-and-concurrency.rst @@ -70,7 +70,6 @@ looks like this: $em->getConnection()->commit(); } catch (Exception $e) { $em->getConnection()->rollback(); - $em->close(); throw $e; } @@ -81,14 +80,12 @@ require an active transaction. Such methods will throw a ``TransactionRequiredException`` to inform you of that requirement. -A more convenient alternative for explicit transaction demarcation -is the use of provided control abstractions in the form of -``Connection#transactional($func)`` and -``EntityManager#transactional($func)``. When used, these control -abstractions ensure that you never forget to rollback the -transaction or close the ``EntityManager``, apart from the obvious -code reduction. An example that is functionally equivalent to the -previously shown code looks as follows: +A more convenient alternative for explicit transaction demarcation is the use +of provided control abstractions in the form of +``Connection#transactional($func)`` and ``EntityManager#transactional($func)``. +When used, these control abstractions ensure that you never forget to rollback +the transaction, in addition to the obvious code reduction. An example that is +functionally equivalent to the previously shown code looks as follows: .. code-block:: php @@ -104,8 +101,8 @@ previously shown code looks as follows: The difference between ``Connection#transactional($func)`` and ``EntityManager#transactional($func)`` is that the latter abstraction flushes the ``EntityManager`` prior to transaction -commit and also closes the ``EntityManager`` properly when an -exception occurs (in addition to rolling back the transaction). +commit and rolls back the transaction when an +exception occurs. Exception Handling ~~~~~~~~~~~~~~~~~~ From 6eac308ca39e6d233cce3e26c3186e55e90f9725 Mon Sep 17 00:00:00 2001 From: Carlos Buenosvinos Date: Fri, 1 Nov 2013 12:11:01 +0100 Subject: [PATCH 06/12] Add example use of repositoryClass in YAML --- docs/en/reference/yaml-mapping.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/reference/yaml-mapping.rst b/docs/en/reference/yaml-mapping.rst index 1d7f8b17a..af2d404a5 100644 --- a/docs/en/reference/yaml-mapping.rst +++ b/docs/en/reference/yaml-mapping.rst @@ -72,6 +72,7 @@ of several common elements: # Doctrine.Tests.ORM.Mapping.User.dcm.yml Doctrine\Tests\ORM\Mapping\User: type: entity + repositoryClass: Doctrine\Tests\ORM\Mapping\UserRepository table: cms_users indexes: name_index: From 01dc0e8273186326e9b9d5af655dc56c35e62684 Mon Sep 17 00:00:00 2001 From: Michael Cummings Date: Sun, 3 Nov 2013 09:20:15 -0800 Subject: [PATCH 07/12] Update annotations-reference.rst @JoinTable because of mapping defaults does NOT have required attributes. Updated annotations reference to show them as optional. --- docs/en/reference/annotations-reference.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/reference/annotations-reference.rst b/docs/en/reference/annotations-reference.rst index 80ed01e7a..2ebc5c1f8 100644 --- a/docs/en/reference/annotations-reference.rst +++ b/docs/en/reference/annotations-reference.rst @@ -519,7 +519,7 @@ details of the database join table. If you do not specify @JoinTable on these relations reasonable mapping defaults apply using the affected table and the column names. -Required attributes: +Optional attributes: - **name**: Database name of the join-table From dc476b62d16a2a7267ca69f40022ce2be564e31a Mon Sep 17 00:00:00 2001 From: flack Date: Mon, 4 Nov 2013 19:16:04 +0100 Subject: [PATCH 08/12] Spelling fix --- docs/en/tutorials/getting-started.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/tutorials/getting-started.rst b/docs/en/tutorials/getting-started.rst index 817c56270..dc65b433c 100644 --- a/docs/en/tutorials/getting-started.rst +++ b/docs/en/tutorials/getting-started.rst @@ -381,7 +381,7 @@ better than in a scenario where updates are done for each entity in isolation. Doctrine follows the UnitOfWork pattern which additionally detects all entities that were fetched and have changed during the request. You don't have to keep track of -entities yourself, when Doctrine already knowns about them. +entities yourself, when Doctrine already knows about them. As a next step we want to fetch a list of all the products. Let's create a new script for this: From 8ad6853e8422e3b7cff32cda22cab79e8347043d Mon Sep 17 00:00:00 2001 From: flack Date: Mon, 4 Nov 2013 19:17:04 +0100 Subject: [PATCH 09/12] Spelling fix --- docs/en/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/index.rst b/docs/en/index.rst index 58753eb25..e7813561c 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -67,7 +67,7 @@ Advanced Topics * :doc:`Architecture ` * :doc:`Advanced Configuration ` -* :doc:`Limitations and knowns issues ` +* :doc:`Limitations and known issues ` * :doc:`Commandline Tools ` * :doc:`Transactions and Concurrency ` * :doc:`Filters ` From 0edf2bc585dab37c7d935aee34e240632fda2dac Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 7 Nov 2013 16:43:36 +0100 Subject: [PATCH 10/12] Add missing link to batch processing chapter --- docs/en/index.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/en/index.rst b/docs/en/index.rst index e7813561c..eb995278e 100644 --- a/docs/en/index.rst +++ b/docs/en/index.rst @@ -78,6 +78,7 @@ Advanced Topics * :doc:`Change Tracking Policies ` * :doc:`Best Practices ` * :doc:`Metadata Drivers ` +* :doc:`Batch Processing ` Tutorials --------- From 6cdd65762f136528d478974d4d2db942f3d75207 Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Tue, 12 Nov 2013 13:37:20 +0100 Subject: [PATCH 11/12] Add 2.4 branch [ci skip] --- README.markdown | 1 + 1 file changed, 1 insertion(+) diff --git a/README.markdown b/README.markdown index b6b60ac16..bf337b12f 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,7 @@ # Doctrine 2 ORM Master: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=master)](http://travis-ci.org/doctrine/doctrine2) +2.4: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.4)](http://travis-ci.org/doctrine/doctrine2) 2.3: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.3)](http://travis-ci.org/doctrine/doctrine2) 2.2: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.2)](http://travis-ci.org/doctrine/doctrine2) 2.1: [![Build Status](https://secure.travis-ci.org/doctrine/doctrine2.png?branch=2.1.x)](http://travis-ci.org/doctrine/doctrine2) From 2925fea7bd88b935586a0d4b426acb36e8fcc42f Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Thu, 14 Nov 2013 12:36:52 +0100 Subject: [PATCH 12/12] Make tests forward compatible with DBAL 2.5 --- tests/Doctrine/Tests/Mocks/DriverMock.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/Doctrine/Tests/Mocks/DriverMock.php b/tests/Doctrine/Tests/Mocks/DriverMock.php index af9f869ce..cc33c4c34 100644 --- a/tests/Doctrine/Tests/Mocks/DriverMock.php +++ b/tests/Doctrine/Tests/Mocks/DriverMock.php @@ -85,4 +85,9 @@ class DriverMock implements \Doctrine\DBAL\Driver { return; } + + public function convertExceptionCode(\Exception $exception) + { + return 0; + } }