[DDC-1944] [GH-408] Fix typo in remove method template in entity generator Created: 25/Jul/12  Updated: 13/Nov/13  Resolved: 29/Jul/12

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

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


 Description   

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

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

Message:

Single character change - fixes generated docblocks for removeXXX methods.

Before:

/**

  • Remove measurements
    *
  • @param <variableType$measurements
    */
    public function removeMeasurement(\My\Bundle\Entity\CalibrationMeasurement $measurements) { $this->measurements->removeElement($measurements); }

    After:

    /**
    * Remove measurements
    *
    * @param My\Bundle\Entity\Measurement $measurements
    */
    public function removeMeasurement(\My\Bundle\Entity\Measurement $measurements)
    { $this->measurements->removeElement($measurements); }


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

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

Comment by Doctrine Bot [ 13/Nov/13 ]

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





[DDC-1941] [GH-407] DDC-1939 - Removing references to non-existing AssociationMapping class Created: 24/Jul/12  Updated: 20/Dec/13  Resolved: 29/Jul/12

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

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


 Description   

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

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

Message:

This fixes DDC-1939, which is caused by an overlooked usage of `Doctrine\ORM\Mapping\AssociationMapping`, which was removed.



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

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

Comment by Benjamin Eberlei [ 29/Jul/12 ]

Merged this PR

Comment by Doctrine Bot [ 20/Dec/13 ]

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





[DDC-1939] Trying to save ManyToMany relatrionship Created: 23/Jul/12  Updated: 29/Jul/12  Resolved: 29/Jul/12

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

Type: Bug Priority: Major
Reporter: Jeremie Tom tom Assignee: Marco Pivetta
Resolution: Fixed Votes: 0
Labels: None

Attachments: File Membership.php     File Privileges.php     File UserAccount.php    

 Description   

When i try to save a many to many relationship i have to following error

Fatal error: Call to a member function getOwner() on a non-object in Doctrine/ORM/Persisters/ManyToManyPersister.php on line 181

It tries to call getOwner on the following array ($mapping)

array(19) {
["fieldName"] => string(10) "privileges"
["joinTable"] => array(4) {
["name"] => string(36) "fsbackend.user_mch_account_privilege"
["schema"] => NULL
["joinColumns"] => array(2) {
[0] => array(6)

{ ["name"] => string(13) "mch_accountid" ["referencedColumnName"] => string(13) "mch_accountid" ["unique"] => bool(false) ["nullable"] => bool(true) ["onDelete"] => NULL ["columnDefinition"] => NULL }

[1] => array(6)

{ ["name"] => string(3) "uid" ["referencedColumnName"] => string(3) "uid" ["unique"] => bool(false) ["nullable"] => bool(true) ["onDelete"] => NULL ["columnDefinition"] => NULL }

}
["inverseJoinColumns"] => array(1) {
[0] => array(6)

{ ["name"] => string(10) "resourceid" ["referencedColumnName"] => string(10) "resourceid" ["unique"] => bool(false) ["nullable"] => bool(true) ["onDelete"] => NULL ["columnDefinition"] => NULL }

}
}
["targetEntity"] => string(21) "Entity\User\Privilege"
["mappedBy"] => NULL
["inversedBy"] => NULL
["cascade"] => array(0) {
}
["indexBy"] => string(10) "resourceid"
["fetch"] => int(2)
["type"] => int(8)
["isOwningSide"] => bool(true)
["sourceEntity"] => string(26) "Entity\Merchant\Membership"
["isCascadeRemove"] => bool(false)
["isCascadePersist"] => bool(false)
["isCascadeRefresh"] => bool(false)
["isCascadeMerge"] => bool(false)
["isCascadeDetach"] => bool(false)
["relationToSourceKeyColumns"] => array(2)

{ ["mch_accountid"] => string(13) "mch_accountid" ["uid"] => string(3) "uid" }

["joinTableColumns"] => array(3)

{ [0] => string(13) "mch_accountid" [1] => string(3) "uid" [2] => string(10) "resourceid" }

["relationToTargetKeyColumns"] => array(1)

{ ["resourceid"] => string(10) "resourceid" }

}



 Comments   
Comment by Marco Pivetta [ 23/Jul/12 ]

Can you try to replace your cache with an `ArrayCache` and see if the problem may come from there?
It would also be interesting to see your bootstrap code and the code you use to interact with the collection.

Comment by Jeremie Tom tom [ 23/Jul/12 ]

I'm already using an ArrayCache for my cache.

Also for my bootstrap I'm using this implementation of it : https://github.com/guilhermeblanco/ZendFramework1-Doctrine2.

Here is how i interact with the collection.

$collection->clear();
foreach ($values as $value) {
$collection->add(
$this->_em->getReference(
'Entity\User\Privilege',
$value
));}

... Later on ...
... I have an entity $userAccount with many memberships set to Cascade persist, ....
... and on the membership entity relationship i have my collection ...

$this->_em->persist($userAccount);
$this->_em->flush();

Comment by Jeremie Tom tom [ 24/Jul/12 ]

I don't know if it helps but it works if I replace $mapping with $coll on line 181 :

$sourceClass = $this->_em->getClassMetadata(get_class($mapping->getOwner()));

Replaced by :

$sourceClass = $this->_em->getClassMetadata(get_class($coll->getOwner()));

Comment by Marco Pivetta [ 24/Jul/12 ]

Looks like code coming from the (removed) AssociationMapping class. The fix seems also to be valid. I'm patching this.

Comment by Marco Pivetta [ 24/Jul/12 ]

Nevermind, I don't think this needs a test. It is just something overlooked during a refactoring. Being handled at DDC-1941

Comment by Marco Pivetta [ 24/Jul/12 ]

Could you please provide the models anyway? It would be interesting to see why the test suite doesn't cover that part
Thank you!

Comment by Jeremie Tom tom [ 24/Jul/12 ]

Ok I attached it. Tell me if you need more informations i didn't upload the full models. But just the parts i thought were relevant.

Comment by Benjamin Eberlei [ 29/Jul/12 ]

Fixed and applied to 2.2.3 and 2.3





[DDC-1937] [GH-405] Add possibility to cache annotations wih APC Created: 21/Jul/12  Updated: 13/Nov/13  Resolved: 29/Jul/12

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

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


 Description   

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

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

Message:

APC has a bug - after apc_fetch is made, arrays loose their cursors. That is why is_numeric(key(...)) is not working



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

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

Comment by Doctrine Bot [ 13/Nov/13 ]

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

Comment by Christophe Coevoet [ 13/Nov/13 ]

It looks like the doctrine Bot is doing crap when a PR is closed. It notifies all issues marked with the PR number, even when they are for a different project (and so a different repo with its own PR numbers).





[DDC-1909] Getting Fatal error Call to undefined method Doctrine\ORM\Mapping\ClassMetadata::getSqlExecutor() Created: 05/Jul/12  Updated: 29/Jul/12  Resolved: 29/Jul/12

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

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

PHP 5.3.6-13ubuntu3.8 with Suhosin-Patch (cli) (built: Jun 13 2012 17:19:54)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.2.0, Copyright (c) 2002-2012, by Derick Rethans


Attachments: Zip Archive Bisna.zip     File DoctrineCache.php     File options.ini    

 Description   
( ! ) Fatal error: Call to undefined method Doctrine\ORM\Mapping\ClassMetadata::getSqlExecutor() in /home/www/scms/library/Doctrine/ORM/Query.php on line 241
Call Stack
#	Time	Memory	Function	Location
1	0.0000	327100	{main}( )	../index.php:0
2	0.1485	4174724	Zend_Application->run( )	../index.php:47
3	0.1485	4174724	Zend_Application_Bootstrap_Bootstrap->run( )	../Application.php:366
4	0.1486	4174796	Zend_Controller_Front->dispatch( ???, ??? )	../Bootstrap.php:97
5	0.1545	4488224	Zend_Controller_Router_Rewrite->route( object(Zend_Controller_Request_Http)[333] )	../Front.php:911
6	0.1550	4488968	SCMS_Controller_Router_Route->match( string(6), ??? )	../Rewrite.php:398
7	0.1567	4570028	Doctrine\ORM\AbstractQuery->getOneOrNullResult( long )	../Route.php:72
8	0.1567	4570192	Doctrine\ORM\AbstractQuery->execute( array(0), long )	../AbstractQuery.php:571
9	0.1567	4570660	Doctrine\ORM\Query->_doExecute( )	../AbstractQuery.php:733
Variables in local scope (#9)

$executor =

	Undefined

$paramMappings =

	Undefined

$sqlParams =

	Undefined

$types =

	Undefined

error appears out of the blue, after a few refreshes it disappears, but this happens constantly.



 Comments   
Comment by Marco Pivetta [ 05/Jul/12 ]

Can you try namespacing your caches (metadata/query/results) and see if the problem persists?
Also, it would be interesting to see your bootstrap configuration...

Comment by Benjamin Eberlei [ 05/Jul/12 ]

We need the complete bootstrap configuratino and options.

Comment by Justinas [ 09/Jul/12 ]

DoctrineCache.php is a controller plugin that runs first and initializes doctrine cache usually memcache servers
options.ini contains all configuration options for doctrine

Bisna initializes Doctrine based on options and integrates it into ZF

as you can see all caches are namespaced, and i'm currently the only one using system locally so no cache conflicts should occur even without namespaces

Comment by Benjamin Eberlei [ 12/Jul/12 ]

Can you show one of your controller actions/model services where this error occurs, explicitly the code that generates the ResultCache keys.

Comment by Justinas [ 12/Jul/12 ]
if ($em instanceof \Doctrine\ORM\EntityManager) {
			//search for matching vanity urls from most accurate to least accurate
			//matching full slug first /tv/samsung/lcd then /tv/samsung, and then /tv
			foreach ($urls as $possible_match) {
				/* @var $q Doctrine\ORM\Query */
				$q = $em->createQuery('SELECT r
				FROM SCMS\Entity\Route r
				WHERE r.full_slug = :slug');
				$q->setMaxResults(1)
						->setParameter('slug', $possible_match)
						->useResultCache(true, \SCMS\DbCache::TTL_ROUTE, $possible_match);

				$result = $q->getOneOrNullResult(\Doctrine\ORM\Query::HYDRATE_ARRAY);
Comment by Marco Pivetta [ 12/Jul/12 ]

You should definitely namespace your cache (with something like Doctrine\Common\Cache\ApcCache#setNamespace() for example), since you're manually defining your cache key here...

Is the explicit usage of the cache ID intended?

Benjamin Eberlei, should the fetched cache items be checked for their type?

Comment by Benjamin Eberlei [ 12/Jul/12 ]

What are the contents of $urls and $possible_match? You should namespace them even further in your code:

$q->useResultCache(true, \SCMS\DbCache::TTL_ROUTE, "my_query_type_something_" . $possible_match);
Comment by Benjamin Eberlei [ 12/Jul/12 ]

This isn't related to the result cache, but to the query cache though i just realized. However i don't see any way this is possible, the DQL Query Cache key is generated as a hash, the Metadata cache entry is generated using the ClassName as key. I don't udnerstand how the Metadata could end up in a Query Cache key.

@ocramius As a fix, in AbstractQuery and ClassMetadataFactory, we should check if the return value is really instanceof ClassMetadata or ParserResult. And if that happens throw an error. Also we should prefix the metadata and DQL queries ourself.

Comment by Justinas [ 12/Jul/12 ]

$urls is an array of URIs array('/tv/samsung/lcd', '/tv/samsung', '/tv');
$possible_match is the value of array ex.: '/tv/samsung/lcd'

i'm setting the namespace in the configuration, and providing a unique id for each result cache. the documentation isn't clear
is namespace prefixed automatically if you set your cache id or is namespace ignored if you set cache id yourself.
so i always assumed that namespace is prefixed automatically, and that you have to set cacheId yourself for same query with different parameters, so that query searching for '/tv/samsung' would not return the same result as searching for '/tv';

Comment by Benjamin Eberlei [ 12/Jul/12 ]

can you try setting different namespace for Query and Metadata cache? They seem to use the same prefix. Only the Result cache uses its own prefix.

Comment by Marco Pivetta [ 12/Jul/12 ]

Justinas, setting different caches for query, results and metadata allows you to have, as an example, 3 caches writing/reading from APC. If you set a namespace for those caches, those won't collide (everything is handled transparently).

Anyway Benjamin Eberlei is correct when he states that this shouldn't happen here. Even if your approach isn't correct (you don't need to explicitly set any cache key here, plus you should be using namespaced caches) the issue seems to be valid...

Does this happen also with a clean cache?

Comment by Justinas [ 12/Jul/12 ]

i'm not sure, about the clean cache, it just doesn't happen all the time so it's hard to check. If i remember correctly i flushed the cache, and the error appeared, after a few refreshes it disappeared, without flushing cache. it sorta appears and disappears from time to time.

even if i don't set the namespace for my caches i have a local memcache, so no cache collision from other projects shouldn't occur

Comment by Benjamin Eberlei [ 29/Jul/12 ]

Added a guard to avoid this problem. Its not a real fix, but i cannot come up with the a way to reproduce the problem that you have exactly.





[DDC-1907] RemoveMethod generation doesn't exist Created: 04/Jul/12  Updated: 04/Jul/12  Resolved: 04/Jul/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: Tools
Affects Version/s: 2.2.2
Fix Version/s: 2.2.3

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

Symfony2



 Description   

Symfony2 test existence of AddMethod and RemoveMethod and tools doesn't generate RemoveMethod on Many Relation

CF : symfony2/dev-master Symfony/Component/Form/Util/PropertyPath.php Line 535



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

Fixed





[DDC-1901] [GH-386] [DDC-1895] Fix fetch relation by id of association field Created: 02/Jul/12  Updated: 05/Nov/13  Resolved: 04/Jul/12

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

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


 Description   

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

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

Message:

See issue notes for explaination



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

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

Comment by Benjamin Eberlei [ 04/Jul/12 ]

See DDC-1865

Comment by Benjamin Eberlei [ 04/Jul/12 ]

DDC-1895 i mean

Comment by Benjamin Eberlei [ 04/Jul/12 ]

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

Comment by Benjamin Eberlei [ 04/Jul/12 ]

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

Comment by Doctrine Bot [ 09/Oct/13 ]

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

Comment by Doctrine Bot [ 05/Nov/13 ]

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





[DDC-1895] update an entity with an ID column which is a relation instead of a normal field Created: 27/Jun/12  Updated: 05/Jul/12  Resolved: 05/Jul/12

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

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


 Description   

I got this error when trying to update an entity with an ID column which is a relation instead of a normal field: https://gist.github.com/3399c0ad5e0a44a29f98

Here is the relevant mapping:

<?php

namespace Roompot\TRSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Samson\Bundle\TRSBundle\Entity\Registrar;

/**
 * @ORM\Entity
 */
class RegistrarDepartmentMapping
{
    /**
     * @ORM\ManyToOne(targetEntity="RoompotRegistrar")
     * @ORM\JoinColumn(referencedColumnName="person_id")
     * @ORM\Id
     */
    private $registrar;

    /**
     * @ORM\ManyToOne(targetEntity="Department")
     * @ORM\Id
     */
    private $department;

    /**
     * @ORM\Column(type="boolean")
     */
    private $head = false;

    public function getRegistrar()
    {
        return $this->registrar;
    }

    public function setRegistrar(Registrar $registrar)
    {
        if (null !== $this->registrar) {
            throw new \RuntimeException('Cannot change registrar! Remove this entity and create a new one');
        }
        $this->registrar = $registrar;
    }

    public function getDepartment()
    {
        if (null !== $this->registrar) {
            throw new \RuntimeException('Cannot change department! Remove this entity and create a new one');
        }
        return $this->department;
    }

    public function setDepartment(Department $department)
    {
        $this->department = $department;
    }

    public function isHead()
    {
        return $this->head;
    }

    public function setHead($head)
    {
        $this->head = $head;
    }
}
<?php

namespace Roompot\TRSBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use Samson\Bundle\TRSBundle\Entity\Registrar;

/**
 * @ORM\Entity
 */
class RoompotRegistrar extends Registrar
{
    [...]
}
<?php

namespace Samson\Bundle\TRSBundle\Entity;

use Samson\Bundle\AddressBookBundle\Entity\Person;
use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity 
 * @ORM\InheritanceType("SINGLE_TABLE")
 * @ORM\DiscriminatorColumn(name="discr", type="string")
 */
abstract class Registrar
{
    /**
     * @ORM\Id
     * @ORM\OneToOne(targetEntity="Samson\Bundle\AddressBookBundle\Entity\Person", cascade={"persist"})
     * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
     */
    private $person;

    [...]
}
<?php

namespace Samson\Bundle\AddressBookBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity(repositoryClass="Samson\Bundle\AddressBookBundle\Entity\PersonRepository")
 */
class Person implements [...]
{
    /**
     * @ORM\Column(type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    [...]
}

I was able to fix the error by updating BasicEntityPersister: https://github.com/SamsonIT/doctrine2/compare/fetching_id_column_if_relation



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

Fixed





[DDC-1861] UnitOfWork#doMerge() bug on visited entities Created: 09/Jun/12  Updated: 04/Jul/12  Resolved: 04/Jul/12

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

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


 Description   

Its using return; instead of return $vsted[$oid]; because contract of doMerge(9 actually expects a @return.






[DDC-1846] Pessimistic lock does not retreive latest version of entity when entity is already in doctrine cache Created: 30/May/12  Updated: 23/Jan/14  Resolved: 07/Jul/12

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

Type: Bug Priority: Major
Reporter: Bram Klein Gunnewiek Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 0
Labels: None
Environment:

Mysql 5.5.22-0ubuntu1


Issue Links:
Reference
relates to DDC-2929 Pessimistic lock on Query does not up... Open

 Description   

When setting a pessimistic lock on an entity (e.g. a row lock) and retreiving an entity from the database, Doctrine returns the entity from cache if it has any. When updating a counter on an entity for example, it is important the row is locked, retreived, updated and then unlocked to guarantee the counter keeps in sync. Using $em->clear(); before $em->find(); is a work-around for this problem, but as requested by Benjamin Eberlei on the google groups thread (https://groups.google.com/forum/?fromgroups#!topic/doctrine-user/N8Xop2-XbTY) this bugreport is made to fix this without the need of clear().

In the next example, if the entity is previously retreived already, find() returns that version instead of retreiving the current version from the database after the rowlock is set. When $em->clear(); can be used to work-around the problem

// $em instanceof EntityManager

//$em->clear(); // Uncommenting this fixed the problem
$em->getConnection()->beginTransaction();

try {
	$entity = $em->find('Entity', $id, LockMode::PESSIMISTIC_WRITE);
	
	/* Update some fields, for example, decrease a counter */
	$entity->setCounter($entity->getCounter() - 1);
	
	$em->persist($entity);
	$em->flush();
	$em->getConnection()->commit();
} catch ( \Exception $ex ) {
	$em->getConnection()->rollback();
}


 Comments   
Comment by Bram Klein Gunnewiek [ 22/Jun/12 ]

Any update or ETA on this one? The work-around is still in my production code and I would like to get it out to get it cleaned-up a bit.

Comment by Benjamin Eberlei [ 04/Jul/12 ]

Why does the $this->_em->lock() in EntityRepository#find() don't work for you? It should grab the entity from cache, then do a SELECT 1 FROM table and do the pessemistic write lock on the row.

Comment by Bram Klein Gunnewiek [ 05/Jul/12 ]

I don't exactly know why that does not work. I created this bugreport on your request (see: https://groups.google.com/forum/?fromgroups#!topic/doctrine-user/N8Xop2-XbTY) because I couldnt figure out what I was doïng wrong.

The script that updates the entity is a long running console script, allot of times the entity in question is already in the cache and did not get locked properly. There are two seperate processes that work on the same entity (processing jobs from a jobqueu) and when updating the counters at the same time, and both scripts (with the same locking code as described in the bugreport) have to update a counter, the counter is not updated properly (e.g. both scripts do for example 2-1 where the first script should do 2-1, the second script 1-1 since the counter is updated by the first script).

Comment by Benjamin Eberlei [ 05/Jul/12 ]

Can you paste the SQL log that gets executed?

Comment by Bram Klein Gunnewiek [ 05/Jul/12 ]

Allright, I reverted the code back to my original code. Doctrine is updated to the latest dev version. Code looks like this:

 
$em = $this->getEntityManager();
#$em->clear(); // This fixes the locking problem
$em->getConnection()->beginTransaction();

try {
    // Lock entity in db and load it to update counters
    $entity = $em->find($this->getEntityName(), $this->getEppEntityId(), LockMode::PESSIMISTIC_WRITE);

    printf('Decreasing pendingjobs with 1. Current amount of pending jobs is %d', $entity->getPendingJobs());

    $entity->setPendingJobs($entity->getPendingJobs() - 1);

    $em->persist($entity);
    $em->flush();
    $em->getConnection()->commit();
} catch ( \Exception $ex ) {
    $em->getConnection()->rollback();
}

The output of the debug statement looks like this (e.g. each line is printed by a different process. Instead of the first script decreasing 2 to 1 and the second script decreasing 1 to 0, both scripts decrease 2 to 1):

 
[2012-07-05 11:31:08] Decreasing pendingjobs with 1. Current amount of pending jobs is 2
[2012-07-05 11:31:07] Decreasing pendingjobs with 1. Current amount of pending jobs is 2

I enabled SQL logging but the thing is huge and I dont really know where to look. There is data in it that I dont want publically availible on the internet, is it possible to mail the to you directly?

Comment by Benjamin Eberlei [ 07/Jul/12 ]

Fixed

Comment by Renaud Drousies [ 21/Jan/14 ]

Sorry to comment on a closed ticket, but this is also happening when setting a pessimistic lock on Query objects (unless you set the Query::HINT_REFRESH hint)

Example:

        $em->beginTransaction();
        try {
            $bar = $em->createQuery('SELECT b FROM Foo:Bar b WHERE b.id = :id')
                        ->setParameter('id', 150)
                        ->getSingleResult();
            var_dump($bar->getAmount()); // Yields some positive value
            $bar->setAmount(0);
            $bar = $em->createQuery('SELECT b FROM Foo:Bar b WHERE b.id = :id')
                        ->setParameter('id', 150)
                        ->setLockMode(\Doctrine\DBAL\LockMode::PESSIMISTIC_WRITE)
                        // ->setHint(\Doctrine\ORM\Query::HINT_REFRESH, true)
                        ->getSingleResult();
            var_dump($bar->getAmount()); // Yields 0

            $em->flush();
            $em->commit();
        } catch (\Exception $e) {
            $em->rollback();
        }

Is this the desired behaviour when using a query, or is it related to this bug?

(Tested on 2.4.0 and 2.4.1)

Comment by Jiri Kavalik [ 22/Jan/14 ]

When this is revived, I noticed that $em->lock($entiy, PESSIMISTIC_WRITE); doesn't refresh too. If it is not supposed to, it might be noted in documentation or in http://docs.doctrine-project.org/en/2.0.x/reference/transactions-and-concurrency.html

Comment by Marco Pivetta [ 22/Jan/14 ]

Renaud Drousies Jiri Kavalik can you please open separate (detailed) issues for those problems?

Comment by Renaud Drousies [ 22/Jan/14 ]

Done! See DDC-2929

Comment by Jiri Kavalik [ 23/Jan/14 ]

Done in DDC-2930





[DDC-1836] [GH-356] [DDC-1835] Fix clone side effects in PersistentCollection Created: 24/May/12  Updated: 27/May/12  Resolved: 27/May/12

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

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


 Description   

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

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

Message:



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

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





[DDC-1835] Cloning PersistentCollection affects internal collection of clone source Created: 24/May/12  Updated: 27/May/12  Resolved: 27/May/12

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

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


 Description   

When a PersistentCollection (PC) is loaded and is cloned before it is initialized, anything that is already in that collection will be duplicated if the collection is initialized after it has been marked dirty. The cause is a too late clone operation on the internal (Array)Collection (AC) in the PC.

  1. PC is loaded, but not initialized. The internal AC is empty.
  2. PC is cloned. PC' calls initialize() in __clone()
  3. PC' fills AC (as that has not been cloned yet)
  4. PC' clones AC

As a result the AC in PC now contains elements, but PC still is uninitialized. If PC is afterwards initialized and dirty, the elements already in AC will be considered new and added again to the AC.

The effect will be constraint violations in join tables due to duplicate entries.

The clone method causing this has been introduced with commit 647bd2b2f295d2cbe7d0ee67f21be8a48bae3db5 on February 17th.



 Comments   
Comment by Karsten Dambekalns [ 24/May/12 ]

Test and fix: https://github.com/doctrine/doctrine2/pull/356





[DDC-1833] [GH-354] ValidateSchemaCommand dont't call exit() in execute() Created: 22/May/12  Updated: 22/May/12  Resolved: 22/May/12

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

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


 Description   

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

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

Message:

calling exit() in the command itself is not needed. Symfony Application calls exit() with the return exit code.

chaing this into return makes the validateSchemaCommand usable in other commands as a sub-command



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

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





[DDC-1830] [GH-353] prevent the validator to stop with an "undefined array index"-error Created: 21/May/12  Updated: 22/May/12  Resolved: 22/May/12

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

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


 Description   

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

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

Message:

while validating a wrong inversedBy Attribute.

The validation-error is caught correctly in the block above. Just the warning / notice stops the validator when using stricter error handling



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

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





[DDC-1828] [GH-351] Composer requirement Created: 20/May/12  Updated: 04/Oct/13  Resolved: 22/May/12

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

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


 Description   

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

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

Message:

The ORM should accept using the 2.2 branch of DBAL and Common too, not only the tags (preferring the stable release should be done using the stability flag in composer at the project level)



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

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

Comment by Doctrine Bot [ 04/Oct/13 ]

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





[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-1798] [GH-342] Fix identifier generator strategy for composite identifier Created: 26/Apr/12  Updated: 20/Dec/13  Resolved: 27/May/12

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

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


 Description   

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

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

Message:

When using the ConvertMappingCommand on a schema that contain a table with a composite key, we got the exception:

Single id is not allowed on composite primary key in entity CollectionFields

This can be fix by setting the identifier strategy to NONE for composite identifier fields



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

Fixed

Comment by Doctrine Bot [ 20/Dec/13 ]

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





[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-1783] Combination of Query::iterate() and ObjectHydrator results in continued memory growth after clearing the entity manager Created: 17/Apr/12  Updated: 27/May/12  Resolved: 27/May/12

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

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

ubuntu 11.04, php 5.3.6-13ubuntu3.6


Attachments: File sandbox.tgz    

 Description   

To reproduce:

Start with the doctrine sandbox. Remove address relation from user. append the following to index.php

[code]
for($i=0;$i<100000;++$i) {
$user = new User;
$user->setName('foo' . $i);
$em->persist($user);
}
$em->flush();
$em->clear();

$query = $em->getRepository('Entities\User')>createQueryBuilder('u')>getQuery();
$i = 0;
echo "Running test:" . PHP_EOL . "start: " . memory_get_usage() . PHP_EOL;
foreach($query->iterate() as $row) {
$em->detach($row[0]);
if (++$i === 100000)

{ echo "end: " . memory_get_usage() . PHP_EOL; }

}

echo PHP_EOL . "done" . PHP_EOL;
[/code]

The result i get is

[code]
Running test:
start: 7658928
end: 32601776
[/code]

Adding my own custom hydrator which simply extends and resets the ObjectHydrator::_identifierMap (may cause bugs, i dont know) i get

[code]
Running test:
start: 7658768
end: 10724984
[/code]

This originally came up while working with an process to import an existing doctrine table of ~10M rows into elastic search. I realize going through the ORM will never be the most efficient, but there is room for more efficiency. With larger objects and larger result sets the memory growth is much more pronounced.



 Comments   
Comment by Erik Bernhardson [ 17/Apr/12 ]

code paste above didn't work out so well. Attached is a .tgz of the sandbox used above.

Comment by Benjamin Eberlei [ 27/May/12 ]

Fixed





[DDC-1779] [GH-336] Fixed DDC1778 Created: 16/Apr/12  Updated: 16/Apr/12  Resolved: 16/Apr/12

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

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


 Description   

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

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

Message:



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

Fixed





[DDC-1778] Cloned PersistentCollection with orphanRemoval Created: 16/Apr/12  Updated: 29/Apr/12  Resolved: 16/Apr/12

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

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


 Description   

When using a cloned PersistentCollection (with the Symfony2 Form component, for example) when orphanRemoval is enabled, the cloned PersistentCollection will tell the UOW to schedule orphan removal.

I am working on a test and a fix, posting so i get an issue number to use.



 Comments   
Comment by Tim Nagel [ 16/Apr/12 ]

Pull request with 3 failing tests (That are fixed by modifications to PersistentCollection in the same commit)

Comment by Tim Nagel [ 16/Apr/12 ]

https://github.com/doctrine/doctrine2/pull/336

Comment by Benjamin Eberlei [ 16/Apr/12 ]

Fixed

Comment by Bernhard Schussek [ 29/Apr/12 ]

Is this backported to 2.1 as well?





[DDC-1775] Notify strategy listener is not attached for new entities Created: 11/Apr/12  Updated: 07/Jul/12  Resolved: 07/Jul/12

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

Type: Bug Priority: Major
Reporter: Oleg Namaka Assignee: Benjamin Eberlei
Resolution: Fixed Votes: 1
Labels: None


 Description   

New entities with Notify strategy for changes and with GeneratedValue(strategy="AUTO") never get the onPropertyChanged listener attached to them. That happens because of the logic in the UOW::scheduleForInsert($entity) method. The last condition in it "isset($this->entityIdentifiers[$oid])" is never true because the identifier is not set and therefore the code that attaches the PropertyChangedListener in addToIdentityMap is never run.



 Comments   
Comment by Guilherme Blanco [ 23/May/12 ]

This is intentional to me.
According to code and documentation, PropertyChanged is supposed to operate over updates, never over inserts.

I experimented changing the code to also notify about changed during new and the consequences were very drastic. Internally, propertyChanged creates entityChangesets that implies an UPDATE.

Marking ticket as won't fix.

Comment by Oleg Namaka [ 24/May/12 ]

In that case the Notify strategy is partially broken:
Category entity:

..............

  *\Entity\Category
 *
 * @ORM\Table(name="category")
 * @ORM\Entity
 */
class Category implements TimestampableInterface
 
    /**
     * Caption
     *
     * @var string $caption
     * @ORM\Column(name="caption", type="text", nullable=true)
     */
    protected $caption;
	
    /**
     * Added At
     *
     * @var \DateTime $addedAt
     *
     * @ORM\Column(name="added_at", type="datetime", nullable=true)
     */
    protected $addedAt;

    public function setCaption($caption)
    {
        if ($this->caption != $caption)  {
            $this->_onPropertyChanged('caption', $this->caption, $caption);
            $this->caption = $caption;
        }
    }
	
    public function setAddedAt($addedAt)
    {
        $oldValue = $this->addedAt;
		$this->addedAt = $addedAt;
        if ((is_null($oldValue) || ($oldValue->getTimestamp() != $this->addedAt->getTimestamp()))) {
            $this->_onPropertyChanged('addedAt', $oldValue, $this->addedAt);
        }
    }

    protected function _onPropertyChanged($propName, $oldValue, $newValue)
    {
        if ($this->_listeners) {
            /** @var $listener \Doctrine\Common\PropertyChangedListener */
            foreach ($this->_listeners as $listener) {
                $listener->propertyChanged($this, $propName, $oldValue, $newValue);
            }
        }
    }

    public function addPropertyChangedListener(PropertyChangedListener $listener)
    {
        $this->_listeners[] = $listener;
    }
	
..............	

OnFlush event handler:

..............

        foreach ($uow->getScheduledEntityInsertions() as $entity) {
            if ($entity instanceof TimestampableInterface) {
                $entity->setUpdatedAt(new \DateTime('now'));
                $entity->setAddedAt(new \DateTime('now'));
                $uow->recomputeSingleEntityChangeSet($em->getClassMetadata(get_class($entity)), $entity);
            }
        }
		
...............		

Code that uses the entity:

        $cat = new \Entity\Category();
        // @todo this is a workaround until the http://www.doctrine-project.org/jira/browse/DDC-1775 is resolved
        $cat->addPropertyChangedListener($this->_em->getUnitOfWork());
        $cat->setCaption('Please explain');
        $this->_em->persist($cat);
        $this->_em->flush();

If there is no explicit call to the addPropertyChangedListener method, the caption field gets saved but the $addedAt remains null after flush. The entity does not have the attached listener so UnitOfWork does not know anything about the update that happened in the OnFlush event, and the recomputeSingleEntityChangeSet method skips entities with Notify strategy.

Comment by Benjamin Eberlei [ 27/May/12 ]

Changing computeScheduleInsertsChangeSets() would solve this, but it would also mean that the notifier gets injected more than once.

    private function computeScheduleInsertsChangeSets()
    {
        foreach ($this->entityInsertions as $entity) {
            $class = $this->em->getClassMetadata(get_class($entity));

            $this->computeChangeSet($class, $entity);

            if ($entity instanceof NotifyPropertyChanged) {
                $entity->addPropertyChangedListener($this);
            }
        }
    }

I think injecting in scheduleForInsert() is ok, but we have to look at potential problems also

Comment by Benjamin Eberlei [ 07/Jul/12 ]

Fixed





[DDC-1753] [GH-322] In some weird situation the SimpleXmlIterator used to iterate on the ``$... Created: 02/Apr/12  Updated: 21/May/14  Resolved: 16/Apr/12

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

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


 Description   

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

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

Message:

...xmlRoot->field`` property just get resetted. This solution avoid this situation. This problem occurs when Symfony2 warms up cache with autogenerate proxy to ``true``



 Comments   
Comment by Benjamin Eberlei [ 04/Apr/12 ]

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

Comment by Benjamin Eberlei [ 06/Apr/12 ]

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

Comment by Benjamin Eberlei [ 07/Apr/12 ]

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

Comment by Doctrine Bot [ 21/May/14 ]

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





[DDC-1745] [GH-316] Fixes autoloading of generated Annotations Created: 01/Apr/12  Updated: 16/Apr/12  Resolved: 16/Apr/12

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

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


 Description   

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

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

Message:

This PR fixes an [issue](https://github.com/symfony/symfony/issues/3752) submited by @Venzon.



 Comments   
Comment by Benjamin Eberlei [ 01/Apr/12 ]

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

Comment by Benjamin Eberlei [ 04/Apr/12 ]

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

Comment by Benjamin Eberlei [ 06/Apr/12 ]

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

Comment by Benjamin Eberlei [ 07/Apr/12 ]

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

Comment by Benjamin Eberlei [ 16/Apr/12 ]

Fixed





[DDC-1735] [GH-312] Removed LOCK_EX for writing Proxy class file Created: 29/Mar/12  Updated: 19/Dec/13  Resolved: 05/Jul/12

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

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


 Description   

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

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

Message:

LOCK_EX will not work on NFS and many other networked file systems.

Replaces #307



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

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

Comment by Benjamin Eberlei [ 30/Mar/12 ]

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

Comment by Benjamin Eberlei [ 30/Mar/12 ]

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

Comment by Benjamin Eberlei [ 01/Apr/12 ]

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

Comment by Benjamin Eberlei [ 04/Apr/12 ]

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

Comment by Benjamin Eberlei [ 06/Apr/12 ]

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

Comment by Benjamin Eberlei [ 07/Apr/12 ]

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

Comment by Benjamin Eberlei [ 05/Jul/12 ]

Changed to using temporary filename + rename

Comment by Doctrine Bot [ 19/Dec/13 ]

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





[DDC-1504] Cascade remove in OneToMany relation doesn't work Created: 22/Nov/11  Updated: 14/Mar/12  Resolved: 14/Mar/12

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

Type: Bug Priority: Major
Reporter: Gaetan Rousseau Assignee: Benjamin Eberlei
Resolution: Incomplete Votes: 1
Labels: None
Environment:

Ubuntu 10.10, syfmony 2.0.4


Attachments: File DDC1504GitlessTest.php    

 Description   

I have two entities :

class Structure
{
    // Id and other variables

    /**
     * @var ArrayCollection $employees liste des employés d'une structure
     *
     * @ORM\OneToMany(targetEntity="Uriae\EmployeeBundle\Entity\Employee", mappedBy="structure", cascade={"all"})
     */
    private $employees;
}

class Employee
{
    // Id and other variables

    /**
     * @var integer $structure
     *
     * @ORM\ManyToOne(targetEntity="Uriae\StructureBundle\Entity\Structure",inversedBy="employees")
     */
    private $structure;
}

The problem is when I used tests and I wan't remove a Structure the Employees aren't removed.

// Doesn't work
$em->remove($structure);
$em->flush();

// Bad solution but it works
$em->remove($structure);
$em->flush();
foreach ($employee as $employees)
{
    $em->remove($employee);
}
$e->flush();


 Comments   
Comment by petrs [ 30/Nov/11 ]

The same problem, described here
http://stackoverflow.com/questions/7766999/doctrine-2-0-vs-2-1-cascade-remove-onetomany

Comment by Gaetan Rousseau [ 30/Nov/11 ]

I know, it's me who answered. But the solution i've found is "ugly".

Comment by Benjamin Eberlei [ 15/Dec/11 ]

Fixed formatting

Comment by Nurlan Turdaliev [ 27/Dec/11 ]

If you add orphanRemoval="true" it works.
But I think doctrine should somehow let the user know about this problem (throw exception, etc.)
Maybe it worths making orphanRemoval=true when cascading=remove?

Comment by Benjamin Eberlei [ 28/Dec/11 ]

1. orphanRemoval is not the right solution, it has different semantics. If you want this semantics the solution is ok.
2. Has anyone tried updating to anything above 2.1.2?
3. I cannot reproduce with a test-case against the current master or 2.1.5

I need a better testcase. Attached is the one i am working with.

Comment by Benjamin Eberlei [ 14/Mar/12 ]

No feedback given.





Generated at Thu Oct 23 03:31:15 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.