Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Root cannot be changed manually, change parent instead #1026

Closed
man4red opened this issue Mar 26, 2014 · 28 comments
Closed

Root cannot be changed manually, change parent instead #1026

man4red opened this issue Mar 26, 2014 · 28 comments

Comments

@man4red
Copy link

man4red commented Mar 26, 2014

This error drives me crazy!
Sorry - I'm new with this.

My composer:

// composer.json
{
    "minimum-stability": "dev",
    "require": {
        "php": ">=5.3.3",
        "zendframework/zendframework": "2.2.2",
        "doctrine/doctrine-orm-module": "0.8.*@dev",
        "hounddog/doctrine-data-fixture-module": "dev-master",
        "zendframework/zftool": "dev-master",
        "gedmo/doctrine-extensions": "2.3.*",
        "phploc/phploc": "*",
        "phpmd/phpmd": "dev-master",
        "sebastian/phpcpd": "2.0.*@dev",
        "pdepend/pdepend" : "dev-master",
        "ruflin/elastica": "0.20.5.*@dev",
        "zendframework/zend-developer-tools": "dev-master"
    }
}

My setup:

zendframework/zendframework: 2.2.2
doctrine/annotations: dev-master (316b956)
doctrine/common: 2.4.x-dev (9a7e20e)
doctrine/doctrine-module: 0.8.0
doctrine/doctrine-orm-module: 0.8.0
doctrine/orm: dev-master (927d69b)
gedmo/doctrine-extensions: dev-master (ff48eb0)

Trying to make Nested Tree by documentation tutorial.

Error after this:

$food= new Category;
$food->setTitle('Food');
$em->persist($food);
$em->flush();
Gedmo\Exception\UnexpectedValueException: Root cannot be changed manually, change parent instead in /var/www/domains/zfb2.local/data/vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Strategy/ORM/Nested.php on line 143

So I've added this for debug

var_dump($food);
object(Application\Entity\Category)[377]
  private 'id' => null
  private 'title' => string 'Food' (length=4)
  private 'lft' => null
  private 'lvl' => null
  private 'rgt' => null
  private 'root' => null
  private 'parent' => null
  private 'children' => null

and

// line #142 Nested.php
var_dump($config, $changeSet);

array (size=9)
  'strategy' => string 'nested' (length=6)
  'activate_locking' => boolean false
  'locking_timeout' => int 3
  'left' => string 'lft' (length=3)
  'level' => string 'lvl' (length=3)
  'right' => string 'rgt' (length=3)
  'root' => string 'root' (length=4)
  'parent' => string 'parent' (length=6)
  'useObjectClass' => string 'Application\Entity\Category' (length=27)

array (size=6)
  'title' => 
    array (size=2)
      0 => null
      1 => string 'Food' (length=4)
  'lft' => 
    array (size=2)
      0 => null
      1 => int 0
  'lvl' => 
    array (size=2)
      0 => null
      1 => int 0
  'rgt' => 
    array (size=2)
      0 => null
      1 => int 0
  'root' => 
    array (size=2)
      0 => null
      1 => int 0
  'parent' => 
    array (size=2)
      0 => null
      1 => null

So exception here

# Nested.php #143
        if (isset($config['root']) && isset($changeSet[$config['root']])) {
            throw new \Gedmo\Exception\UnexpectedValueException("Root cannot be changed manually, change parent instead");
        }

I can't understand how to fix this.

Plz any help!
Thx

@10257
Copy link

10257 commented Mar 26, 2014

Same issue here.
It seams to be related with a recent change in doctrine ORM (doctrine/orm@d473824), that introduced a BC break.
Found some explanation in this commit comments : doctrine/orm@d473824#commitcomment-5792807

No idea how to fix this. :/

@man4red
Copy link
Author

man4red commented Mar 26, 2014

@kr0hmy, thx for your answer!

Added to composer as temporary fix:

"doctrine/orm" : "=v2.4.2"

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Mar 26, 2014

looks like an issue. will have a look this weekend and update the source code. use the older orm version for now

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Apr 2, 2014

this will require to refactor tree, will need to change the way it works now

@lmammino
Copy link

lmammino commented May 2, 2014

Any plan to fix this?

@l3pp4rd
Copy link
Contributor

l3pp4rd commented May 3, 2014

not for now, I do not use extensions and ORM in recent projects, not sure when I would be able to take care of it

@lmammino
Copy link

lmammino commented May 4, 2014

Sad news... nobody who can take care of this?
I have a project that heavily relies on the Tree extension and It will be really costly to switch to another solution.

@frodosghost
Copy link

I have the same issue, did what @man4red suggested and it has fixed it temporarily. I don't have time to look at it just now.

@gremo
Copy link

gremo commented Jun 10, 2014

Any idea/plan to fix this?

@jonesio
Copy link

jonesio commented Jun 11, 2014

+1

Also having this problem. Hoping for a fix.

@gremo
Copy link

gremo commented Jun 12, 2014

Friends, things are going worse due to this bug in tree behaviour.

Because of this Doctrine bug (DDC-3120 Warning: Erroneous data format for unserializing) we cannot use the Symfony 2 role subsystem. Affects PHP 5.4.29 also. That bug is already fixed in doctrine/orm 2.4.3 but tree behaviour requires doctrine/orm 2.4.2.

is there any way to use the fixed ClassMetadataInfo class in doctrine/rom 2.4.2?

@dirkluijk
Copy link

+1 Same over here.

Will use 2.4.2 for now, thanks @man4red.

@jmontoyaa
Copy link
Contributor

Same issue, I temporary fix it with @man4red suggestion.

@fungio
Copy link

fungio commented Jun 16, 2014

+1 Looking for a fix :)

@zrod
Copy link

zrod commented Jun 16, 2014

+1 Using temporary fix for now

@zimmermanj42
Copy link

I've got a pull request out for a possible change to the Doctrine DDC-2996 fix that may help with the issues with the DoctrineExtensions bundle.

I made the change described in the pull request, ran the DoctrineExtensions test suite, and all seemed OK. The change should also still handle the bug described in DDC-2996 too.

doctrine/orm#1074

@zimmermanj42
Copy link

A fix for DDC-3160 was just merged into the Doctrine2 master branch. That fix should get DoctrineExtensions back up and running. They are looking for feedback before deciding to port the fix to v2.4.3: http://www.doctrine-project.org/jira/browse/DDC-3208

@Venzon
Copy link

Venzon commented Jul 6, 2014

@zimmermanj42 thx for info
is there any new 2.4.4 version of doctrine2 to test or we have to wait a bit?
I will test master localy and see of extensions works ok in my project

@zimmermanj42
Copy link

I tried testing the extensions with master, but that ended up causing a bunch of other issues. Not sure if it is because master is unstable or it just has a lot of changes/new features that are incompatible with DoctrineExtensions.

What I did to test was use the broken 2.4.3 version and manually update the file that needed fixed and then ran the test suite for DoctrineExtensions. In 2.4.3, there were quite a few tests that were failing. After manually patching that release locally, all the tests reported OK again.

Ideally, a 2.4.4 version of Doctrine2 would be released that includes this fix, but that's up to the Doctrine team to get together and I don't know when that would be.

@zimmermanj42
Copy link

Doctrine2 ORM now has a 2.4.4 version that should fix these problems that were introduced with the 2.4.3 release.

@Venzon
Copy link

Venzon commented Jul 12, 2014

@zimmermanj42 thx for info
gonna check it asap

@alitvinenko
Copy link

@zimmermanj42, thank you!

@nfragnet
Copy link

It's ok : doctrine/orm 2.4.4 fixed it ! Thanks

@Venzon
Copy link

Venzon commented Jul 30, 2014

so we can close all issues related to doctrine 2.4.3 changes i guess

@steve-todorov
Copy link

steve-todorov commented Apr 4, 2017

I'm receiving the same error when I try to $em->merge(). I'm receiving a JSON which is deserialized using JMSSerializerBundle and works fine if you $em->persist(). Is there something that can be done to fix this?

I'm using Symfony 3 and doctrine/orm=v2.5.6

@fagacil
Copy link

fagacil commented Apr 4, 2018

We want to crete from child category, root category, and got this error

message: "Root cannot be changed manually, change parent instead",…}
exception: "Gedmo\Exception\UnexpectedValueException"
file: "/usr/local/src/site/vendor/gedmo/doctrine-extensions/lib/Gedmo/Tree/Strategy/ORM/Nested.php"
line: 142
message: "Root cannot be changed manually, change parent instead"
trace: [,…]

making from child category, root category.

        $category->setParent(null);
        $category->setRoot(category);

composer.json

  "require": {
        "php": "7.1.*",
        "beberlei/DoctrineExtensions": "1.0.*",
        "doctrine/dbal": "2.5.*",
        "gedmo/doctrine-extensions": "^2.4.0",
        "laravel-doctrine/extensions": "~1.0.0",
        "laravel-doctrine/orm": "~1.4.0",
        "laravel/framework": "5.5.*",
    },

So that we removed parent, but still in root category, so our left and right positions are old.

If we try

  $repo->verify();
    $repo->recover();
    $em->flush();

got this error

message: "Undefined offset: 0", exception: "ErrorException",…}
exception:"ErrorException"
file:"/usr/local/src/trade-edu/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/ClassMetadataInfo.php"
line:1782
message:"Undefined offset: 0"
trace:[{file: "/usr/local/src/site/vendor/sentry/sentry/lib/Raven/Breadcrumbs/ErrorHandler.php",…},…]

@l3pp4rd
Copy link
Contributor

l3pp4rd commented Apr 4, 2018

why are you using TreeRoot then at all? TreeRoot is meant to separate trees in the same table, for example project trees for different customers, if you use TreeRoot, the only option you have is to create a new Root node, nothing else. Do not use the TreeRoot at all. Maybe that should somehow be mentioned more explicitly in documentation if it isn't

@Nebojsaa
Copy link

Nebojsaa commented Jul 16, 2020

Doctrine/orm: "2.7"
Symfony: 4.4
Scenario in place:

  1. I come to Menu and try to delete one item in the menu itself and this is the message that I got.
  2. Screenshot from 2020-07-16 15-59-15

Desired scenario:

  1. I want to delete the item from the menu itself.
    Obviously I have checked this link, but my project is depending heavily on newest Doctrine/orm - Root cannot be changed manually, change parent instead #1026

lruozzi9 added a commit to webgriffe/SyliusClerkPlugin that referenced this issue Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests