Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Labels:
      None

      Description

      when we have a saved document and remove that, then add a document at the same path without a flush in between, we get an exception. the reason is that persist already adds the phpcr node, but scheduleRemove does not remove the phpcrnode right away.

      the fix looks like it should be:
      UnitOfWork.php 504 remove phpcr node - 1022 do not remove here as it was removed before.

      but this leads to a problem that is either in jackalope or the phpcr-odm about /functional/user/phpcr:class being not found.

      1) Doctrine\Tests\ODM\PHPCR\Functional\BasicCrudTest::testRemoveAndInsert
      PHPCR\ItemExistsException: This node already has a child named user.

      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/vendor/jackalope/src/Jackalope/Node.php:303
      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:763
      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:404
      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:386
      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/DocumentManager.php:312
      /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/tests/Doctrine/Tests/ODM/PHPCR/Functional/BasicCrudTest.php:152

        Activity

        Hide
        Lukas Kahwe added a comment -

        imho this is now fixed. it will throw an \InvalidArgumentException that the document is detached. I have added relevant tests.

        i have also created a ticket to add something to the persistence interfaces to make it possible to ensure that a node is cleared back to defaults for all fields not being persisted: http://www.doctrine-project.org/jira/browse/DCOM-77

        Show
        Lukas Kahwe added a comment - imho this is now fixed. it will throw an \InvalidArgumentException that the document is detached. I have added relevant tests. i have also created a ticket to add something to the persistence interfaces to make it possible to ensure that a node is cleared back to defaults for all fields not being persisted: http://www.doctrine-project.org/jira/browse/DCOM-77
        Hide
        David Buchmann added a comment -

        i still have a problem with this. doing

        if ($old_node = $this->dm->find(null, $path))

        { $this->dm->remove($old_node); }

        $menuitem = new MultilangMenuItem();
        $menuitem->setPath($path);
        $menuitem->setName($name);
        $menuitem->setLabel($label);

        $this->dm->persist($menuitem);
        return $menuitem;

        leads to an exception. but imo i should be able to do this? what if i want to change the type of document at this location?

        InvalidArgumentException
        Detached document passed to persist().

        Exception trace:
        () at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:444
        Doctrine\ODM\PHPCR\UnitOfWork->doScheduleInsert() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:414
        Doctrine\ODM\PHPCR\UnitOfWork->scheduleInsert() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/DocumentManager.php:447
        Doctrine\ODM\PHPCR\DocumentManager->persist() at /home/david/liip/symfony-cmf/cmf-sandbox/src/Sandbox/MainBundle/Resources/data/fixtures/030_LoadMenuData.php:90
        Symfony\Cmf\Bundle\MenuBundle\Resources\data\fixtures\LoadMenuData->createMenuItem() at /home/david/liip/symfony-cmf/cmf-sandbox/src/Sandbox/MainBundle/Resources/data/fixtures/030_LoadMenuData.php:43
        Symfony\Cmf\Bundle\MenuBundle\Resources\data\fixtures\LoadMenuData->load() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/doctrine-data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:94
        Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/doctrine-data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/PHPCRExecutor.php:55
        Doctrine\Common\DataFixtures\Executor\PHPCRExecutor->execute() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/bundles/Doctrine/Bundle/PHPCRBundle/Command/LoadFixtureCommand.php:86
        Doctrine\Bundle\PHPCRBundle\Command\LoadFixtureCommand->execute() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:237
        Symfony\Component\Console\Command\Command->run() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Application.php:193
        Symfony\Component\Console\Application->doRun() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75
        Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Application.php:106
        Symfony\Component\Console\Application->run() at /home/david/liip/symfony-cmf/cmf-sandbox/app/console:16

        Show
        David Buchmann added a comment - i still have a problem with this. doing if ($old_node = $this->dm->find(null, $path)) { $this->dm->remove($old_node); } $menuitem = new MultilangMenuItem(); $menuitem->setPath($path); $menuitem->setName($name); $menuitem->setLabel($label); $this->dm->persist($menuitem); return $menuitem; leads to an exception. but imo i should be able to do this? what if i want to change the type of document at this location? InvalidArgumentException Detached document passed to persist(). Exception trace: () at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:444 Doctrine\ODM\PHPCR\UnitOfWork->doScheduleInsert() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/UnitOfWork.php:414 Doctrine\ODM\PHPCR\UnitOfWork->scheduleInsert() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony-cmf/vendor/doctrine-phpcr-odm/lib/Doctrine/ODM/PHPCR/DocumentManager.php:447 Doctrine\ODM\PHPCR\DocumentManager->persist() at /home/david/liip/symfony-cmf/cmf-sandbox/src/Sandbox/MainBundle/Resources/data/fixtures/030_LoadMenuData.php:90 Symfony\Cmf\Bundle\MenuBundle\Resources\data\fixtures\LoadMenuData->createMenuItem() at /home/david/liip/symfony-cmf/cmf-sandbox/src/Sandbox/MainBundle/Resources/data/fixtures/030_LoadMenuData.php:43 Symfony\Cmf\Bundle\MenuBundle\Resources\data\fixtures\LoadMenuData->load() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/doctrine-data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php:94 Doctrine\Common\DataFixtures\Executor\AbstractExecutor->load() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/doctrine-data-fixtures/lib/Doctrine/Common/DataFixtures/Executor/PHPCRExecutor.php:55 Doctrine\Common\DataFixtures\Executor\PHPCRExecutor->execute() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/bundles/Doctrine/Bundle/PHPCRBundle/Command/LoadFixtureCommand.php:86 Doctrine\Bundle\PHPCRBundle\Command\LoadFixtureCommand->execute() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:237 Symfony\Component\Console\Command\Command->run() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Application.php:193 Symfony\Component\Console\Application->doRun() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:75 Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at /home/david/liip/symfony-cmf/cmf-sandbox/vendor/symfony/src/Symfony/Component/Console/Application.php:106 Symfony\Component\Console\Application->run() at /home/david/liip/symfony-cmf/cmf-sandbox/app/console:16
        Hide
        Lukas Kahwe added a comment -

        I guess this is related to adding DocumentManager::merge()
        http://www.doctrine-project.org/jira/browse/PHPCR-13

        Show
        Lukas Kahwe added a comment - I guess this is related to adding DocumentManager::merge() http://www.doctrine-project.org/jira/browse/PHPCR-13
        Hide
        Lukas Kahwe added a comment -
        Show
        Lukas Kahwe added a comment - duplicate of http://www.doctrine-project.org/jira/browse/PHPCR-13

          People

          • Assignee:
            Jordi Boggiano
            Reporter:
            David Buchmann
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: