DoctrineExtensions: Root cannot be changed manually, change parent instead
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
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Comments: 28 (5 by maintainers)
Commits related to this issue
- Temporary workaround for https://github.com/Atlantic18/DoctrineExtensions/issues/1026 — committed to Kunstmaan/KunstmaanBundlesStandardEdition by deleted user 10 years ago
- Add conflict with Doctrine/orm 2.10 https://github.com/doctrine-extensions/DoctrineExtensions/issues/1026 — committed to webgriffe/SyliusClerkPlugin by lruozzi9 3 years ago
I’m receiving the same error when I try to
$em->merge()
. I’m receiving aJSON
which is deserialized usingJMSSerializerBundle
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
Doctrine/orm: “2.7” Symfony: 4.4 Scenario in place:
Desired scenario: