[DDC-3020] simplexml_load_file(): I/O warning: failed to load external in XmlDriver.php Created: 11/Mar/14  Updated: 14/Mar/14  Resolved: 11/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Rubens Matrono Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None
Environment:

PHP 5.5.9-1~dotdeb.1 (cli) (built: Feb 9 2014 21:29:47)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies

Linux 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 GNU/Linux



 Description   

PHP Warning: simplexml_load_file(): I/O warning : failed to load external entity "/path-to/doctrine/entities/mappings/my_entity.dcm.xml" in /path-to/lib/Doctrine/ORM/Mapping/Driver/XmlDriver.php on line 711

PHP bug:
https://bugs.php.net/bug.php?id=62577

Possible solution:
https://github.com/owncloud/core/pull/7498/files



 Comments   
Comment by Marco Pivetta [ 11/Mar/14 ]

You are not supposed to load external entities in mappings.

Also, mappings are not user input, therefore they are not valid XXE/XEE attack vectors.

Comment by Marco Pivetta [ 11/Mar/14 ]

Deployed a docs fix at https://github.com/doctrine/doctrine2/commit/02daf0049adff040259f1fe86c6a0c846a68c3c1

Comment by Rubens Matrono [ 11/Mar/14 ]

this is not a bug in Doctrine, who wants a quickfix can create a custom driver and force import of XXE/XEE before drivers are used:

class MyQuickFixXmlDriver extends \Doctrine\ORM\Mapping\Driver\XmlDriver
{
    /**
     * {@inheritDoc}
     */
    public function loadMetadataForClass($className, ClassMetadata $metadata)
    {
        $loadEntities = libxml_disable_entity_loader(false);
        parent::loadMetadataForClass($className, $metadata);
        libxml_disable_entity_loader($loadEntities);
    }
} 




[DDC-2871] preFlush event called multiple times in event manager. Created: 25/Dec/13  Updated: 02/Jan/14  Resolved: 02/Jan/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Artur Eshenbrener Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates DDC-2692 [GH-794] Multiple invokation of liste... Resolved

 Description   

preFlush event called multiple times inside event manager when flushing more than one entity.



 Comments   
Comment by Benjamin Eberlei [ 25/Dec/13 ]

preFlush is called for every entity, you can retrieve the entity affected by using "getEntity()" on the event arguments. Use "onFlush" to get an evvent that is only called once.

Comment by Artur Eshenbrener [ 25/Dec/13 ]

Benjamin,

1. It is not documented: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/events.html#preflush
2. There is no method "getEntity()" in the event arguments class. https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Event/PreFlushEventArgs.php
3. It is very unexpectable behaviour. Inside event listener (not entity listener) event should called once time per calling "flush()" method of the entity manager.
4. It can be fixed very simple, I will provide you pull-request soon.

Comment by Benjamin Eberlei [ 25/Dec/13 ]

Ok, the problem is as it seems, there is a "preFlush" lifecycle event that is called for every entity, but also a preFlush listener event that isonly called once. I didn't know that there were sementical differences between them. This indeed needs to be fixed.

Comment by Artur Eshenbrener [ 25/Dec/13 ]

Fix provided here: https://github.com/doctrine/doctrine2/pull/887

Comment by Doctrine Bot [ 02/Jan/14 ]

A related Github Pull-Request [GH-887] was closed:
https://github.com/doctrine/doctrine2/pull/887

Comment by Benjamin Eberlei [ 02/Jan/14 ]

see DDC-2692





[DDC-2810] Doctrine\ORM\EntityNotFoundException - Entity was not found. Created: 21/Nov/13  Updated: 13/Dec/13  Resolved: 13/Dec/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Timothy Lorens Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

Linux 2.6.32-358.18.1.el6.x86_64 #1 SMP Fri Aug 2 17:04:38 EDT 2013 x86_64 x86_64 x86_64 GNU/Linux
Server version: Apache/2.2.22 (Unix)
PHP 5.3.3 (cli) (built: Jul 12 2013 04:36:18)



 Description   

Doctrine\ORM\EntityNotFoundException - Entity was not found.

/zf2/framework/Infrastructure/Vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php:177

OneToOne join-side doesn't contain a matching record. One would assume this would just continue with an empty proxy object (full of null properties).

The offending line of code is on line 750 of DOctrine\ORM\BasicEntityPersister.php.

A quick fix/work-around was to replace the return null value with $entity which seems to be the object proxy class.

Change this:
return $entities ? $entities[0] : null;

To This:
return $entities ? $entities[0] : $entity;



 Comments   
Comment by Benjamin Eberlei [ 13/Dec/13 ]

A proxy object is created, when the value on the foreign key is != NULL. If you are having 0 thhere fore example, this problem will happen. We wont fix this however as this can cause serious issues over the project. Your database schema has to conform with Doctrine in this regard, its a requirement.





[DDC-2734] Composer Broken dependency on dev-master Created: 11/Oct/13  Updated: 16/Oct/13  Resolved: 16/Oct/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Nicolas Macherey Assignee: Marco Pivetta
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

Ubuntu 12.04 Php 5.4 composer



 Description   

When runing composer with doctrine/orm on dev-master I got the following error

Your requirements could not be resolved to an installable set of packages.

Problem 1

  • Installation request for doctrine/orm dev-master -> satisfiable by doctrine/orm[dev-master].
  • doctrine/orm dev-master requires doctrine/dbal >=2.5-dev,<2.6-dev -> no matching package found.
    Problem 2
  • doctrine/orm dev-master requires doctrine/dbal >=2.5-dev,<2.6-dev -> no matching package found.
  • symfony/framework-standard-edition 2.3.x-dev requires doctrine/orm dev-master -> satisfiable by doctrine/orm[dev-master].
  • Installation request for symfony/framework-standard-edition 2.3.x-dev -> satisfiable by symfony/framework-standard-edition[2.3.x-dev].

Potential causes:

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.



 Comments   
Comment by Christophe Coevoet [ 11/Oct/13 ]

I suspect you have your minimum stability set to "stable", which means that the dev versions of DBAL and Common cannot be used to fulfill the requirement (while it is exactly what is needed).

you have 3 solutions:

  • change your minimum stability when you are using unstable libraries
  • whitelist the dev version of DBAL and Common in your root composer.json (by adding a requirement with a @dev flag)
  • use stable versions of Doctrine (i.e. 2.4) instead of using the master branch
Comment by Christophe Coevoet [ 11/Oct/13 ]

And as a side note, composer is giving you a link to the explanation about the minimum stability setting in its output

Comment by Nicolas Macherey [ 14/Oct/13 ]

Sure that's true indeed...
Then the problem is more related to Symfony2's doctrine bundles that are incompatible with the 2.5@dev. Even if I set minimum stability to "dev" or if I include the required dependencies manually in the root composer.json.

Thanks

Here is the output I may still forgot something:

Problem 1

  • doctrine/migrations dev-master requires doctrine/dbal >=2.0,<2.5.x-dev -> satisfiable by doctrine/dbal[v2.4.0, 2.0.x-dev, 2.1.5, 2.1.6, 2.1.7, 2.1.x-dev, 2.2.0, 2.2.0-BETA2, 2.2.0-RC1, 2.2.0-RC2, 2.2.0-RC3, 2.2.0-beta1, 2.2.1, 2.2.2, 2.2.x-dev, 2.3.0, 2.3.0-BETA1, 2.3.0-RC1, 2.3.0-RC2, 2.3.0-RC3, 2.3.0-RC4, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.x-dev, 2.4.0-BETA1, 2.4.0-BETA2, 2.4.0-RC1, 2.4.0-RC2, 2.4.x-dev].
  • doctrine/migrations dev-master requires doctrine/dbal >=2.0,<2.5.x-dev -> satisfiable by doctrine/dbal[v2.4.0, 2.0.x-dev, 2.1.5, 2.1.6, 2.1.7, 2.1.x-dev, 2.2.0, 2.2.0-BETA2, 2.2.0-RC1, 2.2.0-RC2, 2.2.0-RC3, 2.2.0-beta1, 2.2.1, 2.2.2, 2.2.x-dev, 2.3.0, 2.3.0-BETA1, 2.3.0-RC1, 2.3.0-RC2, 2.3.0-RC3, 2.3.0-RC4, 2.3.1, 2.3.2, 2.3.3, 2.3.4, 2.3.x-dev, 2.4.0-BETA1, 2.4.0-BETA2, 2.4.0-RC1, 2.4.0-RC2, 2.4.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0-BETA1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0-RC1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0-RC2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0-RC3].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.0-RC4].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.3].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.4].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.3.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.4.0-BETA1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.4.0-BETA2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.4.0-RC1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.4.0-RC2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.4.x-dev].
  • Can only install one of: doctrine/dbal[v2.4.0, 2.5.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, v2.4.0].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.0.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.1.5].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.1.6].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.1.7].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.1.x-dev].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0-BETA2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0-RC1].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0-RC2].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0-RC3].
  • Can only install one of: doctrine/dbal[2.5.x-dev, 2.2.0-beta1].
  • doctrine/orm dev-master requires doctrine/dbal >=2.5-dev,<2.6-dev -> satisfiable by doctrine/dbal[2.5.x-dev].
  • Installation request for doctrine/orm dev-master -> satisfiable by doctrine/orm[dev-master].
  • Installation request for doctrine/migrations dev-master -> satisfiable by doctrine/migrations[dev-master].
Comment by Marco Pivetta [ 16/Oct/13 ]

Dev versions are not supposed to be compatible with packages from the symfony scenario unless they require it. You can alias versions in composer.json to force installation





[DDC-2470] Sql Server error in createQuery using ORDER BY and setMaxResults Created: 24/May/13  Updated: 07/Jun/13  Resolved: 07/Jun/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Blocker
Reporter: Jonnatan Oyarzún Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: dql, sqlserver
Environment:

Windows 7, Apache 2 (xampp 1.8.1), PHP 5.4.7, Symfony 2.2.1


Attachments: PNG File BD.png    

 Description   

Important: This issue only affect to 2.4.* versions

When executing

$query = $em->createQuery('
SELECT m.nombre
     , m.fechainicio
     , m.fechafin 
  FROM Bundle:Medicion m
  JOIN m.estudio e
  JOIN e.cliente c
  JOIN c.usuarios u
 WHERE u.id = :id
 ORDER BY m.fechainicio DESC
')
->setMaxResults(12);

Get the following error:

An exception occurred while executing '
SELECT * 
  FROM (
           SELECT m0_.NOMBRE AS NOMBRE0
                , m0_.FECHAINICIO AS FECHAINICIO1
                , m0_.FECHAFIN AS FECHAFIN2
                , ROW_NUMBER() OVER (ORDER BY FECHAINICIO1 DESC) AS doctrine_rownum 
             FROM MEDICION m0_ WITH (NOLOCK) 
            INNER JOIN ESTUDIO e1_ 
               ON m0_.ESTUDIO_ID = e1_.ID 
            INNER JOIN CLIENTE c2_ 
               ON e1_.CLIENTE_ID = c2_.ID 
            INNER JOIN USUARIO u3_ 
               ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = ?
       ) AS doctrine_tbl 
 WHERE doctrine_rownum BETWEEN 1 AND 12
' with params [2]:
SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]El nombre de columna 'FECHAINICIO1' no es válido.

Attached the BD model

Added extra info!

Engine version: Sql server 2008 R2

When executing this SQL (returned by doctrine error) on Management Studio

SELECT * FROM (SELECT m0_.NOMBRE AS NOMBRE0, m0_.FECHAINICIO AS FECHAINICIO1, m0_.FECHAFIN AS FECHAFIN2, ROW_NUMBER() OVER (ORDER BY FECHAINICIO1 DESC) AS doctrine_rownum FROM MEDICION m0_ WITH (NOLOCK) INNER JOIN ESTUDIO e1_ ON m0_.ESTUDIO_ID = e1_.ID INNER JOIN CLIENTE c2_ ON e1_.CLIENTE_ID = c2_.ID INNER JOIN USUARIO u3_ ON c2_.ID = u3_.CLIENTE_ID WHERE u3_.ID = 12) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 12

Get the following error:

El nombre de columna 'FECHAINICIO1' no es válido. ('FECHAINICIO1' is invalid)

But if change "FECHAINICIO1"

... OVER (ORDER BY FECHAINICIO1 DESC) AS doctrine_rownum FROM...

by this

... OVER (ORDER BY m0_.FECHAINICIO DESC) AS doctrine_rownum FROM...

Don't get error

regards
Jonnatan Oyarzún



 Comments   
Comment by Guilherme Blanco [ 05/Jun/13 ]
  • Which version of SQL Server are you working on?
  • Also, could you please verify 2 queries for us?
    This one should not work:
SELECT m0_.NOMBRE AS NOMBRE0
     , m0_.FECHAINICIO AS FECHAINICIO1
     , m0_.FECHAFIN AS FECHAFIN2 
  FROM MEDICION m0_ 
 ORDER BY FECHAINICIO1 DESC

This one should work:

SELECT m0_.NOMBRE AS NOMBRE0
     , m0_.FECHAINICIO AS FECHAINICIO1
     , m0_.FECHAFIN AS FECHAFIN2 
  FROM MEDICION m0_ 
 ORDER BY m0_.FECHAINICIO DESC

As soon as you get this it may define the approach on how we're gonna fix the issue. =)

Cheers,

Guilherme Blanco

Comment by Jonnatan Oyarzún [ 05/Jun/13 ]

Add extra info

Cheers,

Jonnatan Oyarzún

Comment by Fabio B. Silva [ 05/Jun/13 ]

Hi Jonnatan

There is a possible fix in this branch : DDC-2470,
but i'm not able to test it right now..

Could you please test it in your environment ?

Thanks..

Comment by Jonnatan Oyarzún [ 05/Jun/13 ]

Hi Fabio

Thank you very much for posting this fix.
From your DDC-2470, I downloaded and pasted files in vendor\doctrine\dbal.
Fix is working for me!.

The question is, when this fix could be merged to dbal/master branch?

Cheers,
Jonnatan Oyarzún

Comment by Fabio B. Silva [ 05/Jun/13 ]

Thanks Jonnatan,

I've created a pull request : https://github.com/doctrine/dbal/pull/332

Comment by Fabio B. Silva [ 07/Jun/13 ]

Fixed : https://github.com/doctrine/doctrine2/commit/753d63c2d48facdecba5d84f6ed2450024de2867





[DDC-2229] Undefined method Created: 09/Jan/13  Updated: 22/Apr/13  Resolved: 08/Apr/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Blocker
Reporter: Karma Dordrak (Drak) Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Attachments: Text File SqlWalker.patch     File SqlWalkerTest.php    

 Description   

There is an undefined method called in Doctrine\ORM\Query\SqlWalker

Fatal error: Call to undefined method Doctrine\ORM\Query\AST\PathExpression::isSimpleArithmeticExpression() in vendor\doctrine\orm\lib\Doctrine\ORM\Query\SqlWalker.php on line 2091



 Comments   
Comment by Fabio B. Silva [ 12/Jan/13 ]

Hi Karma

Could you provide the failing DQL ?

Cheers

Comment by Karma Dordrak (Drak) [ 18/Jan/13 ]

It's generating SQL from a Doctrine Collection in a proxy class. Here is a link to the example: https://github.com/zikula/core/pull/674#discussion_r2696186

The SQL being generated is

`SELECT t0.name AS name1, t0.value AS value2, t0.user_id AS user_id3 FROM users_attributes t0 WHERE t0.user_id = ?`

The ? should be the value 2, but for some reason it's not being added. I've checked the files in the stack-trace below and the right values are entering into the process, just the wrong SQL seems to be generated.

Exception Trace
#0 Exception thrown in C:\xampp\htdocs\core13\src\vendor\doctrine\dbal\lib\Doctrine\DBAL\DBALException.php, line 47.
#1 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php(1599): Doctrine\DBAL\Connection->executeQuery('SELECT t0.name ...', Array, Array)
#2 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php(1558): Doctrine\ORM\Persisters\BasicEntityPersister->getOneToManyStatement(Array, Object(Users\Entity\User))
#3 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\UnitOfWork.php(2673): Doctrine\ORM\Persisters\BasicEntityPersister->loadOneToManyCollection(Array, Object(Users\Entity\User), Object(Doctrine\ORM\PersistentCollection))
#4 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\PersistentCollection.php(224): Doctrine\ORM\UnitOfWork->loadCollection(Object(Doctrine\ORM\PersistentCollection))
#5 C:\xampp\htdocs\core13\src\vendor\doctrine\orm\lib\Doctrine\ORM\PersistentCollection.php(576): Doctrine\ORM\PersistentCollection->initialize()
#6 C:\xampp\htdocs\core13\src\lib\util\UserUtil.php(1152): Doctrine\ORM\PersistentCollection->getIterator()
#7 C:\xampp\htdocs\core13\src\lib\util\UserUtil.php(2007): UserUtil::getVars('admin', false, 'uname', false)

Comment by Fabio B. Silva [ 20/Jan/13 ]

Hi Drak,

Could you try to write a failing test case please ?

Cheers

Comment by Alexander [ 10/Feb/13 ]

ping!

Comment by Daniel Huss [ 14/Feb/13 ]

SqlWalker::walkInExpression() does this:

$sql = $this->walkArithmeticExpression($inExpr->expression)

However, $inExpr->expression could be an instance of PathExpression. The grammar allows this case:

InExpression             ::= SingleValuedPathExpression ["NOT"] "IN" "(" (InParameter {"," InParameter}* | Subselect) ")"

PathExpression and ArithmeticExpression both extend Node, but a PathExpression is not an ArithmeticExpression, and therefore it has no method isSimpleArithmeticExpression.

If you still need a failing test case, I'll write one when I get home from work.

Comment by Fabio B. Silva [ 14/Feb/13 ]

Please Daniel Huss, A test case will be very useful..

Comment by Daniel Huss [ 15/Feb/13 ]

failing test case

Comment by Daniel Huss [ 02/Apr/13 ]

Bug still present in release 2.3.3

Is someone taking care of this? It seems easy enough to fix.

Comment by Marco Pivetta [ 02/Apr/13 ]

Daniel Huss you can open a PR with the attached patch + test. Can you do it or should I take care of it?

Comment by Daniel Huss [ 02/Apr/13 ]

Please take care of it for me this time. I'd rather avoid the git setup until I have a significant contribution to make.

Comment by Benjamin Eberlei [ 08/Apr/13 ]

This is invalid, you need to set the path expression differently, this is pseudo code:

new ArtihmeticExpression(new SimpleArithmeticExpression(arithmeticsTerms => new PathExpression)));
Comment by Daniel Huss [ 22/Apr/13 ]

Could this be bug in the DQL grammar, then? If I'm not mistaken, the resolution of an InExpression cannot involve an ArithmeticPrimary non-terminal. I find the correct solution as shown by Benjamin Eberlei to be quite astonishing, since a path expression like "alias.field" is not something I'd associate with the term "arithmetic".





[DDC-2199] Yaml driver does not take into account field @Version attribute Created: 14/Dec/12  Updated: 16/Dec/12  Resolved: 16/Dec/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: Git Master
Fix Version/s: 2.3.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Georgy Galakhov Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: mapping, yaml


 Description   

Even if field has version: true attribute, Yaml driver does not set class metadata isVersioned and versionField properties. As a result optimistic lock cannot be used.



 Comments   
Comment by Benjamin Eberlei [ 16/Dec/12 ]

Fixed





[DDC-2073] PersistentCollection::matching() always returns empty collection, when passed criteria's expression is created using ExpressionBuilder::isNull() Created: 12/Oct/12  Updated: 12/Nov/12  Resolved: 12/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.3
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Pavol Kirschbaum Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

This happens because expression created by ExpressionBuilder::isNull() is wrongly translated to SQL using '=' operator instead of 'IS NULL'.

If the collection is already loaded, result is as expected.



 Comments   
Comment by Matthieu Napoli [ 06/Nov/12 ]

Pull request: https://github.com/doctrine/doctrine2/pull/508





[DDC-1961] BC Break: Explicit parameter type definitions are discarded when using AbstractQuery::setParameter Created: 31/Jul/12  Updated: 31/Jul/12  Resolved: 31/Jul/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.3
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Michael Moravec Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

In 2.2.x it was possible to explicitly specify a type of a parameter in query. In code below, I used a Type::DATE to explicitly say that it should be converted to date type rather than datetime. In 2.3-RC1, it is completely ignored.

// $query instanceof AbstractQuery
$query->setParameter('day', $date, Type::DATE)

Pull request: https://github.com/doctrine/doctrine2/pull/416



 Comments   
Comment by Benjamin Eberlei [ 31/Jul/12 ]

Fixed





[DDC-1871] Create a relation between two Entities in different EntityManager Created: 12/Jun/12  Updated: 16/Jun/12  Resolved: 16/Jun/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Tibec Assignee: Benjamin Eberlei
Resolution: Can't Fix Votes: 0
Labels: None
Environment:

Symfony2 with Doctrine2 using MySQL



 Description   

Hello,

I'm working on a Symfony based CMS for a game server. The game server use two databases (the `auth` database and `characters` database) and i've created a new one for the CMS named `site`.

Currently my News entity must have a relation with the Account entity but the News entity come from the Site EntityManager (who manage the `site` database) and the Account entity come from the Auth EntityManager (who manage the `auth` database).

So, when I prompt the command "php app/console doctrine:schema:update --em="site" --force" I got the error "Class Eluna\MemberBundle\Entity\Account is not a valid entity or mapped super class." But if I join an entity who is in the same EntityManager it work perfectly.

My code :

    /**
     * @var object $author
     *
     * @ORM\ManyToOne(targetEntity="Eluna\MemberBundle\Entity\Account")
     * @ORM\JoinColumn(name="author", referencedColumnName="id")
     */
    private $author;


 Comments   
Comment by Benjamin Eberlei [ 16/Jun/12 ]

Unless the entities are in the same database server (MySQL) but just in different databses you can use the syntax "database.table" in the @Table. Otherwise there is no nice solution, you have to save the foreign key manually in an integer column and maybe use an event listener to fetch a proxy of the related object. But that has to be coded manually.





[DDC-1824] Native Query fail Created: 17/May/12  Updated: 27/May/12  Resolved: 27/May/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.1.6
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Moritz Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

XAMPP on Windows 7
Doctrine in Combination with Symfony



 Description   

I keep getting an error while I'm trying to perfom an native query.
If there is no result then everything is fine and I don't get any errors.

Notice: Undefined index: id in C:\xampp\htdocs\Symfony\vendor\doctrine\lib\Doctrine\ORM\UnitOfWork.php line 1949

 
$sql = "SELECT q.question FROM question q WHERE MATCH (q.question) AGAINST (?)";

$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('WWMGameBundle:Question', 'q');
$rsm->addFieldResult('q', 'question', 'question');

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $request->request->get('q'));

$search = $query->getResult();
 
/**
* WWM\Entity\Question
*
* @ORM\Entity(repositoryClass="WWM\Entity\QuestionsRepository")
* @ORM\Table(name="question")
*/
class Question
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /**
     * @var integer $level
     *
     * @ORM\Column(name="level", type="integer", nullable=false)
     */
    private $level;

    /**
     * @var string $question
     *
     * @ORM\Column(name="question", type="string", length=255, nullable=false)
     */
    private $question;



    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set level
     *
     * @param integer $level
     */
    public function setLevel($level)
    {
        $this->level = $level;
    }

    /**
     * Get level
     *
     * @return integer
     */
    public function getLevel()
    {
        return $this->level;
    }

    /**
     * Set question
     *
     * @param string $question
     */
    public function setQuestion($question)
    {
        $this->question = $question;
    }

    /**
     * Get question
     *
     * @return string
     */
    public function getQuestion()
    {
        return $this->question;
    }
}


 Comments   
Comment by Benjamin Eberlei [ 17/May/12 ]

You have to add the id as field aswell using $rsm->addFieldResult()

Comment by Moritz [ 17/May/12 ]

It doesn't matter if I use the id as well. I keep getting the same error message:

$sql = "SELECT q.question FROM question q WHERE MATCH (q.question) AGAINST (?)";

$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('WWMGameBundle:Question', 'q');
$rsm->addFieldResult('q', 'question', 'question');
$rsm->addFieldResult('q', 'id', 'id');

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $request->request->get('q'));

$search = $query->getResult();
Comment by Moritz [ 20/May/12 ]

It doesn't matter if I use the id as well. I keep getting the same error message.

Comment by Benjamin Eberlei [ 27/May/12 ]

Do you want to fetch the whole Question Entity? Or just the question as string? Since you only do q.question i suppose using a scalar result instead of the entity works.

$sql = "SELECT q.question FROM question q WHERE MATCH (q.question) AGAINST (?)";

$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addScalarResult('question', 'question');

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $request->request->get('q'));

$search = $query->getResult();

However if you want the whole entity, then you have to fetch the ID from sql as well:

$sql = "SELECT q.id, q.question FROM question q WHERE MATCH (q.question) AGAINST (?)";

$rsm = new \Doctrine\ORM\Query\ResultSetMapping;
$rsm->addEntityResult('WWMGameBundle:Question', 'q');
$rsm->addFieldResult('q', 'question', 'question');
$rsm->addFieldResult('q', 'id', 'id');

$em = $this->getDoctrine()->getEntityManager();
$query = $em->createNativeQuery($sql, $rsm);
$query->setParameter(1, $request->request->get('q'));

$search = $query->getResult();
Comment by Moritz [ 27/May/12 ]

Now it works perfectly fine. Thank you





[DDC-1784] Error on generate entities: 'Attribute "allocationSize" of @ORM\SequenceGenerator' Created: 18/Apr/12  Updated: 27/May/12  Resolved: 20/Apr/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.2.2
Fix Version/s: 2.2.3, 2.3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Augusto Ximenes de Souza Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None


 Description   

When I generated my entities on version 2.2.2 through "orm:convert-mapping", the sequence has a value ' allocationSize="1", initialValue="1" ' with quotes.

So I received an error:

Attribute "allocationSize" of @ORM\SequenceGenerator declared on property entities\Test::$id expects a integer, but got string.

To fix, I removed the quotes. is It a bug?

Part of entity generated:

/**

  • @var integer $id
    *
  • @ORM\Column(name="id", type="integer", precision=0, scale=0, nullable=false, unique=false)
  • @ORM\Id
  • @ORM\GeneratedValue(strategy="SEQUENCE")
  • @ORM\SequenceGenerator(sequenceName="test_id_seq", allocationSize="1", initialValue="1") /* SEE QUOTES ON allocationSize="1", initialValue="1" */
    */
    private $id;


 Comments   
Comment by Augusto Ximenes de Souza [ 18/Apr/12 ]

I think the problem is on the line 1037 to 1042 of Class Doctrine \ ORM \ Tools \ EntityGenerator:

if (isset($metadata->sequenceGeneratorDefinition['allocationSize']))

{ $sequenceGenerator[] = 'allocationSize="' . $metadata->sequenceGeneratorDefinition['allocationSize'] . '"'; }

if (isset($metadata->sequenceGeneratorDefinition['initialValue']))

{ $sequenceGenerator[] = 'initialValue="' . $metadata->sequenceGeneratorDefinition['initialValue'] . '"'; }

Replace to:

if (isset($metadata->sequenceGeneratorDefinition['allocationSize']))

{ $sequenceGenerator[] = 'allocationSize=' . $metadata->sequenceGeneratorDefinition['allocationSize']; }

if (isset($metadata->sequenceGeneratorDefinition['initialValue']))

{ $sequenceGenerator[] = 'initialValue=' . $metadata->sequenceGeneratorDefinition['initialValue']; }
Comment by Fabio B. Silva [ 20/Apr/12 ]

Fixed by : https://github.com/doctrine/doctrine2/commit/d5d47222c1dc5ea97ebd8f4c68834fbe4abeb238

Comment by Benjamin Eberlei [ 27/May/12 ]

Merged into 2.2





[DDC-1695] SQLs for PostgreSQL case sensite tables/fields are wrongly generated Created: 09/Mar/12  Updated: 11/Mar/12  Resolved: 11/Mar/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.1.6
Fix Version/s: 2.1.7, 2.2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Ignacio Larranaga Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

PostgreSQL 9.x, Symfony 2


Attachments: Text File doctrine-2.1.6.patch     Text File SqlWalker.patch    

 Description   

The SQLs for case sensitive schemas in postgreSQL are wronly generated.

Example:
Schema:

CREATE TABLE "News" (
  "IdNews" serial NOT NULL,
  "IdUser" bigint NOT NULL,
  "IdLanguage" integer NOT NULL,
  "IdCondition" integer,
  "IdHealthProvider" integer,
  "IdSpeciality" integer,
  "IdMedicineType" integer,
  "IdTreatment" integer,
  "Title" character varying,
  "SmallText" character varying,
  "LongText" character varying,
  "PublishDate" timestamp with time zone,
  "IdxNews" tsvector,
  "Highlight" boolean NOT NULL DEFAULT false,
  "Order" integer NOT NULL DEFAULT 0,
  "Deleted" boolean NOT NULL DEFAULT false,
  "Active" boolean NOT NULL DEFAULT false,
  "UpdateToHighlighted" boolean DEFAULT false,
  CONSTRAINT "News_pkey" PRIMARY KEY ("IdNews" ));

Object (I added quotes trying to generate the SQLs quoted.:

<?php

namespace GlobalTreatments\ApplicationBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Table(name="""News""")
 * @ORM\Entity
 */
class News
{
    /**
     * @var integer $idNews
     *
     * @ORM\Column(name="""IdNews""", type="integer", nullable=false)
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="SEQUENCE")
     * @ORM\SequenceGenerator(sequenceName="""News_IdNews_seq""", allocationSize="1", initialValue="1")
     */
    private $idNews;

    /**
     * @var bigint $iduser
     *
     * @ORM\Column(name="""IdUser""", type="bigint", nullable=false)
     */
    private $idUser;

    /**
     * @var integer $idLanguage
     *
     * @ORM\Column(name="""IdLanguage""", type="integer", nullable=false)
     */
    private $idLanguage;

    /**
     * @var integer $idCondition
     *
     * @ORM\Column(name="""IdCondition""", type="integer", nullable=true)
     */
    private $idCondition;

    /**
     * @var integer $idHealthProvider
     *
     * @ORM\Column(name="""IdHealthProvider""", type="integer", nullable=true)
     */
    private $idHealthProvider;

    /**
     * @var integer $idSpeciality
     *
     * @ORM\Column(name="""IdSpeciality""", type="integer", nullable=true)
     */
    private $idSpeciality;

    /**
     * @var integer $idMedicineType
     *
     * @ORM\Column(name="""IdMedicineType""", type="integer", nullable=true)
     */
    private $idMedicineType;

    /**
     * @var integer $idTreatment
     *
     * @ORM\Column(name="""IdTreatment""", type="integer", nullable=true)
     */
    private $idTreatment;

    /**
     * @var string $title
     *
     * @ORM\Column(name="""Title""", type="string", nullable=true)
     */
    private $title;

    /**
     * @var string $smallText
     *
     * @ORM\Column(name="""SmallText""", type="string", nullable=true)
     */
    private $smallText;

    /**
     * @var string $longText
     *
     * @ORM\Column(name="""LongText""", type="string", nullable=true)
     */
    private $longText;

    /**
     * @var datetimetz $publishDate
     *
     * @ORM\Column(name="""PublishDate""", type="datetimetz", nullable=true)
     */
    private $publishDate;

    /**
     * @var tsvector $idxNews
     *
     * @ORM\Column(name="""IdxNews""", type="tsvector", nullable=true)
     */
    private $idxNews;

    /**
     * @var boolean $highlight
     *
     * @ORM\Column(name="""Highlight""", type="boolean", nullable=false)
     */
    private $highlight;

    /**
     * @var integer $order
     *
     * @ORM\Column(name="""Order""", type="integer", nullable=false)
     */
    private $order;

    /**
     * @var boolean $deleted
     *
     * @ORM\Column(name="""Deleted""", type="boolean", nullable=false)
     */
    private $deleted;

    /**
     * @var boolean $active
     *
     * @ORM\Column(name="""Active""", type="boolean", nullable=false)
     */
    private $active;

    /**
     * @var boolean $updateToHighlighted
     *
     * @ORM\Column(name="""UpdateToHighlighted""", type="boolean", nullable=true)
     */
    private $updateToHighlighted;

    /**
     * @var condition
     *
     * @ORM\ManyToOne(targetEntity="Condition")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdCondition""", referencedColumnName="""IdCondition""")
     * })
     */
    private $condition;

    /**
     * @var healthProvider
     *
     * @ORM\ManyToOne(targetEntity="HealthProvider")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdHealthProvider""", referencedColumnName="""IdHealthProvider""")
     * })
     */
    private $healthProvider;

    /**
     * @var language
     *
     * @ORM\ManyToOne(targetEntity="Language")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdLanguage""", referencedColumnName="""IdLanguage""")
     * })
     */
    private $language;

    /**
     * @var medicineType
     *
     * @ORM\ManyToOne(targetEntity="MedicineType")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdMedicineType""", referencedColumnName="""IdMedicineType""")
     * })
     */
    private $medicineType;

    /**
     * @var speciality
     *
     * @ORM\ManyToOne(targetEntity="Speciality")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdSpeciality""", referencedColumnName="""IdSpeciality""")
     * })
     */
    private $speciality;

    /**
     * @var treatment
     *
     * @ORM\ManyToOne(targetEntity="Treatment")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdTreatment""", referencedColumnName="""IdTreatment""")
     * })
     */
    private $treatment;

    /**
     * @var user
     *
     * @ORM\ManyToOne(targetEntity="User")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="""IdUser""", referencedColumnName="""IdUser""")
     * })
     */
    private $user;

    ....

}

DQL:

'SELECT n.smallText, n.publishDate ' .
'FROM News n ' .
	'INNER JOIN n.language la ' .
'WHERE la.languageCode = :languageCode ' .
'ORDER BY n.publishDate DESC'

Generated SQL:

SELECT "0_."SmallText" AS "SmallText"0, "0_."PublishDate" AS "PublishDate"1 FROM "News" "0_ INNER JOIN "Language" "1_ ON "0_."IdLanguage" = "1_."IdLanguage" WHERE "1_."LanguageCode" = ? ORDER BY "0_."PublishDate" DESC LIMIT 6

Notice there are unmattched " in the SQL.



 Comments   
Comment by Ignacio Larranaga [ 09/Mar/12 ]

If there is another approach to specify the table/column names are case sensitive in PGSQL please let me know.

Comment by Ignacio Larranaga [ 09/Mar/12 ]

Just to comment. I also tried the normal quoting.

Example: @ORM\Column(name="`IdNews`", type="integer", nullable=false)

And does not work too because of the same reason.

Comment by Ignacio Larranaga [ 09/Mar/12 ]

Hi, I generate this patch and seems to be working for me (at least what I'm testing right now).

I used ´ to quote tables and single attributes (not relationships) and the SQLs are correctly generated.

Comment by Ignacio Larranaga [ 09/Mar/12 ]

Adding a new patch for another files I need to change.

Comment by Benjamin Eberlei [ 11/Mar/12 ]

Formatted code

Comment by Benjamin Eberlei [ 11/Mar/12 ]

Fixed and merged into 2.1.x and 2.2 branches





[DDC-1668] bug with reading cached annotations in Annotation driver Created: 28/Feb/12  Updated: 03/Mar/12  Resolved: 03/Mar/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.2
Fix Version/s: 2.2.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: victor Velkov Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

I had a problem with Class Table Inheritance on first call of a child entity it was working but if call another child in another instance it was not joining with the parent class. After some debugging i found the problem it was not detecting the annotation that is a parent entity to be joined in Doctrine\ORM\Mapping\Driver\AnnotationDriver when the function on line 479 isTransient($className) is called. So after more debugging i found the problem it is in

is_int(key($classAnnotations))

Looks like that after it is cached in and then the cache is read when it returns the array of annotations for the entity class the keys are returned as strings not as integer and if the key is '0' the the value that is_int returns is NULL so the check

 if ($classAnnotations && is_int(key($classAnnotations))) 

fails and it does not foreach the the array of annotations.
Also i found that you are making that check in a couple of places so I maid a quick fix for my self in the Doctrine\Common\Annotations\CachedReader which is if annotations are found that are cached before returning them i call array_values

// Attempt to grab data from cache
        if (($data = $this->cache->fetch($cacheKey)) !== false) {
            if (!$this->debug || $this->isCacheFresh($cacheKey, $class)) {
                return array_values($data);
            }
        }

I am using APC cache.



 Comments   
Comment by Benjamin Eberlei [ 03/Mar/12 ]

Fixed





[DDC-1620] Partial merge of PR261 Created: 25/Jan/12  Updated: 25/Jan/12  Resolved: 25/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.2-BETA1, 2.2-BETA2, 2.2.0-RC1
Fix Version/s: 2.1.6, 2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Miha Vrhovnik Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The PR261 [1] has two commits, but only one (the first one) was merged to 2.1 and 2.2

[1] - https://github.com/doctrine/doctrine2/pull/261



 Comments   
Comment by Benjamin Eberlei [ 25/Jan/12 ]

fixed

Comment by Miha Vrhovnik [ 25/Jan/12 ]

Hm github is still saying that this is not in 2.2 branch....

Comment by Benjamin Eberlei [ 25/Jan/12 ]

Cherrypick

Comment by Benjamin Eberlei [ 25/Jan/12 ]

ah no, now its up. thanks





[DDC-1607] Entity with eager loaded association is not found when association is null Created: 17/Jan/12  Updated: 21/Jan/12  Resolved: 21/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2-BETA2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Marcel Koonstra Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Attachments: File DDC1607Test.php    

 Description   

Two entities: A and B

A:
id PRIMARY
b NULLABLE

B:
id PRIMARY

Situation: A.b is null and set to eager loading (with fetch="EAGER"), find(id) is called for object A

Actual Behaviour: The record from A is not found (probably due to an INNER JOIN being used).

Expected behaviour: Entity A is loaded with b set to null (like during lazy loading).



 Comments   
Comment by Guilherme Blanco [ 18/Jan/12 ]

Increasing priority

Comment by Guilherme Blanco [ 18/Jan/12 ]

It seems to be associated with this commit:

https://github.com/doctrine/doctrine2/commit/68663fac4b5619643b8a140d6bbe7031e4fa2ad5#comments

Comment by Guilherme Blanco [ 18/Jan/12 ]

Since it's a crash between versions, I'm increasing priority and also marking as regression.

Comment by Benjamin Eberlei [ 18/Jan/12 ]

A blocker indeed, reschedulding RC1 release until this is fixed.

Comment by Benjamin Eberlei [ 18/Jan/12 ]

Can you show us the mappings, specifically how you map A#b? Are you setting nullable=false on the join columns?

You problem could be related to:

https://github.com/doctrine/doctrine2/pull/180
https://github.com/doctrine/doctrine2/pull/182/files

Comment by Guilherme Blanco [ 19/Jan/12 ]

Hi,

I was unable to reproduce your issue with the comments you made so far.
Are you able to modify the attached test file into a failure state that represents your problem?

It may be easier for us to track down your problem after that.

Comment by Marcel Koonstra [ 19/Jan/12 ]

Trying the test case on master, but can't seem to be able to reproduce the bug (same goes for the actual problem case)

Maybe some code has changed allready? I will investigate further if I can reproduce the bug in master.

Comment by Benjamin Eberlei [ 21/Jan/12 ]

Closing as invalid, please reopen if you can reproduce, but it seems this is fixed.





[DDC-1587] Foreign key as Primary does not work as intended Created: 08/Jan/12  Updated: 17/Jan/12  Resolved: 17/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Presteus Assignee: Guilherme Blanco
Resolution: Invalid Votes: 0
Labels: None

Attachments: File AgentDdc1587.php     File IdentifierDdc1587.php    

 Description   

Hi,

In first time, sorry for my bad english.

The feature Foreign key as Primary does not work as intended.

The CLI tool report an error on validating mapping:
The referenced column name 'pk_agent' does not have a corresponding field with this column name on the class 'BddP\Model\Entity\Sd\Contact'.

If I run the application, many features works: querying, entity population.
But for persist a new Agent without associated entities for OneToOne; the ORM report :
PDOException: SQLSTATE[23502]: Not null violation on "pk" column

And If I comment all OneToOne, the persist work.

Thank you in advance for your response.

Agent.php
/**
 * @Entity(repositoryClass="BddP\Model\Entity\Repository\Sd\Agent")
 * @Table(name="agent")
 */
class Agent extends AEntity
{
    /**
     * Agent ID
     * @var int
     *
     * @Id
     * @GeneratedValue
     * @Column(name="pk", type="integer", nullable=false)
     */
    private $pk;
    /**
     * @var BddP\Model\Entity\Sd\Contact
     *
     * @OneToOne(targetEntity="BddP\Model\Entity\Sd\Contact", cascade={"remove,merge,detach"}, mappedBy="agent")
     * @JoinColumn(name="pk", referencedColumnName="pk_agent")
     */
    private $contact;

    [...]

}

Contact.php
/**
 * @Table(name="contact")
 */
class Contact extends AEntity
{
    /**
     * The agent
     * @var BddP\Model\Entity\Sd\Agent
     *
     * @Id
     * @OneToOne(targetEntity="BddP\Model\Entity\Sd\Agent", inversedBy="contact")
     * @JoinColumn(name="pk_agent", referencedColumnName="pk")
     */
    private $agent;

    [...]

}



 Comments   
Comment by Presteus [ 08/Jan/12 ]

In addition,
1. The generated SQL from CLI tool is correct.
2. I think the problem is located when the associated entity request the Primary Key.

Comment by Presteus [ 08/Jan/12 ]

After some dumping. I found a strange state :

BasicEntityPersister : $this->_getInsertSQL() returns
INSERT INTO agent (pk, name, firstname, birthday, email, address, city, postcode, phone, mobile) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)

And the PK parameter in $insertData has null value

array
  'agent' => 
    array
      'pk' => null
      'name' => string 'XXX' (length=7)
      'firstname' => string 'YYY' (length=8)
      'birthday' => 
        object(DateTime)[283]
          public 'date' => string '1970-01-01 00:00:00' (length=19)
          public 'timezone_type' => int 3
          public 'timezone' => string 'Europe/Paris' (length=12)
      'email' => string 'email@domain.tdl' (length=16)
      'address' => null
      'city' => null
      'postcode' => null
      'phone' => null
      'mobile' => null

But the variable $idGen constains the right value...

object(Doctrine\ORM\Id\SequenceGenerator)[335]
  private '_allocationSize' => int 1
  private '_sequenceName' => string 'agent_pk_seq' (length=12)
  private '_nextValue' => int 451
  private '_maxValue' => int 451

What have I misunderstood?

Comment by Presteus [ 08/Jan/12 ]

After some test, other entity do not reproduce this error.

So the only one reason for this bug: The mapping is incorrect.

And I find... This annotation @JoinColumn(name="pk_agent", referencedColumnName="pk") add a foreign key on agent primary key.

But in the documentation the default value are `id` for PK and `table_id`for FK.

Then my question is still open: What have I misunderstood?

Comment by Guilherme Blanco [ 13/Jan/12 ]

Hi,

Can you please try to wrap your issue into a test case?
I could not reproduce here.

Regards,

Comment by Benjamin Eberlei [ 15/Jan/12 ]

First, schema validator had a bug that reported this errors in mapping although it was correct.

Second, I think your mapping is wrong. In this case you cannot have a bidirectional OneToOne.

Comment by Presteus [ 15/Jan/12 ]

Thanks for our response and your time, especially Guilherme for my no response.

I'm right with you Benjamin, it is my responsability to determinate wich field do not need to create a FK...

This is the point of my misunderstood.

Comment by Presteus [ 16/Jan/12 ]

Hi,

I reopen this issue because the problem still alive, not totally the same but it's a side effect due to the removal of the @JoinColumn.

Without the annotation my Agent do not retrieve the Identifier if and only if the Identifier have all fields with null value (except PK of course).
With the annotation my Agent retrieve the Identifier but the valide-schema returns:

[Mapping]  FAIL - The entity-class 'Entity\Agent' mapping is invalid:
* The referenced column name 'pk_agent' does not have a corresponding field with this column name on the class 'Entity\Identifier'.

And the dump for schema-tool returns

ALTER TABLE agent ADD CONSTRAINT FK_268B9C9DB486D3D9 FOREIGN KEY (pk) REFERENCES identifier(pk_agent) NOT DEFERRABLE INITIALLY IMMEDIATE;

For the moment, I do not trace inside the core of framework but i think the problem turn around the @JoinColum and custom name for primary key.

If i do not use the join colum, how the framework retrieve pk name ?
But if I provide the join column, Doctrine create a FK (without considering mapping error).

Comment by Presteus [ 16/Jan/12 ]

Basic Agent and Identifier entities.

Comment by Guilherme Blanco [ 17/Jan/12 ]

Hi,

I added coverage for your issue in master.
It seems the issue have been addressed already. Are you able to upgrade?

Commit reference: https://github.com/doctrine/doctrine2/commit/0f070448367f90dffb81225c680ef9b3490a3f0a

@beberlei He's still able to make a bidirectional association, there's not restriction for that code-wise.

Closing the issue as invalid, since recent versions have already addressed the issue.





[DDC-1509] Issue when merging entity with several associations to inherited classes Created: 23/Nov/11  Updated: 15/Dec/11  Resolved: 23/Nov/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.3, Git Master
Fix Version/s: 2.1.4
Security Level: All

Type: Bug Priority: Blocker
Reporter: Aigars Gedroics Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: File DDC1509Test.php    

 Description   

When merging entity with several associations to inherited classes update data gathering is broken after first inheritance processing because $entity variable is overwritten with another object.

The problem is in the line

https://github.com/doctrine/doctrine2/commit/08716d9f72996bab8c71a8cc8bda72d3925e8fb1#commitcomment-741698

Test case will be attached shortly,



 Comments   
Comment by Benjamin Eberlei [ 23/Nov/11 ]

Raised to blocker.

I will fix that tonight and release a new ORM 2.1.* branch.

Comment by Benjamin Eberlei [ 23/Nov/11 ]

Fixed

Comment by Wandrille M [ 15/Dec/11 ]

Hey I have something similar with one-to-one, can you tell me which git commit this relates to so I can investigate?

And i think it worked fine on 2.1.3 and not anymore

Comment by Aigars Gedroics [ 15/Dec/11 ]

It's https://github.com/doctrine/doctrine2/commit/80fae20f749f8db95156e333c430780a0717002f I guess.





[DDC-1492] Fatall error: Cannot use object as array in ORM\Internal\Hydration\ObjectHydrator.php on line 314 Created: 13/Nov/11  Updated: 15/Nov/11  Resolved: 15/Nov/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.1.1
Fix Version/s: 2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Konstantin Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None
Environment:

Symfony2, Doctrine 2.1.1 (also bug present on 2.1.3-dev - latest revison of 2.1.x branch)



 Description   

My entities

event
eveht.event_area_id=event_area.id (1:1)
event_area.event_id=event.id (1:1)
event_area.area.id=area.id (one area has many event_area's)
area.parent_id=area_id (hierarchial)
event.author_id=user.id (one user has many events)

area - STI: District/City/Region/Country/etc.

SELECT
	r, ra, a, ap, au, DATE(r.eventTime) AS event_date
FROM OloloEventsBundle:Event r
	LEFT JOIN r.eventArea ra
		LEFT JOIN ra.area a
			LEFT JOIN a.parent ap
	INNER JOIN r.author au WHERE r.eventTime <= :r_eventtime AND ra.area IN(:ra_area)
GROUP BY r
ORDER BY event_date DESC

This DQL caused an error "Cannot use object of type District as array in ORM\Internal\Hydration\ObjectHydrator.php on line 314". When I'm removing `ap` friom fetching - it works. Mapping are correct - there are many other places where it works correctly.



 Comments   
Comment by Benjamin Eberlei [ 13/Nov/11 ]

On 2.1.1 line 314 is a "}". Can you restate the line and add a stack trace if possible (xdebug or phpunit can help there).

Comment by Konstantin [ 13/Nov/11 ]

Sorry, line was changed cause I've updated to 2.1.3-dev.

( ! ) Fatal error: Cannot use object of type Ololo\Bundle\TerritorialBundle\Entity\District as array in Z:\home\dev\Ololo\code\vendors\Doctrine\Orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 308
Call Stack
#	Time	Memory	Function	Location
1	0.0006	333520	{main}( )	..\index_dev.php:0
2	0.0254	1435584	Symfony\Component\HttpKernel\Kernel->handle( )	..\index_dev.php:20
3	0.2454	3634168	Symfony\Bundle\FrameworkBundle\HttpKernel->handle( )	..\Kernel.php:171
4	0.2454	3634576	Symfony\Component\HttpKernel\HttpKernel->handle( )	..\HttpKernel.php:44
5	0.2454	3634576	Symfony\Component\HttpKernel\HttpKernel->handleRaw( )	..\HttpKernel.php:71
6	0.3589	5534264	call_user_func_array ( )	..\HttpKernel.php:117
7	0.3590	5534448	Ololo\Bundle\DistrictsBundle\Controller\DistrictController->EventsPastAction( )	..\HttpKernel.php:0
8	1.1606	13782464	Ololo\Bundle\EventsBundle\Entity\EventRepository->getPastEventsByAreasIds( )	..\DistrictController.php:145
9	1.1607	13783520	Ololo\Bundle\EventsBundle\Entity\EventRepository->getEventsSliceBySpecification( )	..\EventRepository.php:385
10	1.2010	14224216	Doctrine\ORM\AbstractQuery->getResult( )	..\EventRepository.php:477
11	1.2010	14224368	Doctrine\ORM\AbstractQuery->execute( )	..\AbstractQuery.php:392
12	3.3409	14781264	Doctrine\ORM\Internal\Hydration\AbstractHydrator->hydrateAll( )	..\AbstractQuery.php:594
13	3.3412	14785824	Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateAll( )	..\AbstractHydrator.php:99
14	3.3413	14798576	Doctrine\ORM\Internal\Hydration\ObjectHydrator->_hydrateRow( )	..\ObjectHydrator.php:140
                    $parentObject = $this->_resultPointers[$parentAlias][key($first)]; // trouble here, $this->_resultPointers[$parentAlias] is object of District
Comment by Guilherme Blanco [ 14/Nov/11 ]

Hi.

If you change this line:

$parentObject = $this->_resultPointers[$parentAlias][key($first)];

To this:

$parentObject = $first[key($first)];

Does it work for you?

Comment by Konstantin [ 14/Nov/11 ]

yes, with this line of code this query works.

Comment by Guilherme Blanco [ 15/Nov/11 ]

https://github.com/doctrine/doctrine2/commit/77e076f1fdbe24fdb2f5a1fb1842c0b9cb7d95a4

This issue was fixed in master.
I requested Benjamin to merge this with 2.1 branch.

Thanks





[DDC-1453] YamlDriver calls Yaml::parse(), but only Yaml::load() exists Created: 25/Oct/11  Updated: 25/Oct/11  Resolved: 25/Oct/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Karsten Dambekalns Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

As the subject says, this cannot work. Reported to me through http://forge.typo3.org/issues/31212. Looking at https://github.com/fabpot/yaml/blame/master/lib/sfYaml.php it even seems there never was a parse() method.



 Comments   
Comment by Benjamin Eberlei [ 25/Oct/11 ]

You are using the oldest possible version of YAML component, please use the right one: https://github.com/symfony/yaml

Comment by Karsten Dambekalns [ 25/Oct/11 ]

Heh, why on earth is the one we use then showing a last update in June 2011? I think all this forking on github is confusing... :/

Anyway, thanks for the pointer!

PS: source of the confusion is http://components.symfony-project.org/yaml/installation, which points to https://github.com/fabpot/yaml





[DDC-1410] leftJoin with condition WITH & Object Hydratation problem. Created: 10/Oct/11  Updated: 07/Jun/12  Resolved: 28/Oct/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: Git Master
Fix Version/s: 2.1.3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Thomas Tourlourat - Armetiz Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 2
Labels: None
Environment:

Debian 5 dotdeb
PHP 5.3
MySQL 5.0
Apache 2.2


Attachments: Text File ObjectHydrator_DDC-1410_v1.patch    

 Description   

Here an example of a simple QueryBuilder :

$queryBuilder = $entityManager->createQueryBuilder();
$queryBuilder->select ( "player, options" );
$queryBuilder->from ( "Player_Model_Entity_Player", "player");
$queryBuilder->where ("player.idPlayer = 12");
$queryBuilder->leftJoin ("player.options", "options", "WITH", "options.enabled = :enabled");
$queryBuilder->setParameter ("enabled", 1);

OptionA & OptionB & OptionC three entities.
User case :

  • OptionA.enabled = 1 & OptionB.enabled = 1 & OptionC.enabled = 1 : OK - All options are return.
  • OptionA.enabled = 1 & OptionB.enabled = 0 & OptionC.enabled = 0 : OK - only optionA is return.
  • OptionA.enabled = 1 & OptionB.enabled = 0 & OptionC.enabled = 1 : OK - only optionA & optionC is return.
  • OptionA.enabled = 0 & OptionB.enabled = 1 & OptionC.enabled = 1 : KO - no option return.
  • OptionA.enabled = 0 & OptionB.enabled = 0 & OptionC.enabled = 0 : OK - no option return.

I have test on OneToMany configuration and I have not problem. The problem only appear with ManyToMany relationships.

The problem seems to be on hydratation. The data return on SQL command seems to be correct.



 Comments   
Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ]

I have made some other search about it.

On the queryBuilder described above, I was using getSingleResult / getResult.
When I'm using getScalarResult I can see data of every options.

Here the scalar result :

array(3) {
  [0]=>
  array(21) {
    ["player_id"]=>
    int(2)
    ["options_id"]=>
    NULL
    ["options_enabled"]=>
    NULL
  }
  [1]=>
  array(21) {
    ["player_id"]=>
    int(2)
    ["options_id"]=>
    int(2)
    ["options_enabled"]=>
    bool(true)
  }
  [2]=>
  array(21) {
    ["player_id"]=>
    int(2)
    ["options_id"]=>
    int(4)
    ["options_enabled"]=>
    bool(true)
  }
}

Do you have any clue ?

Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ]

I think I have find the problem.

See patch.
I have test the modification, it seem to be okay.

In the 2.1.2 version, If the first related object wasn't a "nonemptyComponents", the ObjectHydrator initialized the collection by a specific way.

Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ]

It's a patch for Doctrine/ORM/Internal/Hydration/ObjectHydrator.php version 2.1.2.

Comment by Thomas Tourlourat - Armetiz [ 20/Oct/11 ]

I have add a correction on Github : https://github.com/armetiz/doctrine2/commit/42d507632fd27a23220c38bb867b611c3caaab8e

Comment by Benjamin Eberlei [ 25/Oct/11 ]

Thanks for digging into that, I will evaluate this issue

Comment by Thomas Tourlourat - Armetiz [ 25/Oct/11 ]

No problem, It was blocking for me.
But I don't understand why this bug doesn't appear to other users. Because of that, I'm wondering if it's a real bug or a miss configuration on my app.

To be sure, the best will be to create a new test, but I'm not really familiar to create ORM test case..

Thomas.

Comment by Benjamin Eberlei [ 25/Oct/11 ]

can you post your mappings?

Comment by Thomas Tourlourat - Armetiz [ 26/Oct/11 ]

PlayerEntity :

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
                    http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
	<entity name="PlayerEntity">
		<many-to-many field="options" target-entity="OptionEntity" mapped-by="players" />
	</entity>
</doctrine-mapping>
{/code}

<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd" >
<entity name="OptionEntity" table="options">
<many-to-many field="players" target-entity="PlayerEntity" inversed-by="options">
<cascade>
<cascade-merge />
</cascade>
<join-table name="compo_option_player" />
</many-to-many>
</entity>
</doctrine-mapping>

{/code}

I have post all the mapping, but it's Doctrine compliant.
PlayerEntity extends PlayerBaseEntity, and Option is a standalone Entity.
All define an auto generated identifier.
The join table is correctly configured.

Do you need this mapping to create tests ?
To sum-up, this is a simply ManyToMany relation between an inheritance Entity & a simple Entity.

Do you need any else ?

Thomas.

Comment by Benjamin Eberlei [ 28/Oct/11 ]

Fixed.

Comment by Benjamin Eberlei [ 08/Nov/11 ]

This issue is referenced in Github Pull-Request GH-161
https://github.com/doctrine/doctrine2/pull/161

Comment by Benjamin Eberlei [ 07/Jun/12 ]

A related Github Pull-Request [GH-161] was opened
https://github.com/doctrine/dbal/pull/161

Comment by Benjamin Eberlei [ 07/Jun/12 ]

A related Github Pull-Request [GH-161] was closed
https://github.com/doctrine/dbal/pull/161





[DDC-1360] Reserved words escaping fails when using multiple reserved words Created: 03/Sep/11  Updated: 03/Jan/12  Resolved: 31/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.1
Fix Version/s: 2.2-BETA2, 2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Elnur Abdurrakhimov Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux, PostgreSQL



 Description   

Everything works fine when I use the @Table annotation like this: @Table(name="`user`"). But when the user table is in the user schema and I try to use the annotion in this way: @Table(name="`user`.`user`") — everything falls apart.

A quick look into the code showed that it checks if the table name starts with `, and if it does, it sets the quoted parameter to true and removes the ` characters on the both sides. So, if I quote the both words like @Table(name="`user`.`user`"), the table name becomes "user`.`user" and it, of course, fails. If I quote it just like @Table(name="`user.user`"), the table name becomes "user.user", which fails too.

If Doctrine allows to escape the reserved words, it should take into account this kind of usage as well.



 Comments   
Comment by Guilherme Blanco [ 05/Sep/11 ]

By now, it's currently impossible to do cross database joins in an easy way.
We have planned it through the schema support in @Table.

I'll be working on this support for 2.2, but until there, my only recommendation is to not use a keyword as a table name.

Cheers,

Comment by Elnur Abdurrakhimov [ 05/Sep/11 ]

It's not cross database; it's just schema.table in PostgreSQL. It works when not using reserved words, but fails with them.

Comment by Benjamin Eberlei [ 28/Oct/11 ]

How much of this ticket does your commit from some weeks ago cover guilherme?

Comment by Benjamin Eberlei [ 16/Nov/11 ]

Fixed for 2.2

Comment by Elnur Abdurrakhimov [ 21/Dec/11 ]

It still doesn't work. Tried on master.

Comment by Benjamin Eberlei [ 21/Dec/11 ]

what kind of error do you get?

Comment by Benjamin Eberlei [ 28/Dec/11 ]

could reproduce the problem with table names and sequence names.

Comment by Benjamin Eberlei [ 28/Dec/11 ]

Fixed.

Comment by Elnur Abdurrakhimov [ 29/Dec/11 ]

I've just got fresh clones of doctrine-doctrine2, doctrine-dbal and doctrine-common — all on their master branches.

My entity has this annotation:

@ORM\Table(name="`user`.`user`")

I'm getting the following exception:

SQLSTATE[42P01]: Undefined table: 7 ERROR: relation "user.user" 
does not exist LINE 1: ... is_private9,
u0_.created_at AS created_at10 FROM "user.user... 

So, it's translating `user`.`user` to "user.user", while it should be "user"."user".

Comment by Elnur Abdurrakhimov [ 29/Dec/11 ]

What changed is that earlier `user`.`user` was translated to "user`.`user", while now it's translated to "user.user", but should be to "user"."user".

I saw the commit related to this ticket (https://github.com/doctrine/doctrine2/commit/959a68694e5827a74ad5b8c8216996ffff6196ba) and I want to note that I'm getting this error not when creating a table, but when querying it. I don't use Doctrine for creating tables anyway — I do it via plain SQL.

Comment by Benjamin Eberlei [ 31/Dec/11 ]

I keep trying until i fixed this, now with a commit into DBAL: https://github.com/doctrine/dbal/commit/4cb8a99b65fb08e01fbc02cf9c0e07255e3f8463

Will be included in Beta 2

Comment by Elnur Abdurrakhimov [ 31/Dec/11 ]

Now `user`.user, `user`.`user` and `user.user` get escaped properly, ending up as "user"."user". Interestingly enough, even only the beginning tick like in `user.user ends up as "user"."user".

user.`user`, though, results in user.`user` — that is, nothing gets escaped. I don't think this is a big deal, because if I can escape both schema and table name parts, then I won't run into problems. I'm pointing this out in case it was intended to affect the escaping too.

Good job, thanks.





[DDC-1341] MultiTableUpdateExecutor does not bind parameters properly Created: 21/Aug/11  Updated: 28/Aug/11  Resolved: 28/Aug/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.1.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Pavel Kučera Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None


 Description   

Hi, I found really annoing bug in multi table update executor, it doesn't bind parameters properly. I have following structure of entities (afaik not really important, bug should appear with any class inheritance structure)

/**
* @entity
* @inheritanceType("JOINED")
* @discriminatorColumn(name="type", type="string")
* @discriminatorMap({"NodeEntity", forum = "ForumEntity"})
*/
class NodeEntity
{
  // ... some params
}

/**
* @entity
*/
class ForumEntity
{
/**
* @manyToOne(targetEntity="Author")
*/
private $lastPostAuthor;


/**
* @column(type="datetime")
*/
private $tLastPost;
// ... some params
}

And I'm trying to run following query

$qb = $this->entityManager->createQueryBuilder()
			->update('ForumEntity', 'f')
			->set('f.nPosts', 'f.nPosts + 1')
			->set('f.tLastPost', ':tLastPost')->setParameter('tLastPost', $post->getTCreation()) // $post->getTCreation() returns an instance of DateTime
			->set('f.lastPostAuthor', ':author')->setParameter('author', $post->getAuthor()) // $post->getAuthor() returns an instance of AuthorEntity

			->where('f.lft <= :left')->setParameter('left', $forum->getLft())
			->andWhere('f.rgt >= :right')->setParameter('right', $forum->getRgt())
			->andWhere('f.root = :root')->setParameter('root', $forum->getRoot());

		$qb->getQuery()->execute();

Which fails with "recoverable error", because Doctrine tries to convert value of parameter 'right' to datetime. I have learned why it does so, it is because of line 157 in already mentioned MultiTableUpdateExecutor - while parameters for the insert query are sliced of parameters from update clause, their types are not. And that is a bit problematic.

But that is not the only problem, if you look at line 161, the update query receives parameters as they were binded to QueryBuilder, so when I bind there an object, the update query receives the object instead of his identificator. That leads to error like "object ... could not be converted to string". And also, the update query does not receive any information about type of parameters, but I'm not sure if that is also a bug.

I'm not a native english speaker so if I explain things chaotically, just say so please, I'll try better .



 Comments   
Comment by Benjamin Eberlei [ 28/Aug/11 ]

Assigned to Guilherme

Comment by Guilherme Blanco [ 28/Aug/11 ]

Fixed since this commit: https://github.com/doctrine/doctrine2/commit/e7f471ef3e1ffa5e180623115a45f423572549e4

Comment by Benjamin Eberlei [ 28/Aug/11 ]

Merged into 2.1.x





[DDC-1302] orphan-removal does not work in XML Created: 29/Jul/11  Updated: 31/Jul/11  Resolved: 31/Jul/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.1
Fix Version/s: 2.0.7, 2.1.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The check for $oneToManyElement->

{'orphan-removal'}

returns false, the right check would be $oneToManyElement['orphan-removal']



 Comments   
Comment by Benjamin Eberlei [ 31/Jul/11 ]

Fixed and merged into 2.0.x and 2.1.x branches.





[DDC-1251] EntityGenerator uses non-existing constant T_AMPERSAND Created: 05/Jul/11  Updated: 09/Jul/11  Resolved: 09/Jul/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.1
Fix Version/s: 2.0.7, 2.1.1, 2.2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Jordi Boggiano Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Irrelevant



 Description   

As per http://www.php.net/manual/en/tokens.php - the T_AMPERSAND token does not exist. I'm not sure what was the intent, but the entity generator fails on the following code:

            $elems = array_map(function($el) {
                return $el;
            }, $elems);

Due to the way notices are handled in Symfony, this basically stops the execution of the generator entirely. Not so great.

  [ErrorException]                                                                                            
  Notice: Use of undefined constant T_AMPERSAND - assumed 'T_AMPERSAND' in ./vendor/doctrine/lib/Doctrine/ORM/Tools/EntityGenerator.php line 454

Commenting out the offending line makes it work fine though, so I think it's just choking while expecting a function that takes args by reference or something.



 Comments   
Comment by Benjamin Eberlei [ 09/Jul/11 ]

Fixed





[DDC-1231] In ObjectHydrator->_getEntity(...) looking for the discriminator should be in uppercase Created: 27/Jun/11  Updated: 28/Jun/11  Resolved: 28/Jun/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1
Fix Version/s: 2.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Alexandre Mathieu Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

On line 204:
$discrColumn = $this->_rsm->metaMappings[$this->_rsm->discriminatorColumns[$dqlAlias]];

$this->_rsm->discriminatorColumns[$dqlAlias] is in lowercase, whereas $this->_rsm->metaMappings[$this->_rsm->discriminatorColumns[$dqlAlias]] is in uppercase.

$discrColumn cannot be assigned.

A simple fix could be:
$discrColumn = $this->_rsm->metaMappings[strtoupper($this->_rsm->discriminatorColumns[$dqlAlias])];



 Comments   
Comment by Benjamin Eberlei [ 27/Jun/11 ]

What version of the code are you using? I fixed this problem yesterday on git master.

Comment by Alexandre Mathieu [ 27/Jun/11 ]

2.1.0RC1 downloaded this morning from the website.

Comment by Benjamin Eberlei [ 27/Jun/11 ]

ah yes, please update to Git Master then or wait for the RC2 release happening this week.

Comment by Benjamin Eberlei [ 28/Jun/11 ]

This was fixed on master





[DDC-1186] Proxy Objects are incompatible with Serialization Created: 01/Jun/11  Updated: 01/Jun/11  Resolved: 01/Jun/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Johannes Schmitt Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

Lazy-loading users is impossible atm if you want to serialize them at some point, and they are using private member variables.

My suggestion is to check whether the proxied class implements the Serializable interface, and in these cases instead of implementing a __sleep method, a serialize/unserialize method should be implemented instead.

Something like:

public function serialize()

{ return serialize(array($this->__isInitialized__, parent::serialize())); }

public function unserialize($str)

{ list($this->__initialized__, $parentStr) = unserialize($str); parent::unserialize($parentStr); }

At the moment, this makes Doctrine Proxy objects incompatible with the Symfony Security component, and if possible it should be fixed for the 2.1 release. If you need help on this, let me know.



 Comments   
Comment by Johannes Schmitt [ 01/Jun/11 ]

Closing this, not sure what I was debugging there, the problem is a Symfony one





[DDC-1176] Error on proxy loading with foreign Key Created: 27/May/11  Updated: 11/Jun/11  Resolved: 11/Jun/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1
Fix Version/s: 2.1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Jonathan Clus Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Doctrine 2.1Beta



 Description   

Look at this thread:http://groups.google.com/group/doctrine-user/browse_thread/thread/2a03a6aea43428d6

This entity class configuration:

class IndividualsStatus
{
    /**
     * @var Individuals
     *
     * @Id
     * @ManyToOne(targetEntity="Individuals", inversedBy="diagnosers", cascade={"persist","refresh","remove"})
     * @JoinColumns({
     *   @JoinColumn(name="individuals_id", referencedColumnName="id")
     * })
     */
    private $individuals;

    /**
     * @var Diagnosers
     *
     * @Id
     * @ManyToOne(targetEntity="Diagnosers", inversedBy="individuals", cascade={"persist","refresh"})
     * @JoinColumns({
     *   @JoinColumn(name="diagnosers_id", referencedColumnName="id")
     * })
     */
    private $diagnosers;

    /**
    * @var smallint $status
    *
    * @Column(name="status_individuals", type="smallint")
    */
    private $statusIndividuals;

    [...]
}

class Individuals
{
    /**
     * @var Users
     *
     * @OneToOne(targetEntity="Users", cascade={"persist","detach","merge","refresh","remove"}, orphanRemoval=true)
     * @JoinColumns({
     *   @JoinColumn(name="users_id", referencedColumnName="id", unique=true)
     * })
     */
    private $users;

    /**
     * @var Advertisements
     *
     * @OneToMany(targetEntity="Advertisements", mappedBy="individuals")
     */
    private $advertisements;

    /**
     * @var IndividualsStatus
     *
     * @OneToMany(targetEntity="IndividualsStatus", mappedBy="individuals", cascade={"refresh", "remove", "persist"})
     * @joinColumns({
     *   @JoinColumn(name="individuals_id", referencedColumnName="id")
     * })
     */
    private $diagnosers;

  [...]
}

class Diagnosers
{
    /**
     * @var Users
     *
     * @OneToOne(targetEntity="Users", cascade={"persist","remove","detach","merge","refresh"})
     * @JoinColumns({
     *   @JoinColumn(name="users_id", referencedColumnName="id", unique=true)
     * })
     */
    private $users;

    /**
     * @var Pros
     *
     * @OneToOne(targetEntity="Pros", cascade={"persist","remove","detach","merge","refresh"})
     * @JoinColumns({
     *   @JoinColumn(name="pros_id", referencedColumnName="id", unique=true)
     * })
     */
    private $pros;

    /**
     * @var Reports
     *
     * @OneToMany(targetEntity="Reports", mappedBy="diagnosers", cascade={"refresh", "remove"})
     */
    private $reports;

    /**
     * @var IndividualsStatus
     *
     * @OneToMany(targetEntity="IndividualsStatus", mappedBy="diagnosers", cascade={"refresh", "remove", "persist"})
     * @joinColumns({
     *   @JoinColumn(name="diagnosers_id", referencedColumnName="id")
     * })
     */
    private $individuals;
}

Note that in individuals, the relation called "Diagnosers" refered to IndividualsStatus entity.
Note that in diagnosers, the relation called "Individuals" refered to IndividualsStatus entity.

When I execute this DQL request:
   $qb->select(array('i', 'iss', 'u')) 
           ->from('IndividualsStatus', 'iss') 
           ->join('iss.individuals', 'i') 
           ->join('i.users', 'u') 
           ->where('iss.diagnosers = ?1') 
           ->andWhere('iss.individuals = ?2') 
           ->setParameters(array(1 => $idDiag, 2 => $id)); 

I retrieve an IndividualsStatus entity:

object(stdClass)[149] 
  public '__CLASS__' => string 'IndividualsStatus' (length=37) 
  public 'individuals' => 
    object(stdClass)[148] 
      public '__CLASS__' => string 'Individuals' (length=31) 
      public 'reference' => string '451' (length=3) 
      public 'maxAdvertisements' => null 
      public 'role' => int 2 
      public 'id' => int 8 
      public 'users' => string 'Users' (length=25) 
      public 'advertisements' => string 'Array(0)' (length=8) 
      public 'diagnosers' => string 'Array(1)' (length=8) 
      public 'ownedReports' => string 'Array(0)' (length=8) 
      public 'reports' => string 'Array(0)' (length=8) 
      public '_em' => null 
  public 'diagnosers' => 
    object(stdClass)[154] 
      public '__CLASS__' => string 'Proxies 
\OpengroupeEntitiesDiagnosersProxy' (length=61) 
      public 'id' => string '19' (length=2) 
  public 'statusIndividuals' => int 1 
  public '_em' => null 

Now i want to access to the "Diagnosers" relation of the Individuals:
\Doctrine\Common\Util\Debug::dump($individualsStatus->getIndividuals()->getDiagnosers());

In my database, this individuals got 2 diagnosers attached, but only 1 is dumped.
For getting the 2, i have to select the Diagnosers relation into my Dql request:

   $qb->select(array('i', 'iss', 'u', 'd')) 
           ->from('IndividualsStatus', 'iss') 
           ->join('iss.individuals', 'i') 
           ->join('i.diagnosers', 'd') 
           ->join('i.users', 'u') 
           ->where('iss.diagnosers = ?1') 
           ->andWhere('iss.individuals = ?2') 
           ->setParameters(array(1 => $idDiag, 2 => $id)); 

Then if i do \Doctrine\Common\Util\Debug::dump($individualsStatus->getIndividuals()->getDiagnosers())
I have my 2 diagnosers display.



 Comments   
Comment by Jonathan Clus [ 27/May/11 ]

I test something more simple with the same entiies:

$diagnosers = $em->getRepository('Diagnosers')->find(19);
$listDiag = $diagnosers->getIndividuals();

In my database, the Diagnoser(19) got 20 individualsStatus(remember the relation called "Individuals" in "Diagnosers" return "IndividualsStatus" entities)
So this function return only 1 individualStatus(minor id in bdd).

I am completly blocked in my developpement. Did my entity annotation for the relation is bad ?

Comment by Benjamin Eberlei [ 05/Jun/11 ]

Formatting

Comment by Benjamin Eberlei [ 05/Jun/11 ]

This issue is related to foreign key identifiers, not using them will solve the problem. Your annotations are good.

However I fixed an issue of this kind some weeks ago. Are you using the Download of 2.1 Beta? Can you try to update to the latest version on Git?

Comment by Benjamin Eberlei [ 05/Jun/11 ]

Yes just seeing i fixed the bug AFTER releasing BEta 1. Please upgrade and verify!

Comment by Benjamin Eberlei [ 11/Jun/11 ]

Resolved





[DDC-1051] Generated SQL Query Missing Table/Join Constraint leading to SQL Syntax Error Created: 28/Feb/11  Updated: 28/Feb/11  Resolved: 28/Feb/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, Mapping Drivers, ORM
Affects Version/s: 2.0
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Roger Webb Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

RedHat Enterprise, PHP 5.3.4, Symfony2 (Sandbox PR7)



 Description   

SELECT u, uc, ur
FROM ARN\EntityBundle\Entity\Users u
INNER JOIN u.contact_info uc
INNER JOIN u.user_roles ur
WHERE u.username = :username

Generates the following SQL Query

SELECT u0_.user_id AS user_id0, u0_.username AS username1, u0_.password AS password2, u0_.contact_info_id AS contact_info_id3, u0_.user_active AS user_active4, u0_.user_date AS user_date5, u0_.office_id AS office_id6, u0_.superuser AS superuser7, c1_.contact_info_id AS contact_info_id8, c1_.first_name AS first_name9, c1_.last_name AS last_name10, c1_.address AS address11, c1_.city_id AS city_id12, c1_.zip AS zip13, c1_.email AS email14, u2_.user_role_id AS user_role_id15, u2_.role AS role16, u0_.contact_info_id AS contact_info_id17, c1_.city_id AS city_id18 FROM users u0_ INNER JOIN contact_info c1_ ON u0_.contact_info_id = c1_.contact_info_id INNER JOIN WHERE u0_.user_id = ?')

Notice the "INNER JOIN WHERE", this is the problem.

The mapping is as follows:

Users->user_roles

/**

  • @orm:OneToMany(targetEntity="UserRoles", mappedBy="user")
    */
    protected $user_roles;

UserRoles->user

/**

  • @ManyToOne(targetEntity="Users", inversedBy="user_roles")
  • @JoinColumn(name="user_id", referencedColumnName="user_id")
    */
    protected $user;

Let me know if you need any more information. Happy to help. Thanks.



 Comments   
Comment by Roger Webb [ 28/Feb/11 ]

Problem was due to a missing "orm:" prefix for symfony annotations. Thanks.





[DDC-1063] Yaml mapping driver cant find Symfony/Component/Yaml/Yaml.php Created: 08/Mar/11  Updated: 14/Mar/11  Resolved: 14/Mar/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.0.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Nikola Petkanski Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 10.10; PHP 5.3;



 Description   

As of the release of Doctrine ORM 2.0.2 I cannot seem to be able to use the Yaml mapping driver.

PHP Warning: require(/usr/share/php/Doctrine/Symfony/Component/Yaml/Yaml.php): failed to open stream: No such file or directory in /usr/share/php/Doctrine/Common/ClassLoader.php on line 148

I do have the Doctrine 2.0.2 packages installed, here's the output from my console:

Installed packages, channel pear.doctrine-project.org:
======================================================
Package Version State
DoctrineCommon 2.0.1 stable
DoctrineDBAL 2.0.2 stable
DoctrineORM 2.0.2 stable
DoctrineSymfonyConsole 2.0.2 stable
DoctrineSymfonyYaml 2.0.2 stable

It is all up to date, so I am not missing anything.

root@nikola-pc:/usr/share/php# pear upgrade-all
Nothing to upgrade-all

Navigating to the /usr/share/php folder, where the PEAR and all other stuff is located I can't seem to find the Yaml.php file, which should be distributed by some of the newly formed packages.

root@nikola-pc:/usr/share/php# find -iname 'yaml*'
./Doctrine/ORM/Mapping/Driver/YamlDriver.php
./Doctrine/ORM/Tools/Export/Driver/YamlExporter.php
./.registry/.channel.pear.symfony-project.com/yaml.reg
./data/DoctrineSymfonyYaml/Doctrine/Symfony/Component/Yaml
./PHPUnit/Extensions/Database/DataSet/YamlDataSet.php
./PHPUnit/Extensions/Database/DataSet/Persistors/Yaml.php
./PHPUnit/Extensions/Database/DataSet/Specs/Yaml.php
./SymfonyComponents/YAML

root@nikola-pc:/usr/share/php# find -iname 'yaml.php'
./PHPUnit/Extensions/Database/DataSet/Persistors/Yaml.php
./PHPUnit/Extensions/Database/DataSet/Specs/Yaml.php
root@nikola-pc:/usr/share/php#

root@nikola-pc:/usr/share/php/data/DoctrineSymfonyYaml# find
.
./LICENSE
./Doctrine
./Doctrine/Symfony
./Doctrine/Symfony/Component
./Doctrine/Symfony/Component/Yaml
./Doctrine/Symfony/Component/Yaml/LICENSE
./bin
./bin/doctrine.bat
./bin/doctrine
root@nikola-pc:/usr/share/php/data/DoctrineSymfonyYaml#

Please advise me what the possible solution would be in this case?



 Comments   
Comment by Benjamin Eberlei [ 10/Mar/11 ]

What Files are in the ./Doctrine/Symfony/Component/YAML Directory? Only LICENSE? Then maybe my build failed somehow.

Comment by Nikola Petkanski [ 10/Mar/11 ]

Yes, only the LICENSE file is present.

root@nikola-pc:~# ls -lha /usr/share/php/data/DoctrineSymfonyYaml/Doctrine/Symfony/Component/Yaml/
total 12K
drwxr-xr-x 2 root root 4.0K 2011-03-07 14:21 .
drwxr-xr-x 3 root root 4.0K 2011-03-07 14:21 ..
-rw-r--r-- 1 root root 1.1K 2011-03-07 14:21 LICENSE
root@nikola-pc:~# 

P.S It would be nice for the documentation to be updated with recommendations on how to setup the autoloader for versions 2.0.2+.
http://www.doctrine-project.org/docs/orm/2.0/en/reference/configuration.html#additional-symfony-components

Comment by Benjamin Eberlei [ 13/Mar/11 ]

It works for me, i have installed DoctrineSYmfonyYaml on another machine and it contains all the relevant contents.

Have you tried uninstall and install the package again?

pear uninstall doctrine/DoctrineSymfonyYaml
pear install doctrine/Doctrine/SymfonyYaml
Comment by Nikola Petkanski [ 14/Mar/11 ]

I cannot understand the commands you've gave me - utilizing phpunit to uninstall PEAR component? Really?

Anyway.. I've tried to uninstall and re-install, but it does not seem to be fixed.

Please, check the output from my console and inform me if I am doing something wrong.

root@nikola-pc:~# pear list -a | grep Doctrine
DoctrineCommon         2.0.1   stable
DoctrineDBAL           2.0.2   stable
DoctrineORM            2.0.2   stable
DoctrineSymfonyConsole 2.0.2   stable
DoctrineSymfonyYaml    2.0.2   stable
root@nikola-pc:~# pear uninstall Doctrine/DoctrineSymfonyYaml 
doctrine/DoctrineSymfonyYaml (version >= 2.0.0) is required by installed package "doctrine/DoctrineORM"
doctrine/DoctrineSymfonyYaml cannot be uninstalled, other installed packages depend on this package
root@nikola-pc:~# pear uninstall Doctrine/DoctrineORM
uninstall ok: channel://pear.doctrine-project.org/DoctrineORM-2.0.2
root@nikola-pc:~# pear list -a | grep Doctrine
DoctrineCommon         2.0.1   stable
DoctrineDBAL           2.0.2   stable
DoctrineSymfonyConsole 2.0.2   stable
DoctrineSymfonyYaml    2.0.2   stable
root@nikola-pc:~# pear uninstall Doctrine/DoctrineSymfonyYaml 
uninstall ok: channel://pear.doctrine-project.org/DoctrineSymfonyYaml-2.0.2
root@nikola-pc:~# pear list -a | grep Doctrine
DoctrineCommon         2.0.1   stable
DoctrineDBAL           2.0.2   stable
DoctrineSymfonyConsole 2.0.2   stable
root@nikola-pc:~# pear upgrade-all
Nothing to upgrade-all
root@nikola-pc:~# pear update-channels
Updating channel "components.ez.no"
Channel "components.ez.no" is up to date
Updating channel "doc.php.net"
Channel "doc.php.net" is up to date
Updating channel "pear.doctrine-project.org"
Channel "pear.doctrine-project.org" is up to date
Updating channel "pear.pdepend.org"
Channel "pear.pdepend.org" is up to date
Updating channel "pear.phing.info"
Channel "pear.phing.info" is up to date
Updating channel "pear.php.net"
Channel "pear.php.net" is up to date
Updating channel "pear.phpunit.de"
Channel "pear.phpunit.de" is up to date
Updating channel "pear.symfony-project.com"
Channel "pear.symfony-project.com" is up to date
Updating channel "pecl.php.net"
Channel "pecl.php.net" is up to date
root@nikola-pc:~# pear install Doctrine/DoctrineORM
downloading DoctrineORM-2.0.2.tgz ...
Starting to download DoctrineORM-2.0.2.tgz (194,608 bytes)
.........................................done: 194,608 bytes
downloading DoctrineSymfonyYaml-2.0.2.tgz ...
Starting to download DoctrineSymfonyYaml-2.0.2.tgz (19,883 bytes)
...done: 19,883 bytes
install ok: channel://pear.doctrine-project.org/DoctrineSymfonyYaml-2.0.2
install ok: channel://pear.doctrine-project.org/DoctrineORM-2.0.2
root@nikola-pc:~# ls -lha /usr/share/php/data/DoctrineSymfonyYaml/Doctrine/Symfony/Component/Yaml/
total 12K
drwxr-xr-x 2 root root 4.0K 2011-03-14 11:15 .
drwxr-xr-x 3 root root 4.0K 2011-03-14 11:15 ..
-rw-r--r-- 1 root root 1.1K 2011-03-14 11:15 LICENSE
root@nikola-pc:~# 
Comment by Nikola Petkanski [ 14/Mar/11 ]

It seems to be fixed. Perhaps you've fixed the package and during my uninstall-install it was set properly.

root@nikola-pc:/usr/share/php# find -iname 'yaml.php'
./Doctrine/Symfony/Component/Yaml/Yaml.php
./PHPUnit/Extensions/Database/DataSet/Persistors/Yaml.php
./PHPUnit/Extensions/Database/DataSet/Specs/Yaml.php

Thanks for fixing it up

P.S I was having the same issue with the symfony console, but re-installing the ORM and the DBAL packages helped.

Comment by Benjamin Eberlei [ 14/Mar/11 ]

lol, i got confsued. I meant "pear" of course. Fixed my previous comment.

Comment by Benjamin Eberlei [ 14/Mar/11 ]

I had the packages built wrong right after the 2.0.2 release, but only for 2-4 hours. After that they were complete. Good it works for you now, sorry for the difficulties





[DDC-844] Call to undefined function Doctrine\ORM\Query\ctype_alpha() in Doctrine/ORM/Query/Lexer.php Created: 20/Oct/10  Updated: 20/Oct/10  Resolved: 20/Oct/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0-BETA4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Justin Otherguy Assignee: Roman S. Borschel
Resolution: Fixed Votes: 1
Labels: None
Environment:

OpenWRT/x86 within vmware fusion
OpenWRT backfire 10.03
lighttpd - 1.4.26-2
php5 - 5.3.1-3
php5-cgi - 5.3.1-3
php5-mod-json - 5.3.1-3
php5-mod-pdo - 5.3.1-3
php5-mod-pdo-pgsql - 5.3.1-3
php5-mod-pgsql - 5.3.1-3
pgsql-server - 8.3.3-2



 Description   

Hi there,

we're trying to get our code to run on OpenWRT; for now inside a vmware environment.
You can find our code here:
http://github.com/volkszaehler/volkszaehler.org

accessing this url
http://192.168.189.179/backend/index.php/data/a301d8d0-903b-11df-94bb-d943d061b6a8.json
we get:

"Fatal error: Call to undefined function Doctrine\ORM\Query\ctype_alpha() in /www/doctrine/doctrine/lib/Doctrine/ORM/Query/Lexer.php on line 158"

our debug output ("&debug=5" appended to URL) looks like this:
{"source":"volkszaehler.org","version":0.2,"component":"backend","exception":{"type":"Exception","message":"Unknown format: json&debug=5","code":0}}

Thanks in advance!

Regards, J.



 Comments   
Comment by Justin Otherguy [ 20/Oct/10 ]

Hi,

seems package php5-mod-ctype was missing.

It's working now...

Thanks anyway!

Keep up the good work - looking forward to the final version

Regards, J.





[DDC-765] \Symfony\Components renamed to \Symfony\Component (singular) ... refactoring unfinished. console cannot be invoked Created: 25/Aug/10  Updated: 30/Aug/10  Resolved: 29/Aug/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.0-BETA3
Fix Version/s: 2.0-BETA4
Security Level: All

Type: Bug Priority: Blocker
Reporter: Radomirs Cirskis Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

winXP, PHP 5.3.3



 Description   

I pulled from github the whole thing, but still stuck with sandbox:

\doctrine\tools\sandbox>php doctrine.php
.PHP Warning: require(doctrine\lib\vendor\Symfony\Components\Console\Helper\Helper.php): failed to open st
ream: No such file or directory in C:\Inetpub\wwwroot\BugTrackerORM\doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common\ClassLoader.php
on line 148
PHP Stack trace:
PHP 1.

{main}

() ..... doctrine\tools\sandbox\doctrine.php:0
PHP 2. require() .... doctrine\tools\sandbox\doctrine.php:21
PHP 3. Doctrine\Common\ClassLoader->loadClass() ... doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common\C
lassLoader.php:0
PHP 4. require() ... doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common\ClassLoader.php:148
PHP 5. Doctrine\Common\ClassLoader->loadClass() C:\Inetpub\wwwroot\BugTrackerORM\doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common\C
lassLoader.php:0

Warning: require(.... doctrine\lib\vendor\Symfony\Components\Console\Helper\Helper.php): failed to open stream:
No such file or directory in.... doctrine\lib\vendor\doctrine-common\lib\Doctrine\Common\ClassLoader.php on lin
e 148

well, it seams that at some stage Symfony\Components got renamed to Symfony\Coponet:

$ git log Component
commit 4a9f36800e3f55bc2cf61033573e1103594b4742
Author: S<C3><A9>bastien HOUZE <sebastienhouze@mbash.livebox.home>
Date: Mon Aug 23 08:21:41 2010 +0200
Symfony/Components renamed into Symfony/Component

When I copied Component into Componets I got:
.PHP Fatal error: Cannot redeclare class Symfony\Component\Console\Helper\Helper in doctrine\lib\vendor\Sy
mfony\Components\Console\Helper\Helper.php on line 21



 Comments   
Comment by Nico Kaiser [ 27/Aug/10 ]

Same for me, even worse, despite git submodule dependencies, the submodules (and their submodules) have different versions of "Components" vs. "Component", so the CLI is broken now.

Comment by Benjamin Eberlei [ 29/Aug/10 ]

Yes this sucks, unfortunately for ORM depending on DBAL Beta 3 we cannot easily change this.

Workaround until the next release of DBAL is uncommenting the following two lines instantiating DBAL Commands from your doctrine.php:

$cli->addCommands(array(
    // DBAL Commands
    //new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(),
    //new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(),

For the next release this week this will be resolved.

Comment by Sherri Flemings [ 30/Aug/10 ]

I came across this issue today. I installed Doctrine via PEAR and had to do a few things to get the sandbox example working, which might help as a workaround until the next release:

1. make sure the PEAR directory is part of your php.ini include path
2. move the Symfony directory from 'PEAR/Doctrine/Symfony' to 'PEAR/Symfony'
3. update the paths to Doctrine & Symfony inside 'tools/sandbox/doctrine.php' & 'tools/sandbox/cli-config.php'

I can now work with the sandbox examples.

As a reference, this is what my cli-config.php source looks like now: (sorry for the unformatted code <pre> tag & [code] weren't recognized.)

<?php

require_once 'Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(_DIR_ . 'Doctrine/ORM'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(_DIR_ . 'Doctrine/DBAL'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(_DIR_ . 'Doctrine/Common'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(_DIR_ . 'Symfony'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Entities', _DIR_);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', _DIR_);
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(_DIR_."/Entities"));
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(_DIR_ . '/Proxies');
$config->setProxyNamespace('Proxies');

$connectionOptions = array(
'driver' => 'pdo_sqlite',
'path' => 'database.sqlite'
);

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

$helpers = array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
);





[DDC-714] Fix of DDC-167 creates FatalError when persisting a new entity Created: 22/Jul/10  Updated: 25/Jul/10  Resolved: 25/Jul/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0-BETA3, 2.0-BETA4
Fix Version/s: 2.0-BETA3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Michael Zach Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Debian 5 (64bit), Postgresql 8.3, ZendServer 5.0.2, PHP 5.3.2, Doctrine-HEAD


Attachments: File uow.diff    

 Description   

The resolution of DDC-167 introduced a new problem in UnitOfWork on line 612 (function persistNew()) as well - when I try to save an entity, I get an Exception from my error handler (who captues php errors):

ErrorException with Argument 2 passed to Doctrine\ORM\Mapping\ClassMetadata::setIdentifierValues() must be an array, integer given, called in /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php on line 612 and defined
Backtrace: #0: Doctrine\ORM\Mapping\ClassMetadata->setIdentifierValues at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:612
#1: Doctrine\ORM\UnitOfWork->persistNew at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:1247
#2: Doctrine\ORM\UnitOfWork->doPersist at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/UnitOfWork.php:1210
#3: Doctrine\ORM\UnitOfWork->persist at /var/www/svn/cWorld_ZF/branches/devel-trunk/library/Doctrine/ORM/EntityManager.php:438

The relevant code in UoW is:

            $idValue = $idGen->generate($this->em, $entity);
            if ( ! $idGen instanceof \Doctrine\ORM\Id\AssignedGenerator) {
                $this->entityIdentifiers[$oid] = array($class->identifier[0] => $idValue);
                $class->setIdentifierValues($entity, $idValue);

We're using the SequenceGenerator

@SequenceGenerator(allocationSize=1,sequenceName="address_id_seq")

which doesn't return an array, so the array typehint fails and generates an error.

The fix, which worked for me, is attached.



 Comments   
Comment by Benjamin Eberlei [ 25/Jul/10 ]

This bug also leads to about 400 test failures in the Postgres ORM Testsuite

Comment by Benjamin Eberlei [ 25/Jul/10 ]

Fixed! Thanks for reporting.





[DDC-646] Missing inclusion of namespace Created: 19/Jun/10  Updated: 19/Jun/10  Resolved: 19/Jun/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.0-BETA2
Fix Version/s: 2.0-BETA3
Security Level: All

Type: Bug Priority: Blocker
Reporter: Antoine Hedgecock Assignee: Roman S. Borschel
Resolution: Fixed Votes: 0
Labels: None


 Description   

ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand.php requires that you include the following namespace

Doctrine\ORM\Tools\EntityGenerator,

else the following error is thrown

PHP Warning:  require(Doctrine/ORM/Tools/Console/Command/EntityGenerator.php): failed to open stream: No such file or directory in /usr/local/zend/share/pear/Doctrine/Common/ClassLoader.php on line 148
PHP Fatal error:  require(): Failed opening required 'Doctrine/ORM/Tools/Console/Command/EntityGenerator.php' (include_path='/Users/antoine/Sites/startaeget-3.3/application/library:.:/usr/local/zend/share/ZendFramework/library:/usr/local/zend/share/pear') in /usr/local/zend/share/pear/Doctrine/Common/ClassLoader.php on line 148


 Comments   
Comment by Benjamin Eberlei [ 19/Jun/10 ]

fixed.





[DDC-491] Quoting Patch completly wrecked OCI8 support Created: 02/Apr/10  Updated: 02/Apr/10  Resolved: 02/Apr/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.0-ALPHA4
Fix Version/s: 2.0-BETA1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Benjamin Eberlei Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The quoting issue broke the OCI8 Driver, there is a fatal because of changes in the interface, and fixting that there are 160 test-failures



 Comments   
Comment by Benjamin Eberlei [ 02/Apr/10 ]

Failure is always something like:

164) Doctrine\Tests\ORM\Functional\Ticket\Ticket2481Test::testEmptyInsert
Exception: [PHPUnit_Framework_Error_Warning] Invalid argument supplied for foreach()

With queries:
4. SQL: 'INSERT INTO ticket_2481_products (id) VALUES (?)' Params: '1'
3. SQL: 'SELECT ticket_2481_products_id_seq.nextval FROM DUAL' Params: 
2. SQL: 'CREATE SEQUENCE ticket_2481_products_id_seq START WITH 1 MINVALUE 1 INCREMENT BY 10' Params: 

Trace:
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/DBAL/Driver/OCI8/OCI8Statement.php:138
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/DBAL/Statement.php:130
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php:187
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/ORM/UnitOfWork.php:698
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/ORM/UnitOfWork.php:291
/home/benny/code/php/wsnetbeans/Doctrine/trunk/lib/Doctrine/ORM/EntityManager.php:281
/home/benny/code/php/wsnetbeans/Doctrine/trunk/tests/Doctrine/Tests/ORM/Functional/Ticket/Ticket2481Test.php:27
Comment by Benjamin Eberlei [ 02/Apr/10 ]

Fixed





[DDC-427] DoctrineException.php is an empty file! Created: 16/Mar/10  Updated: 14/Jun/10  Resolved: 16/Mar/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Mario Weidler Assignee: Roman S. Borschel
Resolution: Fixed Votes: 0
Labels: None


 Description   

http://svn.doctrine-project.org/trunk/lib/Doctrine/Common/DoctrineException.php is an empty file after rev 7313. in rev 7312 it is ok.



 Comments   
Comment by Roman S. Borschel [ 16/Mar/10 ]

It is removed now. Thanks for the notice.





[DDC-309] ReflectionException when using AbstractQuery::iterate() Created: 09/Feb/10  Updated: 09/Feb/10  Resolved: 09/Feb/10

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.0-BETA1
Security Level: All

Type: Bug Priority: Blocker
Reporter: Nico Kaiser Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File ddc309.patch    

 Description   

When I use two Queries and iterate() over the results, the second one fails with a PHP Fatal error (ReflectionException). It has a strange message ('Class does not exist').
This happens with any two different entities. The error seems to occur when next() is called (directly or via foreach) and the objects are being created.

$q = $em->createQuery('SELECT c FROM Entity\Country c');
$q->iterate()->next();

$q = $em->createQuery('SELECT u FROM Entity\User u');
$q->iterate()->next(); // FAILS

Entities:
http://pastie.org/816374

Example code:
http://pastie.org/816377



 Comments   
Comment by Benjamin Eberlei [ 09/Feb/10 ]

It seems IterableResult does not support two iterators at once, because it re-uses the hydrator for both queries - effectivly deleting the information from the previous query and destroying the call.

Comment by Benjamin Eberlei [ 09/Feb/10 ]

Suggested patch

Comment by Benjamin Eberlei [ 09/Feb/10 ]

Fixed!





[DDC-231] YAML isn't persisting correcty Created: 30/Dec/09  Updated: 30/Dec/09  Resolved: 30/Dec/09

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.0-ALPHA3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Henrique Girardi dos Santos Assignee: Roman S. Borschel
Resolution: Invalid Votes: 0
Labels: None
Environment:

Ubuntu 9.04 -
PHP 5.3.1-0.dotdeb.0 with Suhosin-Patch (cli) (built: Nov 28 2009 13:18:25)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2009 Zend Technologies
with Xdebug v2.0.5, Copyright (c) 2002-2008, by Derick Rethans
with Suhosin v0.9.29, Copyright (c) 2007, by SektionEins GmbH
-
PostgreSQL 8.3



 Description   

I'm have some problems when I try to persist..
I've created these classes:

class Customer
{
    public $id;
    public $users;

    public function __construct()
    {
        $this->users = new \Doctrine\Common\Collections\ArrayCollection();
    }
}

class User
{
    public $id;
    public $customer;
}

And then I make the mappers with YAML

Ciutat\DomainModel\Customer:
  type: entity
  table: customer
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: auto
      sequenceGenerator:
        sequenceName: customer_id_seq
        allocationSize: 1
        initialValue: 1
  oneToMany:
    users:
      targetEntity: User
      mappedBy: customer
      cascade: cascadePersist

Ciutat\DomainModel\User:
  type: entity
  table: user1
  fields:
    id:
      type: integer
      id: true
      generator:
        strategy: auto
      sequenceGenerator:
        sequenceName: user1_id_seq
        allocationSize: 1
        initialValue: 1
  manyToOne:
    customer:
      targetEntity: Customer
      joinColumn:
        name: customerId
        referencedColumnName: id

And when I try to persist some data

$costumer = new DomainModel\Customer();
$user = new DomainModel\User();
$user2 = new DomainModel\User();
$user3 = new DomainModel\User();

$costumer->users->add($user);
$costumer->users->add($user2);
$costumer->users->add($user3);
    
$em->persist($costumer);
$em->flush();

the result in my database is not what I think it must be expected

select * from customer;
 id 
----
  1

elect * from user1;
 id | customerid 
----+------------
  1 |           
  2 |           
  3 |           

I would like to know if have some mistake with my code or is there a problem with YAML? 'cause I think there should be some data on 'customerId', don't I ?



 Comments   
Comment by Roman S. Borschel [ 30/Dec/09 ]

This is expected behavior. You must maintain the bidirectional association properly. Doctrine only looks at the "owning side" of a bidirectional association. In the case of a bidirectional one-to-many, like in your case, the owning side is always the many-side. Since you only add the elements to the collection, but dont set the customer property pointing back to the customer, the association does not exist for Doctrine.

Change your code to:

$costumer = new DomainModel\Customer();
$user = new DomainModel\User();
$user2 = new DomainModel\User();
$user3 = new DomainModel\User();

$costumer->users->add($user);
$user->customer = $costumer;
$costumer->users->add($user2);
$user2->customer = $costumer;
$costumer->users->add($user3);
$user3->customer = $costumer;

$em->persist($costumer);
$em->flush();

And it should work.

Please read this section carefully: http://www.doctrine-project.org/documentation/manual/2_0/en/association-mapping#owning-side-and-inverse-side

Its a simple, yet essential concept to understand.

Hope that helps.

Comment by Henrique Girardi dos Santos [ 30/Dec/09 ]

I did this way sometime ago but I thought I was a mistake mine..but I see i was correct..
I created a prePersist method where I did it automatic and a postPersist to unset after that, cause I dont see any another reason to keep all my object customer inside the User class if inside Customer I have a User collection, so I know which Users belong to Customer..

why I need to set

oneToMany:
    users:
      targetEntity: User
      mappedBy: customer
      cascade: cascadePersist

in Customer?? I thought if I set the target and the mappedBy it would be enough..can't it be automatic? Or it's impossible?

Comment by Roman S. Borschel [ 30/Dec/09 ]

You dont need prePersist or postPersist. You just need to maintain your bidirectional associations properly. This is nothing doctrine specific, basic OOP.

And it is not automatic because this would break transparency. Its not the task of the ORM to fix your broken associations. Then your object model is suddenly broken without the persistence layer.

If you want a unidirectional one-to-many, you must map it through a join table. Its all in the documentation.

The behavior is very consistent and predictable (compared to what D1 does, for example...)

Comment by Henrique Girardi dos Santos [ 30/Dec/09 ]

I know I dont need prePersist or postPersist, It was just my choice, I just created them to make it automaticaly..
and I don't want a unidirectional..there's no reason to have another table to join them..
but now I understood why it's not automatic..

thanks man!





[DDC-188] Collections are not hydrated properly Created: 02/Dec/09  Updated: 02/Dec/09  Resolved: 02/Dec/09

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Nico Kaiser Assignee: Roman S. Borschel
Resolution: Invalid Votes: 0
Labels: None


 Description   

The following example has User and Address entities, where User has many Addresses (ArrayCollection).

http://pastebin.com/f1f065cb0

$u = $em->find('Entity\User', $id);
$addresses = $u->getAddresses();
foreach ($addresses as $a) { }  // This line breaks!

The script runs until the foreach loop, then it breaks with a fatal error:

PHP Notice:  Undefined variable: owningAssoc in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persist
ers/StandardEntityPersister.php on line 545
PHP Fatal error:  Uncaught exception 'Doctrine\ORM\ORMException' with message 'Unrecognized field: user
Id' in /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/ORMException.php:14
Stack trace:
#0 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(660): Doctrin
e\ORM\ORMException::unrecognizedField('userId')
#1 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Persisters/StandardEntityPersister.php(545): Doctrin
e\ORM\Persisters\StandardEntityPersister->_getSelectEntitiesSql(Array, NULL)
#2 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/Mapping/OneToManyMapping.php(133): Doctrine\ORM\Pers
isters\StandardEntityPersister->loadOneToManyCollection(Array, Object(Doctrine\ORM\PersistentCollection
))
#3 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(244): Doctrine\ORM\Mapping\
OneToManyMapping->load(Object(Entity\User), Object(Doctrine\ORM\PersistentCollection), Object(Doctrine\
ORM\EntityManager))
#4 /home/kaiser/doctrine/doctrine/lib/Doctrine/ORM/PersistentCollection.php(549): Doc in /home/kaiser/d
octrine/doctrine/lib/Doctrine/ORM/ORMException.php on line 14

If I uncomment the user creation code in my pastebin example (i.e. create User, Address first), it works as expected (assumingly because everything is in the EM already).

So this bug probably breaks all select-only use cases with collections (which makes it a Blocker in my opinion).



 Comments   
Comment by Roman S. Borschel [ 02/Dec/09 ]

Hm, this is dubious as this is directly and indirectly tested all over the place.

I was unable to reproduce it as of yet. Will keep you updated.

Comment by Roman S. Borschel [ 02/Dec/09 ]

Are you sure you dont have local modifications? The notice looks suspicious and _getSelectEntitiesSql(Array, NULL) does not look correct either. The association should be passed in.

Comment by Roman S. Borschel [ 02/Dec/09 ]

Your patch in DDC-162 is what breaks it.





[DDC-25] Boolean type does not work Created: 01/Oct/09  Updated: 14/Jun/10  Resolved: 01/Oct/09

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.0-ALPHA2
Security Level: All

Type: Bug Priority: Blocker
Reporter: Ismo Toijala Assignee: Roman S. Borschel
Resolution: Fixed Votes: 0
Labels: None


 Description   

The boolean type does not work. The method used by BooleanType does not exist. It should probably use getBooleanTypedeclarationSql(array $field).

In Doctrine\DBAL\Types\BooleanType:

OLD:
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getBooleanDeclarationSql();
}

NEW:
public function getSqlDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getBooleanTypeDeclarationSql($fieldDeclaration);
}



 Comments   
Comment by Roman S. Borschel [ 01/Oct/09 ]

Just checked and this has already been fixed in HEAD and is therefore already fixed for the next release.

Thanks!





[DDC-3078] Doctrine\ORM\Cache::__construct is in an interface Created: 10/Apr/14  Updated: 17/Apr/14  Resolved: 17/Apr/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: Git Master
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Blocker
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: cache, config, second-level-cache

Issue Links:
Dependency
depends on DDC-3080 [GH-1008] DDC-3078 SLC Cache interfac... Resolved

 Description   

CTOR in the interface is a huge problem. This absolutely needs to be fixed before 2.5 is released, or we will have trouble in future.

I'm writing a PoC patch right now.



 Comments   
Comment by Fabio B. Silva [ 17/Apr/14 ]

Fixed by https://github.com/doctrine/doctrine2/commit/6af3236ba6f285fe14763866b20ddc1085e6ea39





[DDC-3094] dbal and orm versions not compatible Created: 20/Apr/14  Updated: 20/Apr/14  Resolved: 20/Apr/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Blocker
Reporter: Luis Cordova Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: dbal, orm


 Description   

( ! ) Fatal error: Call to undefined method Doctrine\ORM\Event\LifecycleEventArgs::format() in /Users/cordoval/Sites/x/vendor/doctrine/dbal/lib/Doctrine/DBAL/Types/DateTimeType.php on line 53

This is happening on sf2.4 default project

"require":

{ "php": ">=5.3.3", "symfony/symfony": "~2.4", "doctrine/orm": "~2.2,>=2.2.3", "doctrine/doctrine-bundle": "~1.2", "twig/extensions": "~1.0", "symfony/assetic-bundle": "~2.3", "symfony/swiftmailer-bundle": "~2.3", "symfony/monolog-bundle": "~2.4", "sensio/distribution-bundle": "~2.3", "sensio/framework-extra-bundle": "~3.0", "incenteev/composer-parameter-handler": "~2.0", "jms/security-extra-bundle": "1.5.*", "jms/di-extra-bundle": "1.4.*", "friendsofsymfony/user-bundle": "dev-master@dev", "doctrine/doctrine-migrations-bundle": "dev-master@dev", "doctrine/migrations": "dev-master@dev", "doctrine/doctrine-fixtures-bundle": "dev-master@dev", "doctrine/data-fixtures": "dev-master@dev", "symfony/icu": "~1.1", "colourstream/cron-bundle": "dev-update23@dev", "nelmio/alice": "dev-master@dev", "raulfraile/ladybug-bundle": "0.7", "guzzle/guzzle": "~3.7", "jms/serializer-bundle": "0.12.0", "beberlei/DoctrineExtensions": "dev-master@dev" }

,
"require-dev":

{ "behat/behat": "~3.0@dev", "phpspec/phpspec": "dev-master@dev", "phpspec/symfony2-extension": "dev-master@dev", "behat/mink-bundle": "~1.4", "phpunit/phpunit": "~3.7", "behat/mink-selenium2-driver": "~1.1" }

,



 Comments   
Comment by Luis Cordova [ 20/Apr/14 ]

closing but you guys broke backward compatibility here, i had to figure it out thanks though

Comment by Luis Cordova [ 20/Apr/14 ]





[DDC-2328] [GH-597] use the extended proxy interface in the same namespace Created: 01/Mar/13  Updated: 26/Jun/14  Resolved: 03/Mar/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: 2.4

Type: Bug Priority: Blocker
Reporter: Benjamin Eberlei Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of MDrollette:

Url: https://github.com/doctrine/doctrine2/pull/597

Message:

Fix for this error:

FatalErrorException: Compile Error: Cannot use Doctrine\Common\Proxy\Proxy as Proxy because the name is already in use in .../vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php line 26



 Comments   
Comment by Marco Pivetta [ 03/Mar/13 ]

Marking as blocker - has to go in before 2.4

Comment by Benjamin Eberlei [ 03/Mar/13 ]

A related Github Pull-Request [GH-597] was closed
https://github.com/doctrine/doctrine2/pull/597

Comment by Marco Pivetta [ 03/Mar/13 ]

merged

Comment by Doctrine Bot [ 26/Jun/14 ]

A related Github Pull-Request [GH-597] was closed:
https://github.com/doctrine/dbal/pull/597





Regression in reComputeSingleEntityChangeset (DDC-3160)

[DDC-3208] Merge DDC-3160 back into 2.4.x Created: 06/Jul/14  Updated: 11/Jul/14  Due: 11/Jul/14  Resolved: 11/Jul/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.3
Fix Version/s: 2.4.4
Security Level: All

Type: Sub-task Priority: Blocker
Reporter: Marco Pivetta Assignee: Marco Pivetta
Resolution: Fixed Votes: 3
Labels: changeset, listener, unitofwork

Issue Links:
Reference
is referenced by DDC-2996 UnitOfWork::recomputeSingleEntityChan... Resolved

 Description   

DDC-3160 should be backported to 2.4.4 once user feedback is collected.



 Comments   
Comment by Kevin Bond [ 06/Jul/14 ]

I ran the DoctrineExtensions test suite with ORM 2.4 with this fix and it passed.

Comment by Justin Zimmerman [ 06/Jul/14 ]

For the project I was working on where I started having issues with the 2.4.3 update and Atlantic18/DoctrineExtensions, the DDC-3160 solution did fix the problems that I was seeing. Granted, I am only using the Tree portion of that library, I cannot say anything about the other parts of it.

I just ran a test with the latest DoctrineExtensions code. These are the results I get with running Doctrine 2.4.3:

FAILURES!
Tests: 411, Assertions: 1760, Errors: 71, Skipped: 62.

When I patch up the Doctrine 2.4.3 branch with the DDC-3160 fix, I get much better results:

OK, but incomplete, skipped, or risky tests!
Tests: 411, Assertions: 2410, Skipped: 62.

From what I can tell, this does seem to fix the DoctrineExtensions issues which I believe was eventually tracked down to being caused by the DDC-2996 fix.

Comment by Eric Coleman [ 08/Jul/14 ]

Patch is working for us.

Comment by Marco Pivetta [ 10/Jul/14 ]

Going to merge this back into 2.4.x asap

Comment by Marco Pivetta [ 11/Jul/14 ]

Merged at https://github.com/doctrine/doctrine2/commit/5c5abb6771c1f5ab8318f76aed79ce1da8a0300d





[DDC-3042] select issue field names with numbers Created: 21/Mar/14  Updated: 04/Apr/14  Resolved: 04/Apr/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.3.3, 2.4.1, 2.4.2
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Marc Lindemann Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by DDC-3043 [GH-985] [WIP] [DDC-3042] SQL Alias c... Resolved

 Description   
$qb = $this->_em->createQueryBuilder();
$qb->select('k.aktiv, k.id, k.firma, k.firma2, k.strasse, k.plz, k.ort, k.plzpostfach, k.postfach, k.bemerkung,
         k.uuid, k.telefon,k.telefonzentrale, k.istmutter, k.isttochter, k.email, k.internet, k.fax, l.id as land, m.id as mutter, m.firma as mutterv, t.id as tochter, t.firma as tochterv, kg.id as kundengruppe, s.id as sic, s.title as sicv,
         kg.title as kundengruppev,m.telefon as telefonmutter,t.telefon as telefontochter, k.id as kdnr')

will create this sql:

SELECT c0_.id AS id0, c0_.aktiv AS aktiv1, c0_.firma AS firma2, c0_.firma2 AS firma23, c0_.strasse AS strasse4, c0_.plz AS plz5, c0_.ort AS ort6, c0_.plzpostfach AS plzpostfach7, c0_.postfach AS postfach8, c0_.hotel AS hotel9, c0_.kuerzel AS kuerzel10, c0_.stornofrist AS stornofrist11, c0_.uuid AS uuid12, c0_.telefon AS telefon13, c0_.telefonzentrale AS telefonzentrale14, c0_.istmutter AS istmutter15, c0_.isttochter AS isttochter16, c0_.trainer AS trainer17, c0_.email AS email18, c0_.internet AS internet19, c0_.fax AS fax20, l6_.id AS id21, c3_.id AS id22, c3_.firma AS firma23, c3_.telefon AS telefon24, c0_.id AS id25, t1_.content AS anfahrt26, t2_.content AS beschreibung27 

as you see, it will create co.firma2 as firma23 and c3_.firma AS firma23,

now when you do:

$query = $qb->getQuery();
$result = $query->getArrayResult();
Array
(
    [0] => Array
        (
            [id] => 11
            [aktiv] => 1
            [firma] => Test GmbH
            [mutterv] => Mutter Test
            [strasse] => 
            [plz] => 
            [ort] => 
            [plzpostfach] => 
            [postfach] => 
            [hotel] => 
            [kuerzel] => 
            [stornofrist] => 0
            [uuid] => 524459b5-7f1c-442b-98dd-3d5cc0a81420
            [telefon] => 0211/415583810
            [telefonzentrale] => 
            [istmutter] => 
            [isttochter] => 
            [trainer] => 
            [email] => 
            [internet] => 
            [fax] => 
            [land] => 3
            [mutter] => 
            [telefonmutter] => 
            [kdnr] => 11
            [anfahrt] => 
            [beschreibung] => 
        )
)

when i change the order of the select , it will work

 $qb->select('k.id, k.aktiv, k.firma, k.strasse, k.plz, k.ort, k.plzpostfach, k.postfach, k.hotel, k.kuerzel, k.stornofrist,  k.firma2,
         k.uuid, k.telefon,k.telefonzentrale, k.istmutter, k.isttochter, k.trainer, k.email, k.internet, k.fax, l.id as land, m.id as mutter, m.firma as mutterv,
         m.telefon as telefonmutter, k.id as kdnr, k.anfahrt, k.beschreibung')


 Comments   
Comment by Marco Pivetta [ 21/Mar/14 ]

Marc Lindemann can you reduce the example to only the fields that are affected? Does this affect also latest ORM?

Comment by Marc Lindemann [ 21/Mar/14 ]

Marco, the Problem only exists when you select like my example

c0_.id AS id0, c0_.aktiv AS aktiv1, c0_.firma AS firma2, (...),  c0_.firma2 AS firma23, 

as you see "firma2" is on the fourth place so it´s selected as "firma23", "m.firma" is on place 24, so it´s also selected as "firma23" (m.firma as mutterv)

Comment by Marco Pivetta [ 21/Mar/14 ]

Marc Lindemann ah, I see it now. This probably requires a change in how the DQL is generated by prefixing numerical indexes with something like an `_`.

Comment by Marco Pivetta [ 21/Mar/14 ]

Marc Lindemann I provided a fix at https://github.com/doctrine/doctrine2/pull/985 - can you try it?

Comment by Marc Lindemann [ 24/Mar/14 ]

Yeah, this works.

Comment by Doctrine Bot [ 04/Apr/14 ]

A related Github Pull-Request [GH-985] was closed:
https://github.com/doctrine/doctrine2/pull/985

Comment by Marco Pivetta [ 04/Apr/14 ]

Merged: https://github.com/doctrine/doctrine2/commit/bfb66f1d85509db9e24ce33e30382c8cccaf2dd7





[DDC-3017] UnitOfWork::$entityIdentifiers does not get updated when saving composite PK with a JoinColum as PK Created: 08/Mar/14  Updated: 31/Mar/14  Resolved: 23/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Thomas Rabaix Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None


 Description   

The Sonata Admin Bundle rely on the ``UnitOfWork::getEntityIdentifier`` method to retrieve the object identifier.

We are adding support for composite PK with a FK as described in the gist: https://gist.github.com/rande/9439778 .

The bug occurs when the Material reference is updated on the Color object. The Color has a new set of PK. However the UnitOfWork::$entityIdentifiers is not updated when the object is persisted. So the values stored ``UnitOfWork::$entityIdentifiers`` are invalid for the Color object.

The consequence is that we are unable to redirect the user once the object is saved as the UnitOfWork::getEntityIdentifier refers to the old values.



 Comments   
Comment by Marco Pivetta [ 12/Mar/14 ]

Thomas Rabaix can you please come up with a failing test case for this issue?

Comment by Benjamin Eberlei [ 23/Mar/14 ]

It is not supported to change the identifier. They are assumed to be immutable by Doctrine and we cannot change that, as the consequences are impossible to handle.

Comment by Thomas Rabaix [ 31/Mar/14 ]

Thanks for commenting this issue. So with composite keys the assumption is wrong and from your comment this bug is the expected behavior.

Now, should doctrine provide a secure method to retrieve the identifier keys ?

Comment by Marco Pivetta [ 31/Mar/14 ]

Thomas Rabaix shouldn't you extract identifiers via metadata by having an instance of an entity?

Comment by Thomas Rabaix [ 31/Mar/14 ]

It is what I did: https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/master/Model/ModelManager.php#L277-L303

However it will be better to have a clean implementation in the ORM.





[DDC-2931] OneToOne self-referencing fails when loading referenced objects Created: 23/Jan/14  Updated: 08/Feb/14  Resolved: 08/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.1
Fix Version/s: 2.5, 2.4.2
Security Level: All

Type: Bug Priority: Critical
Reporter: Deyine Jiddou Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: orm
Environment:

Zend framework 2 + doctrine ORM module


Issue Links:
Dependency
depends on DDC-2932 [GH-916] [DDC-2931] testcase to repro... Resolved
Reference
is referenced by DDC-2933 [GH-917] DDC-2931 Resolved

 Description   

It's a regression b'cause it's work correctly in 2.3.4.



 Comments   
Comment by Marco Pivetta [ 23/Jan/14 ]

Deyine Jiddou any example?

Comment by Deyine Jiddou [ 23/Jan/14 ]

Sorry for duplication. I've create a pull request test case to reproduce this bug.

The test case work correctly on doctrine 2.3.4.
I hope it enough as a description.





[DDC-2923] Query expressions ALL/ANY/SOME don't seem to work Created: 17/Jan/14  Updated: 09/Feb/14  Resolved: 09/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Kees Schepers Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql, orm, querybuilder
Environment:

Doctrine 2.3 from a Symfony 2.4 application running on a Ubuntu 12.04 machine onder Apache / PHP.



 Description   

It seems that the query expressions ALL() / ANY() / SOME() don't work (anymore). See my testcase and the error on my stackoverflow question:

http://stackoverflow.com/questions/21184374/doctrine-any-all-some-doesnt-work

The exception is thrown in the Query/Parser.php (line: 3040) since the functions are not mapped in the parser class as string functions.

What goes wrong?



 Comments   
Comment by Marco Pivetta [ 20/Jan/14 ]

Tests seem to cover this use case at https://github.com/doctrine/doctrine2/blob/a83f5df47c463cd64a2525274c97812e04a8eca5/tests/Doctrine/Tests/ORM/Query/LanguageRecognitionTest.php#L418-L426 - try using plain DQL instead of the query builder first - may be a problem with the QB

Comment by Steve Müller [ 20/Jan/14 ]

Kees Schepers You use the expression wrong. ALL/ANY/SOME expression needs another expression to compare against. Something like:

SELECT * FROM foo WHERE ALL(SELECT bar.id FROM bar WHERE bar.id > 100)

is not valid SQL.

What you want is something like:

SELECT * FROM foo WHERE foo.id > ALL(SELECT bar.id FROM bar WHERE bar.id > 100)

I hope you get what I mean, I don't know exactly what you supposed your query to do but I hope you get the point. This is not a Doctrine bug.

See here for an example with the query builder: https://github.com/doctrine/doctrine2/blob/a83f5df47c463cd64a2525274c97812e04a8eca5/tests/Doctrine/Tests/ORM/QueryBuilderTest.php#L716-L729

Comment by Benjamin Eberlei [ 09/Feb/14 ]

Not an issue, the `andWhere($expr->all())` usage is wrong.





[DDC-2906] Atomic operations with nontransactional engines (MyISAM) Created: 11/Jan/14  Updated: 12/Jan/14  Resolved: 12/Jan/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Jacek Hensoldt Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: atomic, nontransactional, operations, orm,, transactions
Environment:

debian 6.0.3, php5.3.3, Mysql 5.1.49-3



 Description   

Atomic operations with nontransactional engines (MyISAM)

(INFO: this text is a supplement/clarification to http://www.doctrine-project.org/jira/browse/DDC-2905)

I know, MyISAM tables are nontransactional. That does not mean, that atomic operations are not possible.

(http://dev.mysql.com/doc/refman/5.0/en/ansi-diff-transactions.html)

The question is how does the ORM system deal with the problem. I think its a database abstraction layer too. That means the ORM can see that the engine MyISAM is nontransactional and it chooses a different strategy to solve this task.

It makes no sense to send commands how „"SET TRANSACTION" to a nontransactional MyISAM engine (it will not work) and Doctrine ORM do that.

(for more details see my example for this behavior:
http://www.doctrine-project.org/jira/browse/DDC-2905)

An example:

(the user- and address-tables are both MyISAM-Tables)

$user = new User();
$user->setName('Mr. Test');

// OK 
$address1 = new Address();
$address1->setCity('Hamburg');
$address1->setZipcode('12345');

// entity can not be saved because zipcode is NULL
$address2 = new Address();
$address2->setCity('New York');

// OK
$address3 = new Address();
$address3->setZipcode('42000');
$address3->setCity('Solingen');

// entity can not be saved because zipcode is NULL
$address4 = new Address();
$address4->setCity('Chicago');

$user->addAddress($address1);
$user->addAddress($address2);
$user->addAddress($address3);
$user->addAddress($address4);

$em->persist($user);

try {
    $em->flush();
} catch(\Exception $e) {
    echo $e->getMessage();
}

Only the user and the first address are stored in the db, but the developer can not see that. An atomic operation is canceled (I think $em->flush() is an implicit atomic operation), we get an exception but the ORM does not go back to the original state. Now we have a system in a inconsistent state and no information about which entities are stored and which are not. Is this an expected behavior of a ORM system or database abstraction layer? I hope not.

I would now to check all entities if they are stored. In this simple example that is no problem, but for large object-graphs is this a big problem.

(sorry for my english - I try my best



 Comments   
Comment by Steve Müller [ 11/Jan/14 ]

Jacek Hensoldt The problem here is that MySQL differs from other vendors concerning support of transactions. Transactions are supported on a table engine level in MySQL, other vendors do not have different table engines. This is a MySQL specific implementation and therefore we will not add an additional abstraction layer for this. Doctrine abstracts features like transactions and foreign keys on the platform level, not based on specific table options. This does not even make sense, as it is completely non-standard and therefore does not fit into the abstraction layer.
I see the problem you have but I am afraid we cannot support this scenario in Doctrine and I would advise you to stick to InnoDB table engine when working with Doctrine in production. Otherwise it cannot be guaranteed that transactions and foreign key constraints work as expected.

Comment by Jacek Hensoldt [ 11/Jan/14 ]

Hello Steve,

thank you for your answer.

I'm a little disappointed. Our company would like to change to Doctrine ORM. We have a Database with over more than 100 MyIsam-Tables. We can not currently change all tables to InnoDB so we can not use Doctrine ORM.

I think:

  • Doctrine ORM supports official MyISAM tables (options= {"engine"="MyISAM"}
  • The command flush() is an atomic operation (UnitOfWork),
  • There is only one flush-command for all engines and vendors, so you go normally from the same behavior
  • There is absolutely no notice that the command may behave differently (be carryful when you use it with...)

That means for MySQL-MyISAM ist the abtraction layer broken.

I think it's a bad practice when a system suggests a functionality which can not meet it. Then it is mayby better the support for MyISAM completly to remove (all or nothing - the same behavior for every vendor and every table-engine).

I do not understand why Doctrine ORM can not check if all requirements are ok and why it is a problem to implement a transaction strategy for nontransactional engines. I think it is not difficult to implement.

it would be nice if Doctrine-Team could think about this problem again

Comment by Benjamin Eberlei [ 12/Jan/14 ]

There is indeed a documentation notice missing on this issue and I am sorry that you have assumed this works. But the options=

{"engine": "MyISAM"}

is not documented as well, as well is there no official statement that this is supported.

The link you provided about Ansi Transactions does not show how easy it is with MyISAM. They say you can LOCK TABLES and then write your SQL in specific ways to get it work for examples operating on one table.

You can achieve the same with Doctrine by calling the flush operation passing only one entity at a time. This will only change this one entity (and execute scheduled inserts+deletes, so its not perfect).

Supporting transactions like InnoDB and other vendors have them in code is impossible.

Comment by Benjamin Eberlei [ 12/Jan/14 ]

I added MyISAM as known limitation to the documentation:

https://github.com/doctrine/doctrine2/commit/12556e2dfeea293c65fb24000622b6327dd27e17





[DDC-2905] MySQL MyISAM Engine / Transaction rollback does not work Created: 11/Jan/14  Updated: 11/Jan/14  Resolved: 11/Jan/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.4.1
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Jacek Hensoldt Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: orm
Environment:

debian 6.0.3, MySQL 5.1.49, PHP 5.3.3-7+squeeze3 with Suhosin-Patch (cli)



 Description   

I have two simple entities ( user 1:n address)

<?
/**
 * @Entity @Table(name="users", options={"engine"="MyISAM"})
 **/
class User {
    /** @Id @Column(type="integer") @GeneratedValue **/
    protected $id;
    /** @Column(type="string") **/
    protected $name;

    /**
     * @OneToMany(targetEntity="Address", mappedBy="user", cascade={"persist"})
     * @var Address[]
     **/
    protected $addresses = null;

    public function __construct()
    {
        $this->addresses = new ArrayCollection();
    }

    public function getId() {
        return $this->id;
    }

    public function setName($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }

    public function addAddress(Address $address) {
        $this->addresses[] = $address;
        $address->setUser($this);
    }
}

 * @Entity @Table(name="addresses", options={"engine"="MyISAM"})
 **/
class Address {
    /** @Id @Column(type="integer") @GeneratedValue **/
    protected $id;
    /** @Column(type="string") **/
    protected $zipcode;
    /** @Column(type="string") **/
    protected $city;

    /**
     * @ManyToOne(targetEntity="User", inversedBy="addresses")
     * @var User;
     **/
    protected $user = null;

    /**
     * @return mixed
     */
    public function getId() {
        return $this->id;
    }
    /**
     * @return mixed
     */
    public function getCity() {
        return $this->city;
    }

    /**
     * @param mixed $zipcode
     */
    public function setZipcode($zipcode) {
        $this->zipcode = $zipcode;
    }

    /**
     * @return mixed
     */
    public function getZipcode() {
        return $this->zipcode;
    }

    public function setUser(User $user) {
        //$user->addAddress($this);
        $this->user = $user;
    }

    public function getUser() {
        return $this->user;
    }

}

?>

When i do this, then i get an exception:

$user = new User();
$user->setName('Mr. Test');

$address = new Address();
$address->setCity('New York');

$user->addAddress($address);

$entityManager->persist($user);
$entityManager->flush();


// Exception:Integrity constraint violation: 1048 Column 'zipcode' cannot be null'

That's okay, but the address-entity needs a zipcode.

The output from sqlLogger looks like this:

"START TRANSACTION" INSERT INTO users (name) VALUES (?)
array
  1 => string 'Mr. Test' (length=5)
array
  1 => string 'string' (length=6)
INSERT INTO addresses (zipcode, city, street, user_id) VALUES (?, ?, ?, ?)
array
  1 => null
  2 => string 'New York' (length=8)
  3 => null
  4 => int 1
array
  1 => string 'string' (length=6)
  2 => string 'string' (length=6)
  3 => string 'string' (length=6)
  4 => string 'integer' (length=7)
"ROLLBACK"

 

That Problem is, that the transaction is broken and the rollback operation does not work. I get a new user without a address:

mysql> select * from users;
+----+----------+
| id | name     |
+----+----------+
|  1 | Mr. Test |
+----+----------+

mysql> select * from addresses;
Empty set (0.00 sec)

 



 Comments   
Comment by Benjamin Eberlei [ 11/Jan/14 ]

This is not an issue with Doctrine, MyISAM does not support rollbacks. Use InnoDB instead.





[DDC-2886] Entity of Base class in STI can't be persisted because of discriminator column isn't nullable Created: 05/Jan/14  Updated: 05/Jan/14  Resolved: 05/Jan/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Brazhnyk Yuriy Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

When using single table inheritance, discriminator field doesn't created as nullable... so when you persist Base class.. it has null value and you get MySQL violation



 Comments   
Comment by Brazhnyk Yuriy [ 05/Jan/14 ]

Some code for this issue
https://gist.github.com/USvER/d1699c75ec687b4587da

Comment by Brazhnyk Yuriy [ 05/Jan/14 ]

As was pointed out by Bittarman on IRC, base class was not included in DiscriminatorMap...
Closing as not an issue

Comment by Brazhnyk Yuriy [ 05/Jan/14 ]

Not an issue





[DDC-2863] multiple oneToMany entity relations not working, unless specified under one sigle oneToMany entry Created: 18/Dec/13  Updated: 09/Feb/14  Resolved: 09/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Nopcea Francisc Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

this does not work:

oneToOne:
  user:
    targetEntity: Project\Entity\User
    mappedBy: settings
oneToOne:
  language:
    targetEntity: Project\Entity\Language
    joinColumn:
      name: language_id
      referencedColumnName: id

and this works:

 
oneToOne:
  user:
    targetEntity: Project\Entity\User
    mappedBy: settings
  language:
    targetEntity: Project\Entity\Language
    joinColumn:
      name: language_id
      referencedColumnName: id

while the latter is nicer, I don't see why the first one should not work.
Also, this situation should have been prevented in the documentation.



 Comments   
Comment by Benjamin Eberlei [ 09/Feb/14 ]

This is nothing we can prevent or document better. This is just the YAML format and it works like PHP arrays, duplicate key specification removes the previously set data.





[DDC-2801] [GH-851] Documentation about how to use INSTANCE OF in inheritance Created: 19/Nov/13  Updated: 19/Nov/13  Resolved: 19/Nov/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 2.5
Security Level: All

Type: Documentation Priority: Critical
Reporter: Doctrine Bot Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

This issue is created automatically through a Github pull request on behalf of naitsirch:

Url: https://github.com/doctrine/doctrine2/pull/851

Message:

Added documentation about how to use INSTANCE OF in inheritance.
This info has been found on https://groups.google.com/forum/#!topic/doctrine-user/JtCbwuN-37o



 Comments   
Comment by Doctrine Bot [ 19/Nov/13 ]

A related Github Pull-Request [GH-851] was closed:
https://github.com/doctrine/doctrine2/pull/851

Comment by Fabio B. Silva [ 19/Nov/13 ]

Merged : https://github.com/doctrine/doctrine2/commit/0fe6d752113e67053cf030a7347b1fe54b0ab158





[DDC-2768] Doctrine could not work with date as primary key Created: 30/Oct/13  Updated: 13/Jan/14  Resolved: 14/Dec/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Nikita Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None

Issue Links:
Duplicate
is duplicated by DDC-2912 Date column could not be PK Resolved

 Description   

Part of my mapping:

 
id:
    statDate:
        type: date
    phrase:
        type: string
    bannerId:
        type: integer

So I've got an exception:

Object of class DateTime could not be converted to string in /Users/hell0w0rd/dev/rsol/direct/vendor/doctrine/orm/lib/Doctrine/ORM/UnitOfWork.php line 13
45



 Comments   
Comment by Marco Pivetta [ 14/Dec/13 ]

DateTime instances must implement `__toString` in order to be used as identifiers. That is a known limitation.

See http://stackoverflow.com/questions/15080573/doctrine-2-orm-datetime-field-in-identifier/15085566#comment21225419_15085566





[DDC-2647] SSL Off Created: 03/Sep/13  Updated: 18/Dec/13  Resolved: 13/Dec/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Critical
Reporter: Eder Campelo Assignee: Benjamin Eberlei
Resolution: Duplicate Votes: 0
Labels: None


 Description   

Hello all,

How can i connect using SSL whit PostgreSQL?

When i try, a have this error:
SQLSTATE[08006] [7] FATAL: no pg_hba.conf entry for host "...", user "...", database "...", SSL off

Gtraz



 Comments   
Comment by Benjamin Eberlei [ 08/Sep/13 ]

This is not yet possible, the Doctrine\DBAL\Driver\PDOPgSQL\Driver is missing this functionality. You can add a Pull Request to DBAL so that we can add it.

Comment by Benjamin Eberlei [ 13/Dec/13 ]

Duplicate of DBAL-702

Comment by Doctrine Bot [ 18/Dec/13 ]

A related Github Pull-Request [GH-446] was closed:
https://github.com/doctrine/dbal/pull/446





[DDC-2624] ManyToManyPersister fails to handle cloned PeristentCollections Created: 20/Aug/13  Updated: 09/Feb/14  Resolved: 09/Feb/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.5, 2.4.3
Security Level: All

Type: Bug Priority: Critical
Reporter: Martin Prebio Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

I want to clone an entity and persist the clone. The entity itself works (if I reset the identifiers to null) but a M2M collection was first ignored since I only did a shallow copy. When I do a deep copy with the following, Doctrine throws the following exception:

public function __clone()
{
if ($this->question_versions instanceof PersistentCollection)

{ $this->question_versions = clone $this->question_versions; }

}

Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'The class 'Doctrine\ORM\Persisters\ManyToManyPersister' was not found in the chain configured namespaces Foo\Entity' in /var/www/foo/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/MappingException.php on line 37

I've traced the error to the ManyToManyPersister class at the methods get

{Delete,Insert}

RowSQL where $coll->getOwner() is called which returns null because the owner is cleared when the collection is cloned. Therefore get_class does not work as expected under this circumstances.

I've also tried to use $coll->getTypeClass() for $class at that point but this leads to other warnings ("array key not existing" and "spl_object hash got null") and finally an SQL exception because Doctrine is inserting null as one of the identifiers.

There is a workaround for this issue but I think that this edge case should be handled too. The workaround is not to clone the collection itself but only copy the values with getValues() and let Doctrine convert it back to a collection.



 Comments   
Comment by Martin Prebio [ 20/Aug/13 ]

This issue may be related to DDC-2074

Comment by Marcin Iwański [ 18/Nov/13 ]

I have the same problem on v2.4.1 after cloning collections in __clone() method of the entity, so seems that DDC-2074 didnt` fix this case. But collection cloning is needed to properly manage cloned entity relationships.

Comment by Martin Prebio [ 18/Nov/13 ]

The getValues() workaround created some issues for us but I found another workaround. This one works for us for some time in a small to medium sized project where we heavily clone, detach and so on:

__clone() {
if ($this->m2mcoll instanceof PersistentCollection)

{ $this->m2mcoll = clone $this->m2mcoll; $this->m2mcoll->setOwner($this, $this->m2mcoll->getMapping()); }

}

The problem here is that this can not be put into the collection's clone method since it requires the entity object (which is $this).

Comment by Marcin Iwański [ 18/Nov/13 ]

Thanks Martin for your help, your workaround seems to work well in my case. I don`t know yet if it has any drawbacks that may occur in longer time period. My general thought after dealing with entity cloning is that official manual should pay more attention to this topic, because I had to figure out most of the issues by myself.

Comment by Martin Prebio [ 18/Nov/13 ]

Yes, I've made the same experience regarding the documentation but still I haven't found time to contribute to it.
Nevertheless if you run in any problems with my new workaround, please let me know of it. (I already spent some hours in the Doctrine code for some other issues)

Comment by Benjamin Eberlei [ 09/Feb/14 ]

Fixed in https://github.com/doctrine/doctrine2/commit/53a5a48aed7d87aa1533c0bcbd72e41b686527d8





[DDC-2572] ResolveTargetEntityListener does not work as documented. Created: 26/Jul/13  Updated: 08/Sep/13  Resolved: 08/Aug/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Documentation, ORM, Tools
Affects Version/s: 2.3.4
Fix Version/s: 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: Scott Gibson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: orm
Environment:

Debian x64



 Description   

Your documentation on RTEL shows this example:
https://doctrine-orm.readthedocs.org/en/latest/cookbook/resolve-target-entity-listener.html

$evm = new \Doctrine\Common\EventManager;

$rtel = new \Doctrine\ORM\Tools\ResolveTargetEntityListener;
$rtel->addResolveTargetEntity('Acme\\InvoiceModule\\Model\\InvoiceSubjectInterface', 'Acme\\CustomerModule\\Entity\\Customer', array());

// Add the ResolveTargetEntityListener
$evm->addEventSubscriber($rtel);

$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config, $evm);

However, ResolveTargetEntityListener does not implement EventSubscriber, so it fails.



 Comments   
Comment by Fabio B. Silva [ 08/Aug/13 ]

Fixed by : https://github.com/doctrine/doctrine2/commit/0a42401a43dfe1e5c24018bb0fb65deab338d4b5





[DDC-2563] orm:schema-tool:update generates ALTER TABLE tablename without backquoting tablename with Created: 22/Jul/13  Updated: 22/Jul/13  Resolved: 22/Jul/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.3.4
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Pavel Smirnov Assignee: Marco Pivetta
Resolution: Invalid Votes: 0
Labels: None


 Description   

I have an entity "Index"
Running doctrine orm:schema-tool:update using CLI generates following

ALTER TABLE Index ADD Merchant_Id BIGINT DEFAULT NULL

Note there are no backquotes around Index, should be like this:

ALTER TABLE `Index` ADD `Merchant_Id` BIGINT DEFAULT NULL

Naturally SQL fails due to the use of mysql token word as a table name.
Manual workarounds exist, but all DDL should really use proper quotes.



 Comments   
Comment by Marco Pivetta [ 22/Jul/13 ]

The ORM comes with quoting strategies to be used when you don't use ANSI compliant identifier names. Alternatively, wrap the entity table name with mysql-style identifier delimiter ticks ("`") in your mappings





[DDC-2434] Error generating entities using annotation docblock (in php). Attribute "fetch" is not being generated by Class EntityGenerator Created: 07/May/13  Updated: 09/May/13  Resolved: 09/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.3.3
Fix Version/s: 2.3.4
Security Level: All

Type: Bug Priority: Critical
Reporter: André Antônio Lemos de Moraes Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Windows xp, Apache 2.2 and PHP 5.3.15



 Description   

In this part of the code that begins on line 1047 which is generated lines docblock but not being generated attribute fetch.

            $type = null;
            switch ($associationMapping['type']) {
                case ClassMetadataInfo::ONE_TO_ONE:
                    $type = 'OneToOne';
                    break;
                case ClassMetadataInfo::MANY_TO_ONE:
                    $type = 'ManyToOne';
                    break;
                case ClassMetadataInfo::ONE_TO_MANY:
                    $type = 'OneToMany';
                    break;
                case ClassMetadataInfo::MANY_TO_MANY:
                    $type = 'ManyToMany';
                    break;
            }
            $typeOptions = array();

            if (isset($associationMapping['targetEntity'])) {
                $typeOptions[] = 'targetEntity="' . $associationMapping['targetEntity'] . '"';
            }

            if (isset($associationMapping['inversedBy'])) {
                $typeOptions[] = 'inversedBy="' . $associationMapping['inversedBy'] . '"';
            }

            if (isset($associationMapping['mappedBy'])) {
                $typeOptions[] = 'mappedBy="' . $associationMapping['mappedBy'] . '"';
            }

            if ($associationMapping['cascade']) {
                $cascades = array();

                if ($associationMapping['isCascadePersist']) $cascades[] = '"persist"';
                if ($associationMapping['isCascadeRemove']) $cascades[] = '"remove"';
                if ($associationMapping['isCascadeDetach']) $cascades[] = '"detach"';
                if ($associationMapping['isCascadeMerge']) $cascades[] = '"merge"';
                if ($associationMapping['isCascadeRefresh']) $cascades[] = '"refresh"';

                $typeOptions[] = 'cascade={' . implode(',', $cascades) . '}';
            }

            if (isset($associationMapping['orphanRemoval']) && $associationMapping['orphanRemoval']) {
                $typeOptions[] = 'orphanRemoval=' . ($associationMapping['orphanRemoval'] ? 'true' : 'false');
            }

Below is one possible solution.

            $typesFetch = array(
                2 => 'LAZY',
                3 => 'EAGER',
                4 => 'EXTRA_LAZY'
            );

            if(isset($associationMapping['fetch'])) {
                $typeOptions[] = 'fetch="' . $typesFetch[$associationMapping['fetch']] . '"';
            }

Tanks



 Comments   
Comment by Benjamin Eberlei [ 09/May/13 ]

Highlighted code

Comment by Benjamin Eberlei [ 09/May/13 ]

Fixed and will be included in 2.3.4 release





[DDC-2432] Entity can be initialized even if not found Created: 06/May/13  Updated: 09/May/13  Resolved: 09/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3.3
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Critical
Reporter: Christoph Roensch Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None


 Description   

I have some data in loose consistency, trying to load a field from a certain entity will yield a EntityNotFoundException. Trying it again, for example if the group is reused in a set that gets iterated, will work but provide an empty/dirty Entity.

try {
  echo $item->getGroup()->getName();
} catch (\Doctrine\ORM\EntityNotFoundException $enfe) {
  // meh
}

Thats probably because the proxies internal methods set _isInitialized_ to true on the first try. Without reverting it in case of the exception...

    public function __load()
    {
        if (!$this->__isInitialized__ && $this->_entityPersister) {
            $this->__isInitialized__ = true;

            if ($this->_entityPersister->load($this->_identifier, $this) === null) {
                throw new \Doctrine\ORM\EntityNotFoundException();
            }
            unset($this->_entityPersister, $this->_identifier);
        }
    }

Is there any reason to do that?



 Comments   
Comment by Marco Pivetta [ 06/May/13 ]

That is specifically there to disallow recursive load operations that may occur - did you already try this with latest master?

Comment by Christoph Roensch [ 07/May/13 ]

I did not exactly use an "Doctrine Proxy". A colleque of me implemented his own proxies, wich instead of loading from an entity manager, load stuff from a webservice. He simply used the template that a normal proxy provided and thats where i found this case, throw exception - return initialized. Wich i found would be valid for real proxies too.

Now i tried to use http://www.doctrine-project.org/blog/doctrine-2-4-beta.html but the composer install just fails because common cant be resolved atm. So i downloaded and compiled all tarballs from github into our project. Now the proxy mechanism seems changed, with an _initializer_ closure instead. Our "Entities" in question won't work with that anymore...

I would have to construct a demo then, implementing real basic proxies with a RDBMS?

Comment by Marco Pivetta [ 07/May/13 ]

Christoph Roensch did you try setting the minimum-stability flag in composer? Give it a try again with 2.4 and ping back - proxies changed a lot since 2.3

Comment by Christoph Roensch [ 08/May/13 ]

I reproduced it with the tutorial application, please have a look at the two commits i made on https://github.com/croensch/doctrine2-orm-tutorial/tree/DDC-2432

Comment by Marco Pivetta [ 09/May/13 ]

Proposed a fix at https://github.com/doctrine/doctrine2/pull/663





[DDC-2441] Incorrect SQL Query being generated Created: 09/May/13  Updated: 07/Jun/13  Resolved: 07/Jun/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.4
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Critical
Reporter: Paul Mansell Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None
Environment:

Using Doctrine in Symfony 2.2.1 on Windows Platform



 Description   

The following DQL :

SELECT s,ba,c,mno,ss,sws,ccs,cns,cws FROM WLCoreBundle:SIM s INNER JOIN s.billingAccount ba LEFT JOIN s.connection c INNER JOIN s.status ss LEFT JOIN s.workflowStatus sws INNER JOIN c.customerStatus ccs INNER JOIN c.networkStatus cns LEFT JOIN c
.workflowStatus cws INNER JOIN s.mno mno ORDER BY c.msisdn ASC

Produces the following SQL :

SELECT * FROM (SELECT c0_.id AS id0, c0_.iccid AS iccid1, c0_.created AS created2, c0_.updated AS updated3, c0_.spreference AS spreference4, c1_.id ASid5, c1_.account_number AS account_number6, c1_.name AS name7, c1_.address1 AS address18, c1_.address2 AS address29, c1_.address3 AS address310, c1_.address4 AS address411, c1_.address5 AS address512, c1_.address6 AS address613, c1_.email_address AS email_address14, c1_.spreference AS spreference15, c2_.id AS id16, c2_.msisdn AS msisdn17, c2_.local AS local18, c2_.imsi AS imsi19, c2_.data AS data20, c2_.fax AS fax21, c2_.api AS api22, c2_.activation_date AS activation_date23, c2_.contract_end_date AS contract_end_date24, c2_.created AS created25, c2_.updated AS updated26, c2_.spreference AS spreference27, c3_.id AS id28, c3_.ident AS ident29, c3_.label AS label30, c3_.description AS description31, c4_.id AS id32, c4_.ident AS ident33, c4_.label AS label34, c4_.description AS description35, c4_.customer_label AS customer_label36, c4_.customer_description AS customer_description37, c5_.id AS id38, c5_.ident AS ident39, c5_.label AS label40, c5_.description AS description41, c6_.id AS id42, c6_.ident AS ident43, c6_.label AS label44, c6_.description AS description45, c7_.id AS id46, c7_.ident AS ident47, c7_.label AS label48, c7_.description AS description49, c7_.customer_label AS customer_label50, c7_.customer_description AS customer_description51, c8_.id AS id52, c8_.name AS name53, c8_.email_address AS email_address54, c8_.is_active AS is_active55, c8_.spreference AS spreference56, c0_.billing_account AS billing_account57, c0_.customerHierarchy AS customerHierarchy58, c0_.mno AS mno59, c0_.status AS status60, c0_.workflow_status AS workflow_status61, c1_.customer_hierarchy AS customer_hierarchy62, c1_.country AS country63, c1_.tax_rate AS tax_rate64, c1_.currency AS currency65, c1_.status AS status66, c1_.priority AS priority67, c2_.sim AS sim68, c2_.customer_status AS customer_status69, c2_.network_status AS network_status70, c2_.workflow_status AS workflow_status71, ROW_NUMBER() OVER (ORDER BY msisdn17 ASC) AS doctrine_rownum FROM core_sim c0_ WITH (NOLOCK) INNER JOIN core_billing_account c1_ ON c0_.billing_account = c1_.id LEFT JOIN core_connection c2_ ON c0_.id = c2_.sim INNER JOIN core_sim_status c3_ ON c0_.status = c3_.id LEFT JOIN core_sim_workflow_status c4_ ON c0_.workflow_status = c4_.id INNER JOIN core_connection_customer_status c5_ ON c2_.customer_status = c5_.id INNER JOIN core_connection_network_status c6_ ON c2_.network_status = c6_.id LEFT JOIN core_connection_workflow_status c7_ ON c2_.workflow_status = c7_.id INNER JOIN core_mno c8_ ON c0_.mno = c8_.id) AS doctrine_tbl WHERE doctrine_rownum BETWEEN 1 AND 10

Which returns an error :

SQLSTATE[42S22]: [Microsoft][SQL Server Native Client 11.0][SQL Server]Invalid column name 'msisdn17'.

Same query works fine in Doctrine 2.3



 Comments   
Comment by Guilherme Blanco [ 05/Jun/13 ]

Which version of SQL Server are you using?

Comment by Guilherme Blanco [ 05/Jun/13 ]

Seems to be related to DDC-2470

Comment by Paul Mansell [ 05/Jun/13 ]

Im using SQL Server 2008 ... yes does seem the same / similar error

Comment by Fabio B. Silva [ 07/Jun/13 ]

Hi Paul Mansell

Could you please test this branch DDC-2470 with this fix in your environment ?

Thanks..

Comment by Fabio B. Silva [ 07/Jun/13 ]

Merged : https://github.com/doctrine/doctrine2/commit/753d63c2d48facdecba5d84f6ed2450024de2867

Comment by Fabio B. Silva [ 07/Jun/13 ]

Paul Mansell, please let us know if the problem continues after update





[DDC-2310] Recent changes to DBAL SQL Server platform lock hinting breaks ORM SqlWalker in DQL queries with joins Created: 21/Feb/13  Updated: 01/Mar/14  Resolved: 01/Mar/14

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.3.3, 2.5
Security Level: All

Type: Bug Priority: Critical
Reporter: William Schaller Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: dbal, lockhints, orm, sqlserver, sqlsrv
Environment:

SQL Server


Issue Links:
Duplicate
duplicates DDC-2675 WITH (NOLOCK) failing when using JOIN Awaiting Feedback
Reference
is referenced by DBAL-783 [GH-508] [DDC-2310] Fix evaluation of... Resolved
is referenced by DDC-2919 LockMode::NONE evaluation inconsisten... Resolved

 Description   

The SQL Server platform throws an error when you try to run DQL with JOIN statements.

The breaking change was in the DBAL SQL Server platform – it was changed to add a ' WITH (NOLOCK)' to the appendLockHint function. Change was in this rev. The change in DBAL is not wrong, it just highlighted the bug in the ORM...

The ORM SqlWalker runs the appendLockHint function against a generated FROM / JOIN clause in the walkFromClause func here. This is actually the wrong place to append lock hints. This is generating the FROM clause like:

 FROM foo f0_ LEFT JOIN foo_bar f1_ ON f0_.id = f1_.foo_id LEFT JOIN bar b2_ ON f1_.bar_id = b2_.id WITH (NOLOCK)

When it should actually generate something like:

 FROM foo f0_ WITH (NOLOCK) LEFT JOIN foo_bar f1_ WITH (NOLOCK) ON f0_.id = f1_.foo_id LEFT JOIN bar b2_ WITH (NOLOCK) ON f1_.bar_id = b2_.id

It should append lock hints after the table alias.

I think the only reason this hasn't shown up before is that the other lock hint types haven't been applied in this way before, if at all.



 Comments   
Comment by Christophe Coevoet [ 21/Feb/13 ]

I think the line appending the lock should be moved to this place to achieve the result displayed above.

But it may cause issues with some other vendor.

Comment by William Schaller [ 21/Feb/13 ]

@Christophe I considered that too. None of the other platforms implement the appendLockHint function. None of the other platforms implement this because it is handled differently on other platforms – with transaction isolation levels and such.

Comment by Steve Müller [ 13/Jan/14 ]

I don't know why this ticket is marked as "fixed" because it's obviously NOT.
Whatever, here is the patch: https://github.com/doctrine/doctrine2/pull/910

Comment by Steve Müller [ 13/Jan/14 ]

Complementary I provided the following patch to suppress unnecessary NOLOCK hint generation in ORM: https://github.com/doctrine/dbal/pull/508

Comment by Doctrine Bot [ 14/Jan/14 ]

A related Github Pull-Request [GH-508] was closed:
https://github.com/doctrine/dbal/pull/508

Comment by Steve Müller [ 15/Jan/14 ]

This is not resolved, yet.

Comment by Doctrine Bot [ 31/Jan/14 ]

A related Github Pull-Request [GH-910] was closed:
https://github.com/doctrine/doctrine2/pull/910

Comment by Benjamin Eberlei [ 09/Feb/14 ]

Steve Müller When is it?

Comment by Steve Müller [ 09/Feb/14 ]

Benjamin Eberlei It is fixed in PR: https://github.com/doctrine/doctrine2/pull/910





[DDC-2224] convertToDatabaseValueSQL() is not honored for DQL query parameters Created: 05/Jan/13  Updated: 04/Apr/13  Resolved: 04/Apr/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master, 2.3.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Benjamin Morel Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 1
Labels: None

Attachments: File DDC2224Test.php    
Issue Links:
Duplicate
duplicates DDC-2240 Inconsistent querying for parameter t... Resolved

 Description   

Following discussion on Google Groups:
https://groups.google.com/d/msg/doctrine-dev/-/gG-VGiAGQiMJ

When using a mapping type which declares convertToDatabaseValueSQL(), this method is not invoked when passing a value as parameter to a DQL query.

For example, if I declare a mapping type MyType:

class MyType extends \Doctrine\DBAL\Types\Type
{
    public function canRequireSQLConversion()
    {
        return true;
    }

    public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
    {
        return sprintf('FUNCTION(%s)', $sqlExpr);
    }

    // ...
}

And pass a parameter with this type to a DQL query:

$query = $em->createQuery('SELECT e FROM Entity e WHERE e.field = :field');
$query->setParameter('field', $value, 'MyType');

I would expect the following SQL to be generated:

SELECT ... WHERE ... = FUNCTION(?)

But the current SQL generated is the following:

SELECT ... WHERE ... = ?


 Comments   
Comment by Matthieu Napoli [ 08/Feb/13 ]

Fix proposal: https://github.com/doctrine/doctrine2/pull/574

Comment by Matthieu Napoli [ 08/Feb/13 ]

It turns out convertToDatabaseValue() is not called as well.

For example:

class MyType extends \Doctrine\DBAL\Types\Type
{
    public function convertToDatabaseValue($value, AbstractPlatform $platform)
    {
        return serialize($value);
    }

    // ...
}

The SQL generated should not change, but the parameter should go through "convertToDatabaseValue", which is not the case.

Comment by Benjamin Morel [ 08/Feb/13 ]

Have you passed the type as the third parameter to setParameter() ?
Because this works fine for me!

Comment by Matthieu Napoli [ 08/Feb/13 ]

You are right!

But shouldn't the Type mapping be taken into account anyway? I makes sense to me at least (a column has a type, when I specify a parameter for this column, it is for this type), but maybe that was just designed that way?

Comment by Benjamin Morel [ 08/Feb/13 ]

That would make sense, but I think that because of the flexibility of DQL, it's not always obvious what type you want to use.
Say you have some complex expression like:

WHERE entity.field = SomeDQLFunction(:value, entity.otherField)

Then we can't be sure what mapping type to use here (unless we can infer it from SomeDQLFunction, but this is yet another story).
Though I do agree that would be great to have the type inferred automatically when you do a simple:

WHERE entity.field = :value

Here, there's no ambiguity, and if entity.field has a custom mapping type, then I can't see a reason why it shouldn't be applied to the parameter by default.

Comment by Matthieu Napoli [ 08/Feb/13 ]

I made a failing test case, I'll see if I can work on that.

I will open a separate ticket for this.

Edit: http://www.doctrine-project.org/jira/browse/DDC-2290





[DDC-2204] Order by With Equals is not supported Created: 17/Dec/12  Updated: 22/Dec/12  Resolved: 22/Dec/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Ilya Biryukov Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql
Environment:

SQL construct tested on postgres 9.0, mysql 5.5, and sqlite 3.


Attachments: File Language.sql    

 Description   

The sample query (I want to bring a specific item to the top of the list).
mysql> select * from Language order by name='English' desc, name asc limit 5;
------------+

id name

------------+

82 English
73 Albanian
74 Arabic
75 Armenian
76 Bengali

------------+
5 rows in set (0.00 sec)

In theory, the code below should generate the same query.
$repository->createQueryBuilder('p')
->addOrderBy("p.name='english'", 'desc')
->addOrderBy('p.name', 'asc');

In practice, an exception is thrown.
Doctrine\ORM\Query\QueryException: [Syntax Error] line 0, col 67: Error: Expected end of string, got '=' (uncaught exception) at /vendor/doctrine/orm/lib/Doctrine/ORM/Query/QueryException.php line 44

Attached, SQL dump for the table & data



 Comments   
Comment by Benjamin Eberlei [ 22/Dec/12 ]

Its supported by including the condition in the SELECT clause, aliasing it, then using it. You might need to use "AS HIDDEN name" to prevent it from appearing in the result





[DDC-2205] Negative Values in Case Then expressions Created: 18/Dec/12  Updated: 21/Dec/12  Resolved: 21/Dec/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3.1
Fix Version/s: 2.4
Security Level: All

Type: Bug Priority: Critical
Reporter: Ilya Biryukov Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: dql


 Description   

DQL Expression:

SELECT (CASE WHEN t.id = 1 THEN -1 ELSE t.id END) FROM Table t

Gives an error:
[Syntax Error] line 0, col 32: Error: Unexpected '-'

It doesn't seem to like the negative number.



 Comments   
Comment by Fabio B. Silva [ 21/Dec/12 ]

Fixed : https://github.com/doctrine/doctrine2/commit/8b5e4a9a52670992b85e7223d255b98cf77a35a3





[DDC-2162] Undefined index: joinColumns in ManyToMany association Created: 22/Nov/12  Updated: 08/Sep/13  Resolved: 08/Sep/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, Mapping Drivers
Affects Version/s: 2.3, Git Master
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Vyacheslav Slinko Assignee: Benjamin Eberlei
Resolution: Incomplete Votes: 0
Labels: None


 Description   

My classes: https://gist.github.com/4131893

When calling PageRepository::findByTags i get

Notice: Undefined index: joinColumns in vendor/doctrine/orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php line 1494



 Comments   
Comment by Vyacheslav Slinko [ 22/Nov/12 ]

Found a problem: PageRepository not configured for Page entity





[DDC-2155] problem with DQL and cache Created: 18/Nov/12  Updated: 25/Nov/12  Resolved: 25/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: gabriel sancho Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: cache, dql
Environment:

linux , php 5.4.8, mysql 5.5.28



 Description   

I have a problem when I get database records through a query DQL
and then they are changed by another application
If I repeat the query, Doctrine always return the first value, not the current value of the base

<?php

// bootstrap

$cache = new \Doctrine\Common\Cache\ArrayCache();
$config = new Doctrine\ORM\Configuration();
$config->setQueryCacheImpl($cache);
$conn = array(
				'dbname' => $database_name,
				'user' => $cnx_user,
				'password' => $cnx_pass,
				'host' => $cnx_host,
				'driver' => $cnx_type,
				'charset' => 'utf8',
				'driverOptions' => array( 1002 => "SET NAMES 'utf8'" )
				);

			$em = Doctrine\ORM\EntityManager::create($conn, $config);




while(true){
   $dql = "SELECT s from Register s WHERE s.id = 1";
   $query = $em->createQuery($dql);
// the next line is optional, produces same result
   $query->useResultCache(false);
   $res = $query->getResult();
   $orm = reset($res);
   	
   echo " regiter id :".$orm->getId()."  field "$orm->getText()."\n";

}

I run this code in a terminal, and then edit the registry (field text), but the terminal still shows the same result



 Comments   
Comment by Benjamin Eberlei [ 25/Nov/12 ]

Doctrine uses an IdentityMap pattern which leads to this issue.

You need to call "EntityManager#clear()" to clean the in memory cache of Doctrine and fetch records from the database again. or call "EntityManager#refresh($entity)"





[DDC-2157] @HasLifecycleCallbacks does not fire events when set on @MappedSuperclass Created: 20/Nov/12  Updated: 27/Nov/12  Resolved: 27/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Frederic Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: HasLifecycleCallbacks, MappedSuperclass
Environment:

Windows 7 x64 / Apache 2.4.2 / MySQL server 5.1.62


Attachments: File DDC2157Test.php    

 Description   

I am unable to fire any of the "HasLifecycleCallbacks" when defined on a MappedSuperclass... (neither PreUpdate, PostUpdate,PrePersist, PostPersist and others)

I have even tried to put @ORM\HasLifecycleCallbacks on the child class with onPostRemove() on mapped => not working anymore

It only works when i put @ORM\HasLifecycleCallbacks and onPostRemove() both in child class "MyMappedTask"...

Is this a bug ..?

To reproduce :

<?php
namespace MyProject\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\MappedSuperclass
 * @ORM\HasLifecycleCallbacks
 */
class MyMappedTask
{
   /**
    * @ORM\PreRemove
    * @ORM\PostRemove
    * @ORM\PreUpdate
    * @ORM\PostUpdate
     */
    public function onPostRemove()
    {
        echo "here is never reached !";
    }
}

/**
 * @ORM\Entity(repositoryClass="MyProject\Repository\MyTaskRepository")
 * @ORM\Table()
 */
class MyTask extends MyMappedTask
{

}


 Comments   
Comment by Fabio B. Silva [ 22/Nov/12 ]

code format

Comment by Fabio B. Silva [ 22/Nov/12 ]

Hi Frederic,

It failed for all events or just for @PostRemove ?

Could you try to add a failing test case ?

Cheers

Comment by Frederic [ 23/Nov/12 ]

Hi Fabio,

1) Thank you for the "code" tag, i didn't know to do

