[DDC-1056] Using the StaticPHPDriver throws PHP Error Undefined property: Doctrine\ORM\Mapping\Driver\StaticPHPDriver::$_classNames Created: 03/Mar/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

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

Type: Bug Priority: Trivial
Reporter: Steven Rosato Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File 0001-DDC-1056-PHPStaticDriver-was-missing-two-instance-va.patch    

 Description   

Using the StaticPHPDriver throws PHP Error Undefined property: Doctrine\ORM\Mapping\Driver\StaticPHPDriver::$_classNames

this is due to the class not having the two required instance variables $this->_classNames and $this->_fileExtension.



 Comments   
Comment by Steven Rosato [ 03/Mar/11 ]

I have attached the patch that resolves the issue.

Comment by Steven Rosato [ 03/Mar/11 ]

I applied the patch and added a pull request. https://github.com/doctrine/doctrine2/pull/34

Comment by Benjamin Eberlei [ 04/Mar/11 ]

Fixed





[DDC-1041] UnitOfWork tryGetById method is always called with the rootEntityName Created: 24/Feb/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

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

Type: Bug Priority: Critical
Reporter: Couragier Sébastien Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

LAMP



 Description   

My problem : i have a class table inheritance, with only 3 class, one abstract and two concrete.
says AbstractClass, ConcretClassA and ConcreteClassB
All three are declared with @entity

if i already have in my identity map the ConcretClassA with id = 1
when i do an entityManager->find('ConcreteClassB', 1) the identityMap returns me the ConcretClassA with id = 1
that's not correct !
it should return a null value instead

That's because the entityRepository (and all the other doctrine class) call the UnitOfWork tryGetById with the rootEntityName, which in my case is AbstractClass.
See the first line of the entityRepository's find method :

$this->_em->getUnitOfWork()->tryGetById($id, $this->_class->rootEntityName)

if i change this line to :

$this->_em->getUnitOfWork()->tryGetById($id, $this->_class->name)

the find method return the expected null value.

So, why the UnitOfWork tryGetById method is always called with the rootEntityName ?



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

The identity map HAS to work by root entity name.

Otherwise think of an inheritance hierachy A > B. Then both $em>find('A', 1); and $em->find('B', 1); should return the same instance.

If this does not hold you are screwed.

Your problem is more subtle, i am not sure what the expected behavior should be here.

Comment by Couragier Sébastien [ 28/Feb/11 ]

In my sense, the client code should exactly knows the inheritance hierachy, and exactly know what it wants too, so if it asks for an 'A' instance, you can't return a 'B' instance, although A inherit from B.

Comment by Benjamin Eberlei [ 28/Feb/11 ]

I agree with you except for the last sentence part.

If A->B and you query for B with Id 1 it should treturn an A if it exists. But if B->C and A->C then find(A) should only ever return As or Cs never, Bs.

Comment by Couragier Sébastien [ 28/Feb/11 ]

I agree.
Perhaps my problem is more specific to the class table inheritance strategy with an abstract class at the top of it.
Here's my identityMap's dump (with my first comment inheritance example) at the time the problem occurs :

'AbstractClass' =>
array
1 => string 'ConcretClassA'
2 => string 'ConcretClassA'
3 => string 'ConcretClassA'
367 => string 'ConcretClassB'
368 => string 'ConcretClassB'
369 => string 'ConcretClassB'

And, at this time, in my code, i would like to know if the id 1 is a ConcretClassB. If the id 1 is a ConcretClassA, i must throw an exception.
So, how could i test if the id 1 is a ConcretClassB or not, if the find('ConcretClassB', 1) method returns me the ConcretClassA 1 ?

thx for your help

Comment by Benjamin Eberlei [ 28/Feb/11 ]

Cant you just check instanceof?

$a = $em->find('ConcretClassA', $aId);
if ($a instanceof ConcretClassB) {
   throw new Exception();
}
Comment by Couragier Sébastien [ 28/Feb/11 ]

Of course i can.
But i thought Doctrine should already have to do this check internally for us. Because we must now be very careful with the find method's returns...

Nevermind, i don't have all the uses case Doctrine have to handle with inheritance in mind; so if you say it is to the client code to check, and it is a completely normal behavior, then it's okay for me.

Comment by Benjamin Eberlei [ 28/Feb/11 ]

i will change this behavior in the future, i am just making suggestions for you to fix it now. Using instanceof will also be forwards compatible since "null instanceof Class" is always false.

In any case the level of having to be careful is the same, using null instead of an object can get you into troubles aswell.

Comment by Couragier Sébastien [ 03/Mar/11 ]

Perhaps throw a \Doctrine\ORM\EntityNotFoundException would be a better option than return a null value ?

Comment by Benjamin Eberlei [ 04/Mar/11 ]

Fixed.





[DDC-1036] the Aggregate Expressions "AVG" | "MAX" | "MIN" | "SUM", should be followed by SimpleArithmeticExpression Created: 16/Feb/11  Updated: 20/Feb/11  Resolved: 20/Feb/11

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

Type: Bug Priority: Major
Reporter: Jison Xiao Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

the Aggregate Expressions "AVG" | "MAX" | "MIN" | "SUM", should be not only followed by StateFieldPathExpression , but also SimpleArithmeticExpression,
see http://www.doctrine-project.org/docs/orm/2.0/en/reference/dql-doctrine-query-language.html#aggregate-expressions

i found it can not execute dql like
select sum(c.quantity * c.price) total_price from cart c

i think, this should be a bug



 Comments   
Comment by Guilherme Blanco [ 19/Feb/11 ]

You are totally right.

I fixed on trunk repository. Thanks a lot for pointing out this issue. =)

Comment by Benjamin Eberlei [ 20/Feb/11 ]

Merged into 2.0.x also





[DDC-1034] Registered lifecycle callbacks of derived classes have unexpected call sequence Created: 15/Feb/11  Updated: 04/Mar/11  Resolved: 04/Mar/11

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

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

Attachments: File TestClasses.php    

 Description   

Situation:
Create an abstract base class (@InheritanceType("JOINED")) and a derived class, both having the annotation @HasLifecycleCallbacks and both having a method with annotation @PostLoad (different method names). The sequence of methods being called when an object is loaded from the database is not as expected.

Expected output:
Called Che\Tmp\BaseClass::PostLoadBase
Called Che\Tmp\DerivedClass::PostLoadDerived
(base value, derived value)

Actual output:
Called Che\Tmp\BaseClass::PostLoadBase
Called Che\Tmp\DerivedClass::PostLoadDerived
Called Che\Tmp\BaseClass::PostLoadBase
(base value)

Test code:
See attachment for classes

// Assume there is an entity manager $em
// Create object
$newDerived = new \Che\Tmp\DerivedClass();
$em->persist($newDerived);

// Fetch object
$derived = $em->findById('\Che\Tmp\DerivedClass', 1);
$derived->echoList();

Possible problem cause

ClassMetadataInfo::addLifecycleCallback($callback, $event) method has a note 'If the same callback is registered more than once, the old one will be overridden'. We are not sure whether this is the case.



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

Fixed.





[DDC-1033] Cloned proxies show unexpected behavior when initialized Created: 14/Feb/11  Updated: 26/Feb/11  Resolved: 26/Feb/11

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

Type: Bug Priority: Critical
Reporter: Karsten Dambekalns Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

When a proxy has been loaded and is cloned before being initialized, it will behave unexpectedly.

_load() in the proxy starts a chain of method calls that end up loading the data and putting it into the proxy being in the identity map inside UoW. Now the registered proxy will be updated, but the cloned copy will of course not be changed - except it will behave as if it was initialized. This leads (at least in my case) to changes not being picked up after merge() has been called.

In my case I could work around this if I could ask the proxy to initialize itself (DDC-733). More transparent would be a __clone() method in the proxy that initializes the proxy. This might also be related to DDC-18.



 Comments   
Comment by Benjamin Eberlei [ 18/Feb/11 ]

This issue is rather tricky, since __clone is called AFTER the actual clone, on the CLONED object. What we need is before the clone on the original object. This is pretty problematic to solve, i have to wrap my head around it.

Comment by Benjamin Eberlei [ 26/Feb/11 ]

Fixed.





[DDC-1030] Issue with parseTokensInEntityFile() and multiple levels of namespace Created: 12/Feb/11  Updated: 13/Feb/11  Resolved: 13/Feb/11

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

Type: Bug Priority: Major
Reporter: Jonathan H. Wage Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Dependency
is required for DDC-1023 the EntityGenerator duplicates the pr... Resolved

 Description   

If you have something like Acme\MainBundle\Document\User, the parser will only popular Acme\User as the key for the parsed information. We have to consider multiple leves of namespace. This concatenates each namespace after the namespace separator is found.

I made the same fix in the odm here. Pull request for ORM on the way.

https://github.com/doctrine/mongodb-odm/commit/b7c72aa7b7b41de97b328a872cc8f7d4141b3143



 Comments   
Comment by Jonathan H. Wage [ 12/Feb/11 ]

https://github.com/doctrine/doctrine2/tree/DDC-1030

Comment by Benjamin Eberlei [ 13/Feb/11 ]

Ah good catch. That fixes 2 open issues that i couldnt pin down

Comment by Benjamin Eberlei [ 13/Feb/11 ]

Fixed.





[DDC-1026] Doctrine Cache Created: 10/Feb/11  Updated: 25/Feb/11  Resolved: 25/Feb/11

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

Type: Bug Priority: Critical
Reporter: Bertrand Zuchuat Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Attachments: Text File AbstractQuery.php.patch     File apctest.tgz     Text File yay-caching-works-again.patch    

 Description   

I find a problem with doctrine cache key.

It use a namespace and key to save the value and never use the namespace to get it.

I checked that on AbstractQuery::getResultCacheId().

AbstractCache::save > use $this>_getNamespacedId($id)



 Comments   
Comment by Benjamin Eberlei [ 12/Feb/11 ]

AbstractQuery::getResultCacheId() does not append the namespace. The Cache functions fetch() and contains() do.

Comment by Alex Woods [ 24/Feb/11 ]

Actually, I think ALL result caching may be broken since the fix for DDC-892 landed. The code is expecting to fetch an array from the cache with an element in it thats key is $id. Presumably, this is to cater for cases where the hash clashes for different ids. However, the query result is not being inserted into the cache in this format!

This patch should fix the issue.

There's still a less serious issue - and that's that if there are two ids with clashing hashes that are being called repeatedly in quick succession, they're going to keep displacing each other from the cache. An alternative patch could bundle both ids them into the same cache entry:

if ($cached === false)
$cached = array();
$cached[$id] = $result;
$cacheDriver->save($id, $cached, $this->_resultCacheTTL);

However, I think displacing is better than running the risk of having a TTL that is too long be applied as the result of a clash!

EDIT: I'm also wondering why $hash isn't used as the cache key. It looks like the intention was that it should be, but it isn't..

Comment by Benjamin Eberlei [ 25/Feb/11 ]

Fixed, the DDC-892 patch was pretty borked. This does now work





[DDC-1024] the EntityGenerator generate getters and setters for properties of the parent class Created: 09/Feb/11  Updated: 04/Jan/12  Resolved: 12/Feb/11

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

Type: Bug Priority: Major
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

when using the EntityGenerator to generate getters and setters of two classes mapped with annotations, one inheriting from the other, the EntityGenerator generates getters and setters for the properties of the parent class in the child class too. This occurs since the recent EntityGenerator changes (as it did not care about inheritance before).
I suppose this is due to the fact that the getters and setters of the parent class are not yet generated when handling the child class.

I haven't try if it works well when using XML or YAML for the mapping.



 Comments   
Comment by Benjamin Eberlei [ 12/Feb/11 ]

How do you define inheritance?

Comment by Christophe Coevoet [ 12/Feb/11 ]

In my case, it was inheritance using a Single Table Inheritance.

Both entities were in the same Symfony2 Bundle so the getters and setters were generated by the same command.

Comment by Benjamin Eberlei [ 12/Feb/11 ]

fixed

Comment by yakobe [ 01/Nov/11 ]

I am still having this problem with the 2.1 branch. Should it not happen anymore?

Comment by Albert Brand [ 04/Jan/12 ]

I'm also still seeing this in 2.1 (bundled with Symfony2).
Using single table inheritance, adding a protected or public property to the abstract class causes private properties & getters & setters to be added to all subclasses.





[DDC-1023] the EntityGenerator duplicates the property when using annotations Created: 09/Feb/11  Updated: 13/Feb/11  Resolved: 13/Feb/11

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

Type: Bug Priority: Major
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Dependency
depends on DDC-1030 Issue with parseTokensInEntityFile() ... Resolved

 Description   

When using the EntityGenerator to generate getters and setters of a class mapped with annotations, all properties are duplicated. This occurs at least when the properties were defined protected (not tried with private ones).

It worked fine before the recent EntityGenerator changes.



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

Fixed





[DDC-1018] INDEX BY does not work in JOIN clauses Created: 04/Feb/11  Updated: 05/Feb/11  Resolved: 05/Feb/11

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

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

Issue Links:
Dependency
is required for DDC-250 ArrayCollection Key Column @indexBy Resolved

 Description   

It seems INDEX BY only works in the FROM, not in JOIN clauses.

This is a dependency for DDC-250



 Comments   
Comment by Benjamin Eberlei [ 05/Feb/11 ]

Fixed





[DDC-1009] Allow using an annotation namespace in the EntityGenerator Created: 01/Feb/11  Updated: 02/Feb/11  Resolved: 02/Feb/11

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

Type: Improvement Priority: Minor
Reporter: Christophe Coevoet Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

The EntityGenerator does not allow to use a namespace for annotations, which is supported by the driver and used by Symfony2 DoctrineBundle.

The pull request https://github.com/doctrine/doctrine2/pull/22 adds this behavior.



 Comments   
Comment by Benjamin Eberlei [ 02/Feb/11 ]

Fixed.





[DDC-1008] Entity Generator Stub Method For Id Generator Created: 31/Jan/11  Updated: 02/Feb/11  Resolved: 02/Feb/11

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

Type: Bug Priority: Major
Reporter: Stephen Walker Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

In the EntityGenerator when the id setting has a generator of NONE it does not add the stub method for setting the id keys value, here's my fix:

around line 478 in the _generateEntityStubMethods function, the first foreach which checks for the id mapping, change:

if ( ! isset($fieldMapping['id']) || ! $fieldMapping['id']) {

TO

if ( ! isset($fieldMapping['id']) || ! $fieldMapping['id'] || ($this->_getIdGeneratorTypeString($metadata->generatorType) == 'NONE')) {



 Comments   
Comment by Benjamin Eberlei [ 02/Feb/11 ]

Fixed





[DDC-1006] Entity Generator Regenerate If Not New Created: 31/Jan/11  Updated: 02/Feb/11  Resolved: 02/Feb/11

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

Type: Bug Priority: Major
Reporter: Stephen Walker Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None


 Description   

When regenerating entities from xml ( and i am sure all others ) it gives a blank entity class when the file exists and the regenerateIfExists is set to true, the expected result would be a full entity with any removed columns removed from the entity and new columns to be added.

i've come up with a fix that i assume is the correct way
i haven't tested this without the regeneration set to true since my application requires the regeneration, here's my code block i'm using:

$em->getConfiguration()->setMetadataDriverImpl(
new \Doctrine\ORM\Mapping\Driver\SesXmlDriver(
'ext/Doctrine/Entities/xml_metadata/'
)
);

$cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em);
$metadata = $cmf->getAllMetadata();

$generator = new \Doctrine\ORM\Tools\EntityGenerator();
$generator->setGenerateAnnotations(true);
$generator->setGenerateStubMethods(true);
$generator->setRegenerateEntityIfExists(true);
//$generator->setUpdateEntityIfExists(true);
$generator->generate($metadata, 'ext/');

in the _hasProperty and _hasMethod functions, need to add the below to the inline check:

( ! $this->_isNew && $this->_regenerateEntityIfExists)


 Comments   
Comment by Benjamin Eberlei [ 02/Feb/11 ]

blank as in the file is completly empty?

Comment by Stephen Walker [ 02/Feb/11 ]

no, it generates just the class with no properties or methods.

Comment by Benjamin Eberlei [ 02/Feb/11 ]

Fixed





[DDC-1002] bug in generate entities with many2many relationships from xml/yml shcemes Created: 25/Jan/11  Updated: 02/Feb/11  Resolved: 02/Feb/11

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

Type: Bug Priority: Major
Reporter: Stepan Tanasiychuk Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Linux stfalcon-laptop 2.6.35-22-generic #35-Ubuntu SMP Sat Oct 16 20:45:36 UTC 2010 x86_64 GNU/Linux
Installed packages, channel pear.doctrine-project.org:
======================================================
Package Version State
DoctrineCommon 2.0.0 stable
DoctrineDBAL 2.0.0 stable
DoctrineORM 2.0.0 stable


Attachments: GZip Archive Entities.tar.gz     GZip Archive yml.tar.gz    

 Description   

I try use many2many relations in my symfony2 learning project https://github.com/symfony/symfony.git
But entities thar generates from yml schemes did not meet entities from doctrine2 guide or entities from beberlei Whitewashing project https://github.com/beberlei/Whitewashing/tree/master/Blog

After that I try generate similar entitries is doctrine2-sandbox. Problem is the same
I attached yml schemes and result entities.

Problem:

  • Entities\Address does not have relations with Entities\User
  • In Entities\User property $adresses instance of Entity\Address. But this Doctrine\Common\Collections\ArrayCollection or no?
        /**
         * @var Entity\Address
         */
        private $addresses;
  • In Entities\User not at __constructor() method:
        public function __construct()
        {
            $this->addresses = new ArrayCollection();
        }


 Comments   
Comment by Benjamin Eberlei [ 02/Feb/11 ]

Fixed the msising constructor. However mind that in my Whitewashing project i wrote the entities manually, not generated them!





[DDC-953] CLI tools orm:generate-entities --regenerate-entities=1 flag will generate empty entities 50% of time. Created: 28/Dec/10  Updated: 08/Feb/11  Resolved: 08/Feb/11

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

Type: Bug Priority: Major
Reporter: Flyn San Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Ubuntu 10.10, PHP5.3.3



 Description   

Running the command:
doctrine orm:generate-entities --regenerate-entities=1 --generate-annotations=1 ./

50% of the time my entity will appear as:
<?php

namespace models;

/**

  • models\Role
    *
  • @Table(name="roles")
  • @Entity(repositoryClass="models\repositories\RoleRepository")
    */
    class Role
    {

}

The other 50% everything will be in there. In addition, if the --regenerate-entities=1 argument is removed, if I change the data in my YAML schema file for a column (such as changing length=255 to length=50 on a string), the annotations won't be updated when the updated entity is generated. It seems only new fields are being added to the entity files which is why --regenerate-entities=1 was required in the first place.



 Comments   
Comment by Benjamin Eberlei [ 02/Feb/11 ]

Fixed

Comment by Flyn San [ 08/Feb/11 ]

This issue is still not fixed in 2.0.1. Simply run orm:generate-entities --regenerate-entities=1 --generate-annotations=1 to replicate.

Comment by Benjamin Eberlei [ 08/Feb/11 ]

Yes, because this issue is fixed in 2.0.2 not in 2.0.1.





Generated at Tue Sep 02 14:29:27 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.