2) Is fails with all the Annotations "Pre/Post*" ...

Did you try this test case ?

Thank you

Comment by Fabio B. Silva [ 23/Nov/12 ]

Hi Frederic,

Can't reproduce..
Could you try to change the attached test case and make it fails ?

Cheers

Comment by Frederic [ 27/Nov/12 ]

Hi Fabio,

Thank you for the test case, it is OK !

I found what the problem was :
I use Symfony2 and i have one bundle with the @MappedSuperclass entity and its callbacks (@HasLifecycleCallbacks), and another bundle with the child class (@Entity/@Table).
In that case, you must register the 2 bundles on the mappings (config.yml) otherwise it fails.
(I only registered the bundle which contains the child class but was not enough for Doctrine to understand...)

I don't know if it is a bug on Symfony2, not well documented in this case...

Thank you for all





[DDC-2143] $em->refresh($entity) doesn't refresh associations cleared with clear() Created: 14/Nov/12  Updated: 01/May/13  Resolved: 01/May/13

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Alex Assignee: Benjamin Eberlei
Resolution: Cannot Reproduce Votes: 0
Labels: None
Environment:

PHP 5.3 + APC, CentOS


Attachments: File DDC2143Test.php    
Issue Links:
Duplicate
is duplicated by DDC-1987 Cascading "refresh" does not work on ... Resolved

 Description   

  // $entity->items is m2m association

  /////////////////////
  // 1. Bug

  echo $entity->items->count(); // 2

  $entity->items->clear();

  echo $entity->items->count(); // 0

  $em->refresh($entity);

  echo $entity->items->count(); // 0 <-- ???

  //////////////////
  // 2. Workaround

  echo $entity->items->count(); // 2

  // remove items one by one

  $items = $entity->items->toArray();
  foreach ( $items as $item )
  {
    $entity->items->removeElement($item);
  }

  echo $entity->items->count(); // 0

  $em->refresh($entity);

  echo $entity->items->count(); // 2, as expected



 Comments   
Comment by Marco Pivetta [ 23/Jan/13 ]

This is because `clear` on an un-initialized collection doesn't initialize it. Can you confirm this by adding a call to

$this->initialize()

in the `clear` method of `Doctrine\ORM\PersistentCollection`?

Comment by Marco Pivetta [ 23/Jan/13 ]

Related to DDC-1987

Comment by Marco Pivetta [ 21/Feb/13 ]

Alex ping?

Comment by Benjamin Eberlei [ 31/Mar/13 ]

I cannot reproduce this issue, see the testscript attached (put into tests/Doctrine/Tests/ORM/Functional/Ticket/). Can you try to make this code fail?

Comment by Benjamin Eberlei [ 01/May/13 ]

Closed, no feedback.





[DDC-2079] Error in build entities using yml with several inversedJoinColumns Created: 15/Oct/12  Updated: 09/Nov/12  Resolved: 21/Oct/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.3
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Critical
Reporter: André Antônio Lemos de Moraes Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None
Environment:

windows 7/php 5.3/apache 2.2



 Description   

Hello guys, sorry for the bad English found the error during a necessity and would like to post the solution.

Below is an example of my yml relationamento a many to many.

manyToMany:
centroCustos:
targetEntity: Album\Entity\CentroCusto
cascade: ["persist", "merge"]
inversedBy: unidades
joinTable:
name: unidade_centro_custo
joinColumns:
idunidade:
referencedColumnName: idunidade
onDelete: cascade
inverseJoinColumns:
idcentrocusto:
referencedColumnName: idcentrocusto
idpais:
referencedColumnName: idpais
idmundo:
referencedColumnName: idmundo
onDelete: cascade

Well this example is generating this code.

/**

  • @var \Doctrine\Common\Collections\ArrayCollection
    *
  • @ORM\ManyToMany(targetEntity="Album\Entity\CentroCusto", inversedBy="unidades", cascade= {"persist","merge"}

    )

  • @ORM\JoinTable(name="unidade_centro_custo",
  • joinColumns= { * @ORM\JoinColumn(name="idunidade", referencedColumnName="idunidade", onDelete="cascade") * }

    ,

  • inverseJoinColumns= { * @ORM\JoinColumn(name="idcentrocusto", referencedColumnName="idcentrocusto") * @ORM\JoinColumn(name="idpais", referencedColumnName="idpais") * @ORM\JoinColumn(name="idmundo", referencedColumnName="idmundo", onDelete="cascade") * }
  • )
    */

Notice that Doctrine 2 is not putting commas to separate JoinColumns.

So looking at the source code I found the following code and put it solved my problem.

The changes was performed in EntityGenerator.php line 1090.

$arrJoins = array();
foreach ($associationMapping['joinTable']['joinColumns'] as $joinColumn)

{ $arrJoins[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); }

$lines[] = implode(",". PHP_EOL, $arrJoins);
$lines[] = $this->spaces . ' * },';
$lines[] = $this->spaces . ' * inverseJoinColumns={';

$arrJoinsInverse = array();
foreach ($associationMapping['joinTable']['inverseJoinColumns'] as $joinColumn)

{ $arrJoinsInverse[] = $this->spaces . ' * ' . $this->generateJoinColumnAnnotation($joinColumn); }

$lines[] = implode(",". PHP_EOL, $arrJoinsInverse);
$lines[] = $this->spaces . ' * }';
$lines[] = $this->spaces . ' * )'; }

I hope you understand what I'm trying to say, for you do not know if this error occurred, but if there ocorrei is one possible solution.

Thank you.



 Comments   
Comment by Fabio B. Silva [ 21/Oct/12 ]

Fixed by : https://github.com/doctrine/doctrine2/commit/2c0feb2a46a7cf97dc2878e6214924c3ffdbce67





[DDC-2032] DQL fails for Joined Inheritance with Associations on child classes Created: 15/Sep/12  Updated: 21/Sep/12  Resolved: 21/Sep/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.3
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Philipp Dobrigkeit Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: dql
Environment:

Windows XAMPP



 Description   

I have the following object hierarchy:

Clazz A with Joined Table Inheritance
Clazz B extends A
Clazz C extends A with an association (n:1) to D
Clazz D

I am doing a DQL query 'SELECT u FROM A u'

If I just have As and Bs in the DB everything is fine. But I there is a C in there I get the following error:

Notice: Trying to get property of non-object in X:\Zend_Workspace\goalio_application\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 479

Fatal error: Call to a member function fetch() on a non-object in X:\Zend_Workspace\goalio_application\vendor\doctrine\orm\lib\Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 148

When I debug the _rsm of the Hydrator is null when trying to hydrate the row for C.

Any ideas?



 Comments   
Comment by Philipp Dobrigkeit [ 19/Sep/12 ]

Ok, it doesn't seem related to inheritance. Have the same problem now as well with a Join DQL query.

Foo (1:n) Bar
Bar (1:n) Baz

SELECT c FROM Foo c INNER JOIN c.bar cj WITH cj.id IN(1)

Gives me the same error as above when it tries to hydrate Bar

Comment by Philipp Dobrigkeit [ 21/Sep/12 ]

Ok, further investigations on my part have found the problem to be somewhere else entirely... Not sure yet if it is a bug, but the problem arises because during the hydration my application does another query, which uses the same hydrator object and thus does cleanup before the initial query is complete. That results in the _rsm being null when the original hydration continues. Will see if that can be fixed in my application.

Comment by Marco Pivetta [ 21/Sep/12 ]

Philipp Dobrigkeit this is known. You have to pass a custom hydrator to the new query if you use DQL during PostLoad events.





[DDC-2012] Inserting a new entity with a custom mapping type does not call convertToDatabaseValueSQL() when using InheritanceType("JOINED") Created: 04/Sep/12  Updated: 17/Apr/14  Resolved: 03/Oct/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Mapping Drivers
Affects Version/s: 2.2.3
Fix Version/s: 2.3.1
Security Level: All

Type: Bug Priority: Critical
Reporter: Kaspars Sproģis Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None
Environment:

PHP


Attachments: Text File DDC2012Test.php     File DDC2012Test.php    

 Description   

When using class type inheritance - @InheritanceType("JOINED") and inserting new entity with a custom mapping type, custom type method convertToDatabaseValueSQL() is never called.

Here is sample class mapping:

Unable to find source-code formatter for language: php. Available languages are: actionscript, html, java, javascript, none, sql, xhtml, xml
 
/**
 * @Table(name="item")
 * @Entity
 * @InheritanceType("JOINED")
 * @DiscriminatorColumn(name="type_id", type="smallint")
 * @DiscriminatorMap({1 = "ItemPerson"})
 */
class Item {

	/**
	 * @Column(name="tsv", type="tsvector", nullable=true)
	 */
	protected $tsv;
}

/**
 * @Table(name="item_person")
 * @Entity
 */
class ItemPerson extends Item
{
}

I am using the same custom TsvectorType with simple entities and even Mapped Superclasses and it works perfectly, however on InheritanceType("JOINED") method convertToDatabaseValueSQL() is never called :/
Hope someone knows how to fix this.
Thank you.



 Comments   
Comment by Fabio B. Silva [ 24/Sep/12 ]

Hi Kaspars,

I can't reproduce,
Could you change the added testcase and try to make it fails ?

Thanks

Comment by Kaspars Sproģis [ 26/Sep/12 ]

@Fabio thanks for looking into my problem
I attached test where you can detect the problem.

It was quite strange, all i did was changed column that uses custom type to array and some minimal convertToDatabaseValue and convertToDatabaseValueSQL logic and convertToDatabaseValueSQL was never called.

One more thing i noticed, this bug only appears on persist and not on merge.

Thanks

Comment by Fabio B. Silva [ 29/Sep/12 ]

Thanks Kaspars

But sorry, I dont get your use case.

Notice that convertToDatabaseValueSQL is called just when using queries to find a object by a especific columns which is your mapping type.

http://docs.doctrine-project.org/en/2.1/cookbook/advanced-field-value-conversion-using-custom-mapping-types.html#the-mapping-type

Comment by Kaspars Sproģis [ 29/Sep/12 ]

I am using PostgreSQL tsvector data type for full text search.

Here is my tsvector custom data type class:
https://gist.github.com/3129096

The only way to update this field in postgresql is to use postgresql function to_tsvector('some text').
And everything works fine, if i persist simple entity, this method transforms insert query as needed:

public function convertToDatabaseValueSQL($sqlExpr, AbstractPlatform $platform)
{
	return sprintf('to_tsvector(%s)', $sqlExpr);
}

But when i use inheritance, then by some reason convertToDatabaseValueSQL method is not called and tsv field is updated with simple text as returned by convertToDatabaseValue() method.
I modified the Ticket Test so that you can see exact moment of when it is not called, which is exactly my problem.

Here is the result after persisting (for persist it failed)

$person = new ItemPerson();
$person->setName('some words for test');
$em->persist($person);
$em->flush();

DB Result:
Name                | Tsv
--------------------|------------------------------------
some words for test | 'for' 'some' 'test' 'words'

Here is the result after second time update (now by tsv format you can see it worked):

$person->setName('some more words for test');
$em->flush();

DB Result:
Name                | Tsv
--------------------|------------------------------------
some words for test | 'test':5 'word':3
Comment by Fabio B. Silva [ 30/Sep/12 ]

Thanks Kaspars

Now i saw the problem

Writing a patch ...

Comment by Kaspars Sproģis [ 03/Oct/12 ]

Just tested fixed version and everything works perfectly now.
Thank you!

Comment by Fabio B. Silva [ 03/Oct/12 ]

Fixed by : https://github.com/doctrine/doctrine2/commit/91caff1d8965c20b72d5fdd04ffadf3ab063c1ba





[DDC-2001] Problem nextval sequence persist many object Created: 29/Aug/12  Updated: 06/Oct/12  Resolved: 06/Oct/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Sandro Cândido de Oliveira Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Attachments: GZip Archive bugcodeigniterdoctrine.tar.gz    

 Description   

Seems to be a bug doctrine.

Scenario: You cart table and Product table when trying to persist the products do not set the last sequence postgres. In the example cart will id = 1
products id = 1 ... 5 but the sequence of the final product value is 2 and not 5.
If I run the script again I get the following error.

PDOException: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "product_pkey" DETAIL: Key (id)=(2) already exists. in /var/www/codeigniter/scclocal/application/third_party/doctrine-orm/Doctrine/DBAL/Statement.php on line 131

Sample code:

        $cart = new cart\models\Cart;

        $cart->em->getConnection()->beginTransaction();

        $cart->setDescription('My Cart');

        try {
            //Persist Cart
            $cart->em->persist($cart);
            $cart->em->flush();
        } catch(Exception $e) {
            $cart->em->getConnection()->rollback();
            $cart->em->close();
            throw $e;
        }
        //Product
        for($i=0; $i < 5; $i++){
            $product = new cart\models\Product;
            $product->setName('Name product '.$i);
            $product->setDescription('Description product '.$i);
            $product->setCart($cart);
            $cart->getProducts()->add($product); //Add products in cart
            $product->em->persist($product); //Persist Products
        }

        try {
            $cart->em->persist($cart);
            $cart->em->flush();
            $cart->em->getConnection()->commit();
        } catch(Exception $e) {
            $cart->em->getConnection()->rollback();
            $cart->em->close();
            throw $e;
        }
        die ('success save);

EchoSQLLogger Cart:

SELECT NEXTVAL('cart_id_seq') INSERT INTO cart (id, description) VALUES (?, ?)

array
  1 => int 1
  2 => string 'My Cart' (length=7)

EchoSQLLogger Products( Note that the second interaction forward select nextval was not generated. ) :

SELECT NEXTVAL('product_id_seq') INSERT INTO product (id, name, description, cart_id) VALUES (?, ?, ?, ?)

array
  1 => int 1
  2 => string 'Name product 0' (length=14)
  3 => string 'Description product 0' (length=21)
  4 => int 1

INSERT INTO product (id, name, description, cart_id) VALUES (?, ?, ?, ?)

array
  1 => int 2
  2 => string 'Name product 1' (length=14)
  3 => string 'Description product 1' (length=21)
  4 => int 1

INSERT INTO product (id, name, description, cart_id) VALUES (?, ?, ?, ?)

array
  1 => int 3
  2 => string 'Name product 2' (length=14)
  3 => string 'Description product 2' (length=21)
  4 => int 1

INSERT INTO product (id, name, description, cart_id) VALUES (?, ?, ?, ?)

array
  1 => int 4
  2 => string 'Name product 3' (length=14)
  3 => string 'Description product 3' (length=21)
  4 => int 1

INSERT INTO product (id, name, description, cart_id) VALUES (?, ?, ?, ?)

array
  1 => int 5
  2 => string 'Name product 4' (length=14)
  3 => string 'Description product 4' (length=21)
  4 => int 1

Entity Cart:

<?php
namespace cart\models;

/**
 * @Entity
 * @Table(name="cart")
 */
use models\MY_Model,
    Doctrine\Common\Collections\ArrayCollection;


class Cart extends MY_Model {

    /**
     * @Id
     * @Column(type="integer", nullable=false)
     * @GeneratedValue(strategy="SEQUENCE")
     * @SequenceGenerator(sequenceName="cart_id_seq", initialValue=1, allocationSize=100)
     */
    private $id;

    /**
     * @Column(type="string", length=200, nullable=true)
     */
    private $description;


    /**
     * @OneToMany(targetEntity="Product", mappedBy="cart", cascade={"all"})
     */
    private $products;

    public function __construct() {
        parent::__construct();
        $this->products = new ArrayCollection();
    }

    /**
     *
     * @return
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     *
     * @param $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     *
     * @return
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     *
     * @param $descricao
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }

    /**
     *
     * @return
     */
    public function getProducts()
    {
        return $this->products;
    }

    /**
     *
     * @param $categoria
     */
    public function setProducts(Products $products)
    {
        $this->products = $products;
    }
}
?>

Entity Product:

<?php
namespace cart\models;

/**
 * @Entity
 * @Table(name="product")
 */
use models\MY_Model,
    Doctrine\Common\Collections\ArrayCollection;

class Product extends MY_Model {

    /**
     * @Id
     * @Column(type="integer", nullable=false)
     * @GeneratedValue(strategy="SEQUENCE")
     * @SequenceGenerator(sequenceName="product_id_seq", initialValue=1, allocationSize=100)
     */
    private $id;

    /**
     * @Column(type="string", length=100)
     */
    private $name;

    /**
     * @Column(type="string", length=200)
     */
    private $description;

   
    /**
     * @link http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#one-to-many-bidirectional
     *
     * @ManyToOne(targetEntity="Cart", inversedBy="product")
     * @JoinColumn(name="cart_id", referencedColumnName="id")
     */
    protected $cart;


    public function __construct(){
        parent::__construct();
    }

    /**
     *
     * @return
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     *
     * @param $id
     */
    public function setId($id)
    {
        $this->id = $id;
    }

    /**
     *
     * @return
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     *
     * @param $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     *
     * @return
     */
    public function getDescription()
    {
        return $this->description;
    }

    /**
     *
     * @param $description
     */
    public function setDescription($description)
    {
        $this->description = $description;
    }

    /**
     *
     * @return
     */
    public function getCart()
    {
        return $this->cart;
    }

    /**
     *
     * @param $cart
     */
    public function setCart(Cart $cart)
    {
        $this->cart = $cart;
    }
}
?>

Attachment application sample



 Comments   
Comment by Benjamin Eberlei [ 29/Aug/12 ]

But the SQL Log correctly shows 1,..,5 in case of the INSERT statements for products. Where is the unique id clash happening?

Comment by Sandro Cândido de Oliveira [ 29/Aug/12 ]

It happens that for each insert must have a nextval to generate the unique id. Log in to run the script the first time the insert works but if you run the script again next products are not generated 6 ... 10 of the error occurring.

PDOException: SQLSTATE[23505]: Unique violation: 7 ERROR: duplicate key value violates unique constraint "product_pkey" DETAIL: Key (id)=(2) already exists. in /var/www/codeigniter/bugcodeigniterdoctrine/application/third_party/doctrine-orm/Doctrine/DBAL/Statement.php on line 131

Comment by Sandro Cândido de Oliveira [ 30/Aug/12 ]

Benjamin you could understand the problem now?

Comment by Benjamin Eberlei [ 06/Oct/12 ]

Its not a bug with Doctrine but your code, your sequence is defined wrong:

CREATE SEQUENCE product_id_seq
    START WITH 1
    INCREMENT BY 1
    NO MINVALUE
    NO MAXVALUE
    CACHE 1;

If you increment by 100, then the sequence has to increment by 100. This is a low level db vendor feature.





[DDC-1850] Problems deleting when fields are case sensitive, and realtion many to many too Created: 31/May/12  Updated: 06/Jul/12  Resolved: 06/Jul/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: None
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Pablo Minetti Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File BasicEntityPersister.patch    

 Description   

Hi,

well we have same issues when we delete same field from a postgres data base where columns are camelcase and start with caps.

I upload in this issue a patch that solve the problem.



 Comments   
Comment by Fabio B. Silva [ 05/Jun/12 ]

Hi Pablo Minetti,

I'm working on a quote patch right now.
I think that will fix a lot of quote issues.

Could you attach a test for this case please ?

Comment by Benjamin Eberlei [ 06/Jul/12 ]

No feeback given and a fix was pushed to master. Please reopen if problems persist with master + custom quoting strategy.





[DDC-1831] Problem while implement a relation many to many with columns names starting with caps Created: 21/May/12  Updated: 06/Jul/12  Resolved: 06/Jul/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: None
Fix Version/s: 2.3

Type: Bug Priority: Critical
Reporter: Pablo Minetti Assignee: Fabio B. Silva
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File defect_patch.txt    

 Description   

Hi, In my team we are implementing a solution that involves make a relation many to many.

The problem is that the columns names of the middle table start with caps.

we make correction to ORM to solve this problem. I attach to you the files modify.



 Comments   
Comment by Fabio B. Silva [ 05/Jun/12 ]

Hi Pablo,

I'm working on a quote patch right now.
I think that will fix a lot of quote issues.

Could you attach a test for this case please ?

Comment by Benjamin Eberlei [ 05/Jul/12 ]

Fabio, any stats on this one? Is it fixed through your change?

Comment by Fabio B. Silva [ 05/Jul/12 ]

There is no answers from Pablo,

I think this is fixed by quote strategy, also DDC-1850
but without entities or tests is hard to know if are really fixed.

if we don't get any feedback from Pablo, I think both could be closed.

Comment by Benjamin Eberlei [ 06/Jul/12 ]

No feeback given and a fix was pushed to master. Please reopen if problems persist with master + custom quoting strategy.





[DDC-1799] Doctrine's Reverse Engineering 1-n (one to many) association misunderstood as 1-1 (one to one) Created: 27/Apr/12  Updated: 27/May/12  Resolved: 27/May/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.6
Fix Version/s: 2.1.7, 2.2.3
Security Level: All

Type: Bug Priority: Critical
Reporter: simone adami Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

MAC OS X 10.6.8, Symfony 2.0.12, PHP 5.3.6, mysql server 5.5.9



 Description   

I found an odd behaviour of Doctrine's reverse engineering process, just create two simple tables tied by a simple 1-n relationship, take a look at the snap of the folowing SQL code:

    SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
    SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
    SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
    
    DROP SCHEMA IF EXISTS `ACME` ;
    CREATE SCHEMA IF NOT EXISTS `ACME` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
    USE `ACME` ;
    
    -- -----------------------------------------------------
    -- Table `ACME`.`task`
    -- -----------------------------------------------------
    DROP TABLE IF EXISTS `ACME`.`task` ;
    
    CREATE  TABLE IF NOT EXISTS `ACME`.`task` (
      `id_task` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
      `description` VARCHAR(45) NULL ,
      PRIMARY KEY (`id_task`) )
    ENGINE = InnoDB;
    
    
    -- -----------------------------------------------------
    -- Table `ACME`.`tag`
    -- -----------------------------------------------------
    DROP TABLE IF EXISTS `ACME`.`tag` ;
    
    CREATE  TABLE IF NOT EXISTS `ACME`.`tag` (
      `id_tag` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
      `name` VARCHAR(50) NULL ,
      `task_id` INT UNSIGNED NOT NULL ,
      PRIMARY KEY (`id_tag`) ,
      INDEX `fk_tag_task` (`task_id` ASC) ,
      CONSTRAINT `fk_tag_task`
        FOREIGN KEY (`task_id` )
        REFERENCES `ACME`.`task` (`id_task` )
        ON DELETE NO ACTION
        ON UPDATE NO ACTION)
    ENGINE = InnoDB;
    
    
    
    SET SQL_MODE=@OLD_SQL_MODE;
    SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
    SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

I have a Symfony2 netbeans project at

> /Applications/MAMP/htdocs/Acme

and from that location, according to

> http://symfony.com/doc/current/cookbook/doctrine/reverse_engineering.html

in a terminal I did:

    $ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:convert yml ./src/Acme/TaskBundle/Resources/config/doctrine/ --from-database --force
    Processing entity "Tag"
    Processing entity "Task"
    
    Exporting "yml" mapping information to "/Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine"
    
    $ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:import Acme\TaskBundle yml
    Importing mapping information from "default" entity manager
      > writing /Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine/Tag.orm.yml
      > writing /Applications/MAMP/htdocs/Acme/src/Acme/TaskBundle/Resources/config/doctrine/Task.orm.yml
    
    $ ./../../bin/php/php5.3.6/bin/php app/console doctrine:generate:entities Acme\TaskBundle
    Generating entities for bundle "AcmeTaskBundle"
      > backing up Tag.php to Tag.php~
      > generating Acme\TaskBundle\Entity\Tag
      > backing up Task.php to Task.php~
      > generating Acme\TaskBundle\Entity\Task

The fact is that it only seems ok, because if you take a look at "Tag.orm.yml":

Tag.orm.yml
    Acme\TaskBundle\Entity\Tag:
      type: entity
      table: tag
      fields:
        idTag:
          id: true
          type: integer
          unsigned: false
          nullable: false
          column: id_tag
          generator:
            strategy: IDENTITY
        name:
          type: string
          length: 50
          fixed: false
          nullable: true
      oneToOne:
        task:
          targetEntity: Task
          cascade: {  }
          mappedBy: null
          inversedBy: null
          joinColumns:
            task_id:
              referencedColumnName: id_task
          orphanRemoval: false
      lifecycleCallbacks: {  }

It created a *oneToOne* relationship and not a *oneToMany* !

If you need any more confirmation, here are **Task.php** and **Tag.php**:

**Task.php**

Task.php
    <?php
    
    namespace Acme\TaskBundle\Entity;
    
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * Acme\TaskBundle\Entity\Task
     */
    class Task
    {
        /**
         * @var integer $idTask
         */
        private $idTask;
    
        /**
         * @var string $description
         */
        private $description;
    
    
        /**
         * Get idTask
         *
         * @return integer 
         */
        public function getIdTask()
        {
            return $this->idTask;
        }
    
        /**
         * Set description
         *
         * @param string $description
         */
        public function setDescription($description)
        {
            $this->description = $description;
        }
    
        /**
         * Get description
         *
         * @return string 
         */
        public function getDescription()
        {
            return $this->description;
        }
    }
Tag.php
***Tag.php***

    <?php
    
    namespace Acme\TaskBundle\Entity;
    
    use Doctrine\ORM\Mapping as ORM;
    
    /**
     * Acme\TaskBundle\Entity\Tag
     */
    class Tag
    {
        /**
         * @var integer $idTag
         */
        private $idTag;
    
        /**
         * @var string $name
         */
        private $name;
    
        /**
         * @var Acme\TaskBundle\Entity\Task
         */
        private $task;
    
    
        /**
         * Get idTag
         *
         * @return integer 
         */
        public function getIdTag()
        {
            return $this->idTag;
        }
    
        /**
         * Set name
         *
         * @param string $name
         */
        public function setName($name)
        {
            $this->name = $name;
        }
    
        /**
         * Get name
         *
         * @return string 
         */
        public function getName()
        {
            return $this->name;
        }
    
        /**
         * Set task
         *
         * @param Acme\TaskBundle\Entity\Task $task
         */
        public function setTask(\Acme\TaskBundle\Entity\Task $task)
        {
            $this->task = $task;
        }
    
        /**
         * Get task
         *
         * @return Acme\TaskBundle\Entity\Task 
         */
        public function getTask()
        {
            return $this->task;
        }
    }

linuxatico



 Comments   
Comment by simone adami [ 30/Apr/12 ]

This problem is encountered only in this case, 1-1 and n-m relationship are handled in the right way, has anyone else faced this problem too?

linuxatico

Comment by simone adami [ 07/May/12 ]

Hi all,
I wanna give the Doctrine community my full support to help fixing this bug, but I need someone who can give me an answer.....
I couldn't figure out in the source code which is the method executed when given the command

$ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:convert yml ./src/Acme/TaskBundle/Resources/config/doctrine/ --from-database --force

I will keep on looking for it, but some help will be appreciated,

linuxatico

Comment by simone adami [ 07/May/12 ]

Found in vendor/doctrine/lib/Doctrine/ORM/Tools/Console/Command/ConvertMappingCommand.php
I'll see what I can do.

linuxatico

Comment by simone adami [ 09/May/12 ]

Even if I keep being ignored, I want to report a very useful discovery about this annoying bug: it's 100% related to the YAML conversion, because if you execute the first command

 $ ./../../bin/php/php5.3.6/bin/php app/console doctrine:mapping:convert xml ./src/Acme/TaskBundle/Resources/config/doctrine/ --from-database --force

Using XML instead of YML it works in the expected way. I wonder if the author of this code have written a unit test before integrating this function in the official release of Doctrine.... (ironic question)

linuxatico

Comment by Benjamin Eberlei [ 27/May/12 ]

This case was indeed not unit-tested, many-to-one and one-to-one were handled the same in YAML Exporter. No need to get picky about it though, we are investing our free time here.





[DDC-1802] DQL parser issue when using FunctionsReturningStrings(...) NOT LIKE Created: 30/Apr/12  Updated: 04/May/12  Resolved: 04/May/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.1.3, 2.1.4, 2.1.5, 2.1.6, 2.2-BETA1, 2.2-BETA2, 2.2.0-RC1, 2.2, 2.2.1, 2.2.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Critical
Reporter: Martin Hasoň Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

If you create a query like the following, you will get an exception:

$em->createQuery( "SELECT e FROM MyEntity e WHERE CONCAT(e.name, e.name2) NOT LIKE '%abc%'" );

The variable $token['type'] is Lexer::T_NOT - https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Query/Parser.php#L2238



 Comments   
Comment by Alexander [ 04/May/12 ]

https://github.com/doctrine/doctrine2/pull/345 got merged





[DDC-1742] Cascade remove doesn't work with inheritance Created: 30/Mar/12  Updated: 01/Apr/12  Resolved: 01/Apr/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2.1
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Justin Hendrickson Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

Ubuntu 11.10, PHP 5.3.6-13ubuntu3.6 with Suhosin-Patch (cli), MySQL


Attachments: File DDC1742Test.php    

 Description   

When removing an entity with a one-to-many relationship with a cascade delete option on it causes a "Integrity constraint violation: 1451 Cannot delete or update a parent row:" error.

<?php
/** @DiscriminatorColumn(name="type", type="string") @DiscriminatorMap({"cat" = "Cat", "dog" = "Dog"}) @Entity @InheritanceType("SINGLE_TABLE") */
class Animal
{
    /** @Column(type="integer") @GeneratedValue @Id */
    protected $id;

    /** @ManyToOne(targetEntity="Person",inversedBy="pets") */
    protected $owner;

    public function setOwner(Person $person) { $this->owner = $person; }
}

/** @Entity */
class Cat extends Animal
{
}

/** @Entity */
class Dog extends Animal
{
}

/** @Entity */
class Person
{
    /** @Column(type="integer") @GeneratedValue @Id */
    protected $id;
    /** @OneToMany(targetEntity="Animal",mappedBy="owner",cascade={"delete"}) */
    protected $pets;

    public function addPet(Animal $animal) { $animal->setOwner($this); $this->pets[] = $animal; }
}


$person1 = new Person();

$dog1 = new Dog();

$person1->addPet($dog1);

$em->persist($person1);
$em->persist($dog1);

$em->flush();

$em->remove($person1);

$em->flush();

/*
PHP Fatal error:  Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`Animal`, CONSTRAINT `FK_6D0726297E3C61F9` FOREIGN KEY (`owner_id`) REFERENCES `Person` (`id`))' in /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php:754
Stack trace:
#0 /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php(754): PDOStatement->execute(Array)
#1 /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php(438): Doctrine\DBAL\Connection->executeUpdate('DELETE FROM Per...', Array)
#2 /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/ORM/Persisters/BasicEntityPersister.php(464): Doctrine\DBAL\Connection->delete('Person', Array)
#3 /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/ORM/UnitOfWork.php(993): Doctrine\ORM\Persisters\BasicEntityPersister->delete(Object(Person))
#4 /home/jhendric/public_html/doctrine-test/pear/php/Doctrine in /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php on line 754

Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`Animal`, CONSTRAINT `FK_6D0726297E3C61F9` FOREIGN KEY (`owner_id`) REFERENCES `Person` (`id`))' in /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php on line 754

PDOException: SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`test`.`Animal`, CONSTRAINT `FK_6D0726297E3C61F9` FOREIGN KEY (`owner_id`) REFERENCES `Person` (`id`)) in /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/DBAL/Connection.php on line 754

Call Stack:
    0.0002     647440   1. {main}() /home/jhendric/public_html/doctrine-test/test.php:0
    0.0513    7989360   2. Doctrine\ORM\EntityManager->flush() /home/jhendric/public_html/doctrine-test/test.php:26
    0.0513    7989440   3. Doctrine\ORM\UnitOfWork->commit() /home/jhendric/public_html/doctrine-test/pear/php/Doctrine/ORM/EntityManager.php:355
*/


 Comments   
Comment by Justin Hendrickson [ 30/Mar/12 ]

I did some step debugging and it looked like the calculate commit order determined that the person should be removed before the animal.

Comment by Benjamin Eberlei [ 31/Mar/12 ]

It works for me.

See the testcase attached, you can put it into tests/Doctrine/Tests/ORM/Functional/Ticket, then run "phpunit --group DDC-1742" from the CLI to get the result.

Can you make it fail?

Comment by Justin Hendrickson [ 31/Mar/12 ]

I ran the provided test and could not reproduce the original error. There were some differences between the original environment and the environment I ran the tests in.

My original environment was a pear install of 2.2.1 and used the MySQL backend. The pear install does not include the unit tests, so I did a github checkout and used that source code for the tests. I initially got an error about not having pdo_sqlite installed, so I'm assuming the unit test used an sqlite(3) database for it's test. I can't imagine how either of these would effect the final result, but I wanted to note them, just in case.

Assuming neither of the previous differences is the source of the problem, I'll try to figure out how to reproduce the problem with a unit test today.

Comment by Justin Hendrickson [ 31/Mar/12 ]

Using the phpunit.xml file, I setup the unit tests to use MySQL instead of SQLite and I was able to reproduce the error:

jhendric@jhendric-Ubuntu:~/public_html/doctrine2-test/doctrine2-orm$ phpunit --group DDC-1742
PHPUnit 3.6.10 by Sebastian Bergmann.

Configuration read from /home/jhendric/public_html/doctrine2-test/doctrine2-orm/phpunit.xml

E

Time: 1 second, Memory: 72.50Mb

There was 1 error:

1) Doctrine\Tests\ORM\Functional\Ticket\DDC1742Test::testIssue
Exception: [PDOException] SQLSTATE[23000]: Integrity constraint violation: 1451 Cannot delete or update a parent row: a foreign key constraint fails (`doctrine_tests`.`DDC1742Animal`, CONSTRAINT `FK_215064B57E3C61F9` FOREIGN KEY (`owner_id`) REFERENCES `DDC1742Person` (`id`))

With queries:
6. SQL: 'INSERT INTO DDC1742Animal (owner_id, type) VALUES (?, ?)' Params: '1', 'dog'
5. SQL: 'INSERT INTO DDC1742Person (id) VALUES (null)' Params:
4. SQL: 'ALTER TABLE DDC1742Animal ADD CONSTRAINT FK_215064B57E3C61F9 FOREIGN KEY (owner_id) REFERENCES DDC1742Person (id)' Params:
3. SQL: 'CREATE TABLE DDC1742Person (id INT AUTO_INCREMENT NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB' Params:
2. SQL: 'CREATE TABLE DDC1742Animal (id INT AUTO_INCREMENT NOT NULL, owner_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, INDEX IDX_215064B57E3C61F9 (owner_id), PRIMARY KEY(id)) ENGINE = InnoDB' Params:

Trace:
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php:754
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/vendor/doctrine-dbal/lib/Doctrine/DBAL/Connection.php:438
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/Doctrine/ORM/Persisters/BasicEntityPersister.php:464
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php:993
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/Doctrine/ORM/UnitOfWork.php:331
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/lib/Doctrine/ORM/EntityManager.php:355
/home/jhendric/public_html/doctrine2-test/doctrine2-orm/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC1742Test.php:38

/home/jhendric/public_html/doctrine2-test/doctrine2-orm/tests/Doctrine/Tests/OrmFunctionalTestCase.php:401

FAILURES!
Tests: 1, Assertions: 0, Errors: 1.

Comment by Benjamin Eberlei [ 01/Apr/12 ]

Ah yes, i have the same result I ran only against sqlite and they dont have foreign keys. Sorry for that.

Comment by Benjamin Eberlei [ 01/Apr/12 ]

Its not a bug, your mapping is wrong. The option is cascade=

{"remove"}

not cascade=

{"delete"}




[DDC-1706] aggregate all writes does not work Created: 15/Mar/12  Updated: 15/Mar/12  Resolved: 15/Mar/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Jérôme Forêt Assignee: Benjamin Eberlei
Resolution: Won't Fix Votes: 0
Labels: None
Environment:

Standard edition Symfony v2.0.11



 Description   

I have 1 entity :

namespace Test\DoctrineBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
 
/**
 * Test\DoctrineBundle\Entity\User
 *
 * @ORM\Table(name="user")
 * @ORM\Entity
 */
class User
{
    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    /**
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;

...

In controller, i create 2 users, i persist and i flush

 
    public function indexAction()
    {
        $em = $this->getDoctrine()->getEntityManager();
        $repository = $em->getRepository('TestDoctrineBundle:User');
        
        $user = new User();
        $user->setName('name-'.rand(1, 1000));
        $em->persist($user);
        
        $user = new User();
        $user->setName('name-'.rand(1, 1000));
        $em->persist($user);
        
        $em->flush();
        return array();
    }

Results, i have 3 requests
[2012-03-15 08:23:53] doctrine.DEBUG: SET NAMES UTF8
[2012-03-15 08:23:53] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-683"}

)
[2012-03-15 08:23:53] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-638"}

)

I expect to have only 2 requests because i think "INSERT" lines have to be into one single transaction.

I am on dev environment, because in production, i can not know how many request i have.



 Comments   
Comment by Benjamin Eberlei [ 15/Mar/12 ]

This has nothing to do with each other. You are just showing the log output. The Begin and Commit Statements are not listed in the log, the queries are still executed consequitevly, but they are aggregated in the transaction.

Comment by Jérôme Forêt [ 15/Mar/12 ]

Thank you, Benjamin. Ok I understand what you say.
But I think it's too simple, or the tools provide incomplete information.

1st sample :

$user = new User();
$user->setName('name-1');
$em->persist($user);

$user = new User();
$user->setName('name-2');
$em->persist($user);

$em->flush();
        
$user = new User();
$user->setName('name-3');
$em->persist($user);

$em->flush();

$user = new User();
$user->setName('name-4');
$em->persist($user);

$em->flush();

The dev.log gives 4 queries ; the webprofiler bar in sf shows 4 queries.
[2012-03-15 11:50:01] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-1"}

)
[2012-03-15 11:50:01] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-2"}

)
[2012-03-15 11:50:01] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-3"}

)
[2012-03-15 11:50:01] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-4"}

)

2nd sample :

$user = new User();
$user->setName('name-1');
$em->persist($user);

$user = new User();
$user->setName('name-2');
$em->persist($user);
        
$user = new User();
$user->setName('name-3');
$em->persist($user);

$user = new User();
$user->setName('name-4');
$em->persist($user);

$em->flush();

The dev.log gives 4 queries ; the webprofiler bar in sf shows 4 queries.
[2012-03-15 11:51:31] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-1"}

)
[2012-03-15 11:51:31] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-2"}

)
[2012-03-15 11:51:31] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-3"}

)
[2012-03-15 11:51:31] doctrine.DEBUG: INSERT INTO user (name) VALUES (

{"1":"name-4"}

)

In 1st sample, there is 3 transactions.
In 2nd sample, there is 1 transaction.

Is there a possibility to know number of transactions because i think it can help developpers in order to have better performances.

Maybe it is not in doctrine, it is in Symfony webprofiler; what do you think ?

Comment by Benjamin Eberlei [ 15/Mar/12 ]

Well the Symfony debug profiler only shows the queries, not the transactions. If you need the transactions you can extend it of course, for example listening to the "onFlush" event that marks the start of a UnitOfwork transaction. Its still not a bug and we won't add it to the core Doctrine bundle.

EntityManager#flush wrapping the transaction is discussed at length in the documentation.





[DDC-1657] The Doctrine cli tool does not handle schema correctly. Created: 19/Feb/12  Updated: 08/Jul/12  Resolved: 08/Jul/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.2
Fix Version/s: 2.3
Security Level: All

Type: Bug Priority: Critical
Reporter: Presteus Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux Mint Debian Edition, PHP 5.3.10, PostgreSQL 9.1



 Description   

At first time, sorry for my english and I will be short and brief, the problem is clearly explained in the title and the test is very simple.

The entity

/**
 * Short description.
 *
 * @Entity(repositoryClass="Stonewood\Model\Entity\Repository\Screen")
 * @Table(name="stonewood.screen")
 */
class Screen extends Entity
{

    /**
     * Identifier
     * @var integer
     *
     * @Id
     * @GeneratedValue(strategy="IDENTITY")
     * @Column(name="pk", type="integer", nullable=false)
     */
    private $pk;

    /**
     * Title
     * @var string
     *
     * @Column(name="title", type="string", length=255, nullable=false)
     */
    private $title;

    /**
     * Path
     * @var string
     *
     * @Column(name="path", type="string", length=255, nullable=false)
     */
    private $path;

    /**
     * Register date
     * @var Date
     *
     * @Column(name="ddate", type="date", nullable=false)
     */
    private $ddate;

    /**
     * Avatar
     * @var Stonewood\Model\Entity\Avatar
     *
     * @ManyToOne(targetEntity="Stonewood\Model\Entity\Avatar")
     * @JoinColumn(name="pk_avatar", referencedColumnName="pk", nullable=true, onDelete="CASCADE")
     */
    private $avatar;

    /**
     *
     */
    public function __construct($pk = null, $title = null, $path = null, $ddate = null, $avatar = null) {
        $this->setPk($pk);
        $this->setTitle($title);
        $this->setPath($path);
        $this->setDdate($ddate);
        $this->setAvatar($avatar);
    }

    [...]

}

Before the first deployment

./doctrine orm:schema-tool:update --dump-sql
CREATE TABLE stonewood.screen (pk SERIAL NOT NULL, pk_avatar INT DEFAULT NULL, title VARCHAR(255) NOT NULL, path VARCHAR(255) NOT NULL, ddate DATE NOT NULL, PRIMARY KEY(pk));
CREATE INDEX IDX_D91A7FB3E9032144 ON stonewood.screen (pk_avatar);

During the first deployement

 
./doctrine orm:schema-tool:update --force
Updating database schema...
Database schema updated successfully! "100" queries were executed

I test the application and all work correctly

After this test

 
./doctrine orm:schema-tool:update --dump-sql
ALTER TABLE screen ADD pk SERIAL NOT NULL;
ALTER TABLE screen ADD pk_avatar INT DEFAULT NULL;
ALTER TABLE screen ADD title VARCHAR(255) NOT NULL;
ALTER TABLE screen ADD path VARCHAR(255) NOT NULL;
ALTER TABLE screen ADD ddate DATE NOT NULL;
ALTER TABLE screen ADD CONSTRAINT FK_D91A7FB3E9032144 FOREIGN KEY (pk_avatar) REFERENCES stonewood.avatar (pk) ON DELETE CASCADE NOT DEFERRABLE INITIALLY IMMEDIATE;
CREATE INDEX IDX_D91A7FB3E9032144 ON screen (pk_avatar);
ALTER TABLE screen ADD PRIMARY KEY (pk);

The result is false. I should see Nothing to update - your database is already in sync with the current entity metadata.
In addition, the schema name does not appear, except for foreign key, what must be causing the problem.



 Comments   
Comment by Benjamin Eberlei [ 27/May/12 ]

This issue was partially fixed in DBAL already, however it seems there is still a problem with sequence detection.

Comment by Benjamin Eberlei [ 08/Jul/12 ]

Fixed the sequence problem in 2.3, the other schema problems where indeed fixed in 2.2.1 already.





[DDC-1651] APC query caching fails when an entity is bound to a query parameter. Created: 14/Feb/12  Updated: 18/Feb/12  Resolved: 18/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL, ORM
Affects Version/s: 2.1.6
Fix Version/s: 2.2.1

Type: Bug Priority: Critical
Reporter: Jonathan Robinson Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Debian, Php 5.3, APC 3.1.9



 Description   

When an entity is bound as a query parameter, query caching with APC fails with error message:

Catchable fatal error: Object of class XXX could not be converted to string in /libs/doctrine-orm/Doctrine/DBAL/Connection.php on line 1081

If I bind with entity's primary key field, everything works fine.



 Comments   
Comment by Benjamin Eberlei [ 18/Feb/12 ]

Fixed and merged into 2.2 branch.

A rebase onto the 2.1.x branch would take a rewrite, since the code is completly new and since there is a simple workaround ($entity->getId()) when binding i will not backported it into the 2.1.x branch.

https://github.com/doctrine/doctrine2/commit/6cd82d77f5e581b3d21c60c5cb5e6c5042a3ff9b





[DDC-1644] Using full annotation namespace breaks annotations Created: 10/Feb/12  Updated: 17/Feb/12  Resolved: 17/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.6, 2.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: James Reed Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 1
Labels: None
Environment:

Red Hat Linux - PHP 5.3.8



 Description   

I have created my own custom annotations. They work fine when I use them in a normal class file, but if I try to use them inside of a Doctrine Model class then the base Doctrine annotations don't work. My understanding is I have to specify the full namespace for the default Annotations in order for them to work with custom annotations. However, when I do this I get the dreaded error:

Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class xxx is not a valid entity or mapped super class.' in /Magnet/winlibrary/doctrine-orm/Doctrine/ORM/Mapping/MappingException.php:142

In order to test this further I used the quick start documentation and modified it to use full annotation namespaces. Here is the code:

<?php
require_once '/library/doctrine-orm/Doctrine/Common/ClassLoader.php';

$loader = new \Doctrine\Common\ClassLoader("Doctrine", '/library/doctrine-orm');
$loader->register();

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity **/
class Post
{
    /** @ORM\Id @GeneratedValue @ORM\Column(type="integer") **/
    protected $id;
    /** @ORM\Column(type="string") **/
    protected $title;
    /** @ORM\Column(type="text") **/
    protected $body;
}

$dbParams = array(
    'driver' => 'pdo_mysql',
    'user' => 'root',
    'password' => '',
    'dbname' => 'mydb'
);

$config = Setup::createAnnotationMetadataConfiguration(array());
$entityManager = EntityManager::create($dbParams, $config);
$post = $entityManager->find("Post", 555);

print_r($post);

When I run this I get the error:

Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class Post is not a valid entity or mapped super class.' in /Magnet/winlibrary/doctrine-orm/Doctrine/ORM/Mapping/MappingException.php:142

If I remove the "ORM\" from the annotations and remove "use Doctrine\ORM\Mapping as ORM;" then it works properly. I can't seem to find why the full annotation namespaces don't work properly as I've seen a number of examples that do this.

Also, I noticed that if I specify the full namespace without the "use Doctrine\ORM\Mapping as ORM;" alias (i.e. @Doctrine\ORM\Mapping\Entity) then it works on 2.1.x but does not work on 2.2.0. Using the ORM alias does not work on either version. Given I've followed the documentation and have found inconsistencies between the versions it seems this is a bug in either the code or the documentation.



 Comments   
Comment by Benjamin Eberlei [ 17/Feb/12 ]

Setup::createAnnotationMetadataDriver().. uses the Simple Annotation Reader.

You have to setup the "normal" annotation reader with the AnnotationDriver to get "ORM\" working. This could be documented better.





[DDC-1636] JoinColumn with name the same as id generates wrong SQL. Created: 06/Feb/12  Updated: 07/Apr/12  Resolved: 07/Apr/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: DQL
Affects Version/s: 2.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Guilherme Blanco Assignee: Benjamin Eberlei
Resolution: Can't Fix Votes: 0
Labels: None

Attachments: File DDC1636Test.php    

 Description   

Issue came from Hussani de Oliveira on MSN.
He has this Entities configuration:

Usuario.php

<?php
 
namespace App\UsuariosBundle\Entity;
 
use Doctrine\ORM\Mapping as ORM;
 
/**
 * @ORM\Entity
 * @ORM\Table(name="usuarios")
 */
class Usuario
{
    /**
     * @var int
     *
     * @ORM\Id
     * @ORM\Column(name="usuarios_id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
   
    /**
     * @var string
     *
     * @ORM\Column(name="nome", type="string", length=45)
     */
    protected $nome;
   
    /**
     * @var string
     *
     * @ORM\ManyToOne(targetEntity="PerfilUsuario", fetch="EAGER")
     * @ORM\JoinColumn(name="perfil_usuarios_id", referencedColumnName="perfil_usuarios_id")
     */
    protected $perfil;
   
    // getters and setters
}

PerfilUsuario.php

<?php
 
namespace App\UsuariosBundle\Entity;
 
use Doctrine\ORM\Mapping as ORM;
 
/**
 * @ORM\Entity
 * @ORM\Table(name="perfil_usuarios")
 */
class PerfilUsuario
{
    /**
     * @var integer
     * @ORM\Id
     * @ORM\Column(name="perfil_usuarios_id", type="integer")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;
     
    /**
     * @ORM\ManyToOne(targetEntity="Secoes", fetch="EAGER")
     */
    protected $secoes;
   
    // getters and setters
}

Whenever he tries to load User (Usuario) and automatically join the UserProfle (PerfilUsuario), it generates the wrong SQL:

SELECT 
    t0.usuarios_id AS usuarios_id1, 
    t0.nome AS nome2, 
    t0.email AS email3,
    t0.login AS login4,
    t0.senha AS senha5,
    t0.cargo AS cargo6,
    t0.perfil_usuarios_id AS perfil_usuarios_id7,
    t8.perfil_usuarios_id AS perfil_usuarios_id9,
    t8.secoes_id AS secoes_id10 
FROM usuarios t0 
LEFT JOIN perfil_usuarios t8 
  ON t0.perfil_usuarios_id = t11.perfil_usuarios_id

His schema dump:

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL';
 
CREATE SCHEMA IF NOT EXISTS `aquario` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ;
USE `aquario` ;
 
-- -----------------------------------------------------
-- Table `aquario`.`perfil_usuarios`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `aquario`.`perfil_usuarios` (
  `perfil_usuarios_id` INT(11) NOT NULL ,
  `nome` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  PRIMARY KEY (`perfil_usuarios_id`) )
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;
 
 
-- -----------------------------------------------------
-- Table `aquario`.`usuarios`
-- -----------------------------------------------------
CREATE  TABLE IF NOT EXISTS `aquario`.`usuarios` (
  `usuarios_id` INT(11) NOT NULL ,
  `perfil_usuarios_id` INT(11) NULL DEFAULT NULL ,
  `nome` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `email` VARCHAR(100) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `login` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `senha` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  `cargo` VARCHAR(45) CHARACTER SET 'utf8' COLLATE 'utf8_unicode_ci' NULL DEFAULT NULL ,
  PRIMARY KEY (`usuarios_id`) ,
  INDEX `FK_PERIFIL_USUARIOS_PERFIL_USUARIOSID_PERFIL_USUARIOS` (`perfil_usuarios_id` ASC) ,
  CONSTRAINT `FK_PERIFIL_USUARIOS_PERFIL_USUARIOSID_PERFIL_USUARIOS`
    FOREIGN KEY (`perfil_usuarios_id` )
    REFERENCES `aquario`.`perfil_usuarios` (`perfil_usuarios_id` ))
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8
COLLATE = utf8_unicode_ci;


 Comments   
Comment by Fabio B. Silva [ 11/Feb/12 ]

Hi,
I'm trying to test this, But I can't reproduce.
I'm attaching a test case.

Hussani Oliveira ,
Can you try to change the test to make it fail ?

Comment by Benjamin Eberlei [ 07/Apr/12 ]

No feedback was given on this critical issue with proof of working through TestCase. Closing until further feedback.





[DDC-1640] Actual classMetadata is not used when entity with DiscriminatorMap is hydrated, instead AbstractClass metaData is used. Created: 08/Feb/12  Updated: 17/Feb/12  Resolved: 17/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2
Fix Version/s: 2.2.1
Security Level: All

Type: Bug Priority: Critical
Reporter: Jelte Steijaert Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

Because the className changes in ObjectHydrator:226 it might be that the ClassMetadata has not been loaded yet.
When the classMetadata has not been loaded the PostLoad events are not executed.

adding the following after the className has changed solves the issue.

$this->_getClassMetadata($className);

example:

Class Session {
    /**
     * @access private
     * @var ArrayCollection
     * @ORM\OneToMany(targetEntity="AbstractService", mappedBy="session")
     */
    public $services;
}
/**
 * @ORM\Entity
 * @ORM\HasLifecycleCallbacks
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="type", type="string")
 * @ORM\DiscriminatorMap({
 * 		"A" = "ServiceA",
 * 		"B" = "ServiceB"
 * })
 */
abstract class AbstractService 
{
    /**
     * @access private
     * @var string
     * @ORM\Column()
     */
    private $_status;

    public $status;

    /**
     * @access public
     * @internal Do not use; this is for Doctrine only
     * @ORM\PostLoad
     * @return void
     */
    public function _reconstituteValueObjects()
    {
        $this->status = new Status($this->_status);
    }
}

When I would do now:

foreach ( $session->services as $service ) {
    $service->status->stop();
}

$service would be a concrete class ServceA or ServiceB, but these ClassMetadata's might not be loaded yet. If this is the cause then $service->status will be null as the @PostLoad has not been executed.



 Comments   
Comment by Jelte Steijaert [ 09/Feb/12 ]

I've have found the same issue with the SimpleObjectHydrator.

Although here it might have worse consequences.
When a row is hydrated it the class has a discriminatorMap, the classMetadata of the defined class (usually the abstract class) is used and not the actual classMetadata of the class it will be converted to.
Same issue here that the @PostLoad isn't triggered but also

$this->registerManaged($this->class,...) 

uses the wrong classMetadata is used.

should be: Doctrine\ORM\Internal\Hydration\SimpleObjectHydrator:86

    protected function hydrateRowData(array $sqlResult, array &$cache, array &$result)
    {
        $classMetadata = $this->class;
        $entityName = $this->class->name;
        $data       = array();

        // We need to find the correct entity class name if we have inheritance in resultset
        if ($classMetadata->inheritanceType !== ClassMetadata::INHERITANCE_TYPE_NONE) {
            $discrColumnName = $this->_platform->getSQLResultCasing($classMetadata->discriminatorColumn['name']);

            if ($sqlResult[$discrColumnName] === '') {
                throw HydrationException::emptyDiscriminatorValue(key($this->_rsm->aliasMap));
            }

            $entityName = $classMetadata->discriminatorMap[$sqlResult[$discrColumnName]];
            $classMetadata = $this->_getClassMetadata($entityName);

            unset($sqlResult[$discrColumnName]);
        }
        foreach ($sqlResult as $column => $value) {
            // Hydrate column information if not yet present
            if ( ! isset($cache[$column])) {
                if (($info = $this->hydrateColumnInfo($entityName, $column)) === null) {
                    continue;
                }

                $cache[$column] = $info;
            }

            // Convert field to a valid PHP value
            if (isset($cache[$column]['field'])) {
                $type  = Type::getType($cache[$column]['class']->fieldMappings[$cache[$column]['name']]['type']);
                $value = $type->convertToPHPValue($value, $this->_platform);
            }

            // Prevent overwrite in case of inherit classes using same property name (See AbstractHydrator)
            if (isset($cache[$column]) && ( ! isset($data[$cache[$column]['name']]) || $value !== null)) {
                $data[$cache[$column]['name']] = $value;
            }
        }

        if (isset($this->_hints[Query::HINT_REFRESH_ENTITY])) {
            $this->registerManaged($classMetadata, $this->_hints[Query::HINT_REFRESH_ENTITY], $data);
        }

        $uow    = $this->_em->getUnitOfWork();
        $entity = $uow->createEntity($entityName, $data, $this->_hints);

        //TODO: These should be invoked later, after hydration, because associations may not yet be loaded here.
        if (isset($classMetadata->lifecycleCallbacks[Events::postLoad])) {
            $classMetadata->invokeLifecycleCallbacks(Events::postLoad, $entity);
        }

        $evm = $this->_em->getEventManager();

        if ($evm->hasListeners(Events::postLoad)) {
            $evm->dispatchEvent(Events::postLoad, new LifecycleEventArgs($entity, $this->_em));
        }

        $result[] = $entity;
    }
Comment by Jelte Steijaert [ 09/Feb/12 ]

Changed summery to better reflect the bug.

Comment by Benjamin Eberlei [ 17/Feb/12 ]

Fixed.





[DDC-1635] Single Table Inheritance and a composite key gives the wrong entity when using the IdentityMap Created: 06/Feb/12  Updated: 20/Feb/12  Resolved: 18/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.2
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Andreas Hörnicke Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

Given the following data, a single table inheritance with 'type' being the discriminator column and a composite key of (type, key, foreign):

type key foreign
type-1 key-1 xyz
type-2 key-1 xyz

As Doctrine only takes the columns 'key' and 'foreign' into the composite key, it gives me an instance of the class being mapped to 'type-1' when wanting to select an instance of 'type-2' with key=key-1 && foreign=xyz. BUT this only occurs when i already fetched the instance mapped to type-1 with the same values.



 Comments   
Comment by Benjamin Eberlei [ 10/Feb/12 ]

The type can never be part of the primary key, how did you even map that? can you post details?

Comment by Andreas Hörnicke [ 14/Feb/12 ]

I did not specified type as being part of the primary key ... for obvious reasons. I didnt even thought of it being necessary as this is the only time we are using single table inheritance.

This is an abstracted version of our domain model:

sql definition
CREATE TABLE `users` (
	`id` MEDIUMINT(8) UNSIGNED NOT NULL AUTO_INCREMENT,
	`mail` VARCHAR(255) NULL DEFAULT NULL,
	`passwd` VARCHAR(255) NULL DEFAULT NULL,
	PRIMARY KEY (`id`)
) ENGINE=InnoDB;

CREATE TABLE `tasks` (
	`id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
	`f_user` MEDIUMINT(8) UNSIGNED NULL DEFAULT NULL,
	`priority` SMALLINT(5) UNSIGNED NOT NULL,
	`some_other_column` VARCHAR(255) NULL DEFAULT NULL,
	PRIMARY KEY (`id`),
	CONSTRAINT `fk_tasks_user` FOREIGN KEY (`f_user`) REFERENCES `users` (`id`) ON UPDATE CASCADE ON DELETE SET NULL
) ENGINE=InnoDB;

CREATE TABLE `attributes` (
	`key` VARCHAR(50) NOT NULL,
	`name` VARCHAR(255) NOT NULL,
	PRIMARY KEY (`key`)
) ENGINE=InnoDB;

CREATE TABLE `attributes_rel` (
	`type` ENUM('task','user') NOT NULL,
	`foreign_id` BIGINT(20) UNSIGNED NOT NULL,
	`f_attribute` VARCHAR(50) NOT NULL,
	`value_int` BIGINT(20) UNSIGNED NULL DEFAULT NULL,
	`value_date` DATETIME NULL DEFAULT NULL,
	`value_text` TEXT NULL,
	PRIMARY KEY (`type`, `foreign_id`, `f_attribute`),
	CONSTRAINT `fk_attributes_rel_attribute` FOREIGN KEY (`f_attribute`) REFERENCES `attributes` (`key`) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=InnoDB;

INSERT INTO `attributes` (`key`, `name`) VALUES
  ('description', 'description');

INSERT INTO `users` (`id`, `mail`, `passwd`) VALUES
  (1, 'abc@def.xyz', 'e10adc3949ba59abbe56e057f20f883e');

INSERT INTO `tasks` (`id`, `f_user`, `priority`, `some_other_column`) VALUES
  (1, 1, 1, 'nothing in here');

INSERT INTO `attributes_rel` (`type`, `foreign_id`, `f_attribute`, `value_int`, `value_date`, `value_text`) VALUES
  ('task', 1, 'description', NULL, NULL, 'catchy description for a task'),
  ('user', 1, 'description', NULL, NULL, 'catchy description for a user');
// definition wihin task model
/**
 * @var \Doctrine\Common\Collections\ArrayCollection
 *
 * @OneToMany(targetEntity="TaskAttribute", mappedBy="foreign")
 * @JoinColumn(name="foreign", referencedColumnName="id")
 */
protected $attributes;

// definition wihin user model
/**
 * @var \Doctrine\Common\Collections\ArrayCollection
 *
 * @OneToMany(targetEntity="UserAttribute", mappedBy="foreign")
 * @JoinColumn(name="foreign", referencedColumnName="id")
 */
protected $attributes;

When calling $em->find('Task', 1)>getAttributes() and then doing $em>find('User', 1)->getAttributes() it gives me an instance of TaskAttribute for the user instead of a fresh UserAttribute.

Comment by Benjamin Eberlei [ 18/Feb/12 ]

To have type part of the primary key you have to map it as field. Discrimnator columns can never be part of the PK for doctrine, even if they are in the database.

You can change your domain model to something like

class Attribute
{
   /** @Id @Column(type="integer") */
   public $type;
   /** @Id @ManyToOne(target="Foreign") */
   public $foreign;
   /** @id @Column(type="string") */
   public $key;
}
Comment by Andreas Hörnicke [ 20/Feb/12 ]

But then i cant use table inheritance.

Comment by Benjamin Eberlei [ 20/Feb/12 ]

Yes, you can't in your scenario, its just not supported with the discriminator column in it.





[DDC-1638] Inexistant method newInstance in UnitOfWork Created: 07/Feb/12  Updated: 10/Feb/12  Resolved: 10/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.6
Fix Version/s: 2.1.7
Security Level: All

Type: Bug Priority: Critical
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

the UnitOfWork uses ``newInstance`` to get the managed copy but this method does not exist in 2.1.6, thus breaking the code: https://github.com/doctrine/doctrine2/blob/e1647229cd2544bd77f10620e1b95a5781c4a733/lib/Doctrine/ORM/UnitOfWork.php#L1418

This is probably an error when backporting a patch as the method exists in master



 Comments   
Comment by Marco Pivetta [ 07/Feb/12 ]

Patch at https://github.com/doctrine/doctrine2/pull/276

Comment by Benjamin Eberlei [ 10/Feb/12 ]

Fixed





[DDC-1632] one-to-many associations with fetch mode eager using too many SQL queries Created: 02/Feb/12  Updated: 10/Feb/12  Resolved: 09/Feb/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.5
Fix Version/s: None
Security Level: All

Type: Bug Priority: Critical
Reporter: Martin Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

I am loading a list of many entities.
These entities have a one-to-many association to other entities.
These other entities should be loaded in one single SQL query (instead of one query for every entity in the first list).

As discribed in the doctrine2 documentation: http://www.doctrine-project.org/docs/orm/2.1/en/reference/dql-doctrine-query-language.html#temporarily-change-fetch-mode-in-dql this should be possible with "EAGER" loading.

but it does not work as described.

my code:

class User{
    /**
     * @ORM\OneToMany(targetEntity="Address", mappedBy="user", indexBy="id", fetch="EAGER")
     */
    protected $addresses;
    public function __construct(){
        $this->addresses = new ArrayCollection();
    }
}

class Address{
    /**
     * @ORM\ManyToOne(targetEntity="User", inversedBy="addresses")
     * @ORM\JoinColumns({
     *   @ORM\JoinColumn(name="UserId", referencedColumnName="id")
     * })
     */
    private $user;
}

class UserRepository{
    public function findUsersWithAddresses(){
        return $this->getEntityManager()
            ->createQuery('SELECT u FROM MyBundle:User u ORDER BY u.name ASC')
            ->setFetchMode('MyBundle\Entity\User', 'addresses', \Doctrine\ORM\Mapping\ClassMetadata::FETCH_EAGER)
            ->setMaxResults(10)
            ->getResult();
    }
}

The method UserRepository::findUsersWithAddresses() executes 11 SQL Queries instead of 2 SQL Queries.

I am using:

  • symfony v2.0.9
  • doctrine-common 2.1.4
  • doctrine-dbal 2.1.5
  • doctrine 2.1.5


 Comments   
Comment by Benjamin Eberlei [ 06/Feb/12 ]

Increased priority

Comment by Martin [ 09/Feb/12 ]

there is also a question on stackoverflow about this issue: http://stackoverflow.com/questions/9020433/doctrine2-loads-one-to-many-associations-with-fetch-mode-eager-using-too-many-sq

Comment by Benjamin Eberlei [ 09/Feb/12 ]

Its not a bug, its just a feature we haven't implemented yet.

There is a ticket for it

Comment by Martin [ 10/Feb/12 ]

Sorry, I didn't found the ticket before I reported this issue.
now i found it http://www.doctrine-project.org/jira/browse/DDC-1149

Would be very great to have this feature in a future version of doctrine.





[DDC-1598] ProxyFactory makes assumptions on identifier getter code Created: 13/Jan/12  Updated: 16/Jan/12  Resolved: 16/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.0, 2.0.1, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.1, 2.1.1, 2.1.2, 2.1.3, 2.1.4, 2.1.5, 2.2-BETA1, 2.2-BETA2, Git Master
Fix Version/s: 2.2, 2.3, 2.x
Security Level: All

Type: Bug Priority: Critical
Reporter: Marco Pivetta Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

As of
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L214
and
https://github.com/doctrine/doctrine2/blob/master/lib/Doctrine/ORM/Proxy/ProxyFactory.php#L237
the current ProxyFactory isn't actually checking if the identifier getter has logic in it.
Current checks aren't enough/valid.

In my opinion the check should be matching following:

(public|protected)\s+function\s+getFieldname\s*(\s*)\s+

{\s*\$this\s*->Fieldname\s*;\s*}

Not really experienced with regex, but currently cannot come up with a more secure check.



 Comments   
Comment by Benjamin Eberlei [ 15/Jan/12 ]

Can you explain why you think this is necessary?

You are right an id method with logic could exist in 4 lines of code, but for what purpose?

Comment by Marco Pivetta [ 15/Jan/12 ]

First of all it is a question of concept. Doctrine shouldn't assume anything about entities outside of their fields. It already introduces a level of complication when we explain how to clone/serialize objects, which was very confusing.

Asking for the purpose of an identifier field getter method is in my opinion again an attempt of making assumptions over user's code...

What if the user wrote something like:

public function getIdentifierField1()

{ return $this->identifierField1? $this->_myInitializationStuff() : null; }

private function _myInitializationStuff()

{ //open files, check stuff, make things difficult for the D2 team :D }

For instance, opening file handlers, sockets, whatever... This is a case that would break the entity because of optimization introduced by the ProxyFactory. (not to mention when getIdentifierField1 does some conversion, like return $this->identifierField1 + self::OFFSET_REQUIRED_BY_WEBSERVICE;

I'm not arguing about the validity of this optimization, but that the checks are too lazy.

I've read something about moving the ProxyFactory to common and using code scanner tools, and the check should be about applying the optimization only when the form is

return $this->identifierField1;

That's why I put the example of the regex. That would probably not be as safe as using some reflection-based tool, but surely more than just checking if the code is <= 4 lines...

Comment by Marco Pivetta [ 15/Jan/12 ]

Also don't know what stuff like EAccelerator (known in this Jira as of it's fantastic idea about stripping comments) would make the check of the 4 lines like.

Comment by Benjamin Eberlei [ 16/Jan/12 ]

This argument is void i just seen

A method:

public function getIdentifierField1()
{
   return $this->identifierField1? $this->_myInitializationStuff() : null;
} 

Will only used when the id is not set anyways.

In any other case Ids are Immutable and changing them in your code would break a lot more than just this smart proxy method generation.

Comment by Marco Pivetta [ 16/Jan/12 ]

Nope, this code actually works only if the ID is set
I'm not talking about changing IDs, it's just that getters and setters don't always reflect the class attributes...

Comment by Marco Pivetta [ 16/Jan/12 ]

As of IRC there's 3 ways (for now) to get this solved:

  • Some code scanner/stronger checks (difficult/problems with private methods/slow)
  • Regex (as of description)
  • Adding configuration (per-entity or per-method. Probably too messy)
  • Documenting it as "magic" of proxies and let the users be aware of it




[DDC-1568] A better quality control?? Created: 27/Dec/11  Updated: 27/Dec/11  Resolved: 27/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.5
Fix Version/s: None
Security Level: All

Type: Improvement Priority: Critical
Reporter: Nurlan Turdaliev Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None


 Description   

The problem

I love doctrine, but I think you should control quality of your releases better.
Issues like this one - DDC-1504 makes doctrine smell bad.



 Comments   
Comment by Nurlan Turdaliev [ 27/Dec/11 ]

Hey guys, sorry for this ticket
I've checkouted doctrine tests, looked through 'em.
They are thorough and good.
The issue I linked in ticket happens because of misuse





[DDC-1545] Update on loaded association not detected upon flush() Created: 18/Dec/11  Updated: 19/Dec/11  Resolved: 19/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.1.5, 2.2
Security Level: All

Type: Bug Priority: Critical
Reporter: Bernhard Schussek Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None


 Description   

If an association is joined during fetching and then updated in-memory, the update is not detected during flushing. I made the following test cases:

Association is joined:

  • change NULL → entity: does not work
  • change entity → NULL: works
  • change entity1 → entity2: does not work

Assocation is not joined:

  • change NULL → entity: works
  • change entity → NULL: works
  • change entity1 → entity2: works


 Comments   
Comment by Bernhard Schussek [ 18/Dec/11 ]

See here for the test case: https://github.com/bschussek/doctrine-orm/tree/DDC-1545

Comment by Guilherme Blanco [ 19/Dec/11 ]

Increasing priority

Comment by Guilherme Blanco [ 19/Dec/11 ]

Issue fixed since this commit:

https://github.com/doctrine/doctrine2/commit/a8478d5766e2cc4185612af680b7f6bcd83af61e

Thanks a lot for the bug reporting. It was the second time someone reported me this issue and I could not reproduce! =)

Comment by Benjamin Eberlei [ 19/Dec/11 ]

This issue is referenced in Github Pull-Request GH-229
https://github.com/doctrine/doctrine2/pull/229

Comment by Benjamin Eberlei [ 19/Dec/11 ]

Related Pull Request was closed: https://github.com/doctrine/doctrine2/pull/229

Comment by Benjamin Eberlei [ 19/Dec/11 ]

Fixed properly now. Will be merged into 2.1.x

Comment by Benjamin Eberlei [ 19/Dec/11 ]

Update fix version, this was merged into 2.1.5





[DDC-1548] One to one entity badly populated Created: 19/Dec/11  Updated: 19/Dec/11  Resolved: 19/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: 2.1.5, 2.2
Security Level: All

Type: Bug Priority: Critical
Reporter: Asmir Mustafic Assignee: Guilherme Blanco
Resolution: Fixed Votes: 0
Labels: None
Environment:

ubuntu php 5.3.8


Attachments: File 1548.php    

 Description   

One to one entity over populated



 Comments   
Comment by Asmir Mustafic [ 19/Dec/11 ]

I have created a test.

the bug may be in \Doctrine\ORM\Internal\Hydration\AbstractHydrator at line 246.

i think...

remove
if ( ! isset($rowData[$dqlAlias][$cache[$key]['fieldName']]) || $value !== null) {

and replace with :

if ( ! isset($rowData[$dqlAlias][$cache[$key]['fieldName']]) && $value !== null) {

this will fix the bug

Comment by Guilherme Blanco [ 19/Dec/11 ]

Fixed since this commit: https://github.com/doctrine/doctrine2/commit/68663fac4b5619643b8a140d6bbe7031e4fa2ad5

Thanks a lot for the report and patch! =D

Comment by Benjamin Eberlei [ 19/Dec/11 ]

Update fix version, this was merged into 2.1.5





[DDC-1533] ResultSetMap don't work with aliases when using joined entites Created: 13/Dec/11  Updated: 15/Dec/11  Resolved: 15/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.4
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: Bostjan Oblak Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

windows 7, php 5.3.6



 Description   

When using entityNamespace and ResultSetMapping with joined entites you get hydration error.

Example:
EntityNamespace is set to "Project\Model"

I have result set mapping:
->addEntityResult(':Entity', 'e')
->addJoinedEntityResult(':OtherEntity', 'oe', 'e', 'other')

you will get error:

Notice: Undefined index: Projet\Model\OtherEntity in Doctrine\ORM\Internal\Hydration\ObjectHydrator.php on line 371

solution is to use full names for entites:
->addEntityResult('Project\Model\Entity', 'e')
->addJoinedEntityResult('Project\Model\OtherEntity', 'oe', 'e', 'other')



 Comments   
Comment by Benjamin Eberlei [ 15/Dec/11 ]

Class names in strings are always full qualified expect for the metadata target entities. This is expected.

I don't think a check makes sense here, also because we don't have access to a utility that allows for checks.





[DDC-1535] Association method createEntity Created: 13/Dec/11  Updated: 15/Dec/11  Resolved: 15/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.4, Git Master
Fix Version/s: None

Type: Bug Priority: Critical
Reporter: André Ribeiro de Miranda Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None
Environment:

php 5.3.8



 Description   

File: ORM/UnitOfWork.php
Method: function createEntity

within the
if ($assoc ['inversedBy'] && $assoc['type'] & ClassMetadata:ONE_TO_ONE) {

The excerpt below is thus
$targetClass->reflFields[$inverseAssoc['fieldName']]->setValue($newValue, $entity);

And should be well
$targetClass->reflFields[$inverseAssoc['fieldName']]->setValue ($entity, $newValue);



 Comments   
Comment by Guilherme Blanco [ 14/Dec/11 ]

Are you experiencing any type of issues with this?
If positive, please share your models and the script that this issue is happening.

This specific line does the inverse side association assignment of newly created node. I don't see anything wrong with that line.

Comment by Benjamin Eberlei [ 15/Dec/11 ]

This code is valid. It sets the other side of an association on a bidirectional one to one.





[DDC-1526] Unecessary queries with LEFT JOIN Created: 09/Dec/11  Updated: 23/Oct/12  Resolved: 28/Jan/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: None
Affects Version/s: 2.1.4
Fix Version/s: 2.1.6, 2.2
Security Level: All

Type: Bug Priority: Critical
Reporter: Pascal Burkhard Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

PHP 5.3.6


Attachments: Text File trace.txt     Text File trace.txt    
Issue Links:
Duplicate
is duplicated by DDC-1573 Simple relation hydratation not worki... Resolved

 Description   

After upgrading to 2.1.4 (from 2.1.2), the following dql started creating way more queries than necessary :
SELECT m, p, s, c, o
FROM FERMainBundle:Menu m
LEFT JOIN m.page p
LEFT JOIN m.section s
LEFT JOIN m.children c
LEFT JOIN s.position o
ORDER BY m.lft

Details to the code here:
http://pastie.textmate.org/private/z9gtgqe1odwenxcmudywqa
The model looks like that:
http://pastie.textmate.org/private/przxzfimsfyua02cxqcv9a

http://pastie.textmate.org/private/ob1jqiekv89e4xj9bq06q
First query is executed, it should in fact retrieve everything there is about the menu, but then it runs the second query for every menu element I have, generating a lot of queries that didn't occur before.



 Comments   
Comment by Benjamin Eberlei [ 15/Dec/11 ]

Can you profile where exactly the extra queries are executed using xdebug_start_trace? Directly during hydration or later in your code?

Comment by Pascal Burkhard [ 19/Dec/11 ]

xdebug trace start just before I query the database

Comment by Benjamin Eberlei [ 20/Dec/11 ]

Hi Pascal, sorry but this is not enough. I need this query until all the other entities (or at least one) are n+1 joined.

Comment by Pascal Burkhard [ 20/Dec/11 ]

Here the complete trace, started just before the first query. I'm sorry but I can't make heads or tails with that... I hope it can help you pinpoint the problem.

Please also note that I have update Doctrine ORM to 2.1.5 and there was a change in the number of "superfluous" queries done. I am now only left with additional queries to get the relations to "parent", cf the model ( http://pastie.textmate.org/private/przxzfimsfyua02cxqcv9a ).

Comment by Benjamin Eberlei [ 28/Dec/11 ]

Is the trace from before upgrade to 2.1.5 or after?

Comment by Pascal Burkhard [ 28/Dec/11 ]

The "complete" trace, i.e. the one that is 5.94 mb big is from after the upgrade to 2.1.5.

Comment by Benjamin Eberlei [ 29/Dec/11 ]

Can you disable the nested set extension? the other ticket uses it too and i want to rule out that its the extensions fault.

Comment by Pascal Burkhard [ 29/Dec/11 ]

Alright. I deactivated the Tree extension, but there are no changes in the number of queries.

Comment by Benjamin Eberlei [ 28/Jan/12 ]

I found the issue.

Comment by Benjamin Eberlei [ 28/Jan/12 ]

Fixed





[DDC-1515] [Regression] Entities with composite PKs and no other scalar fields are not hydrated Created: 29/Nov/11  Updated: 11/Dec/11  Resolved: 11/Dec/11

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: 2.1.4
Fix Version/s: 2.1.5
Security Level: All

Type: Bug