问题
I came across a strange behavior with Symfony and Doctrine issue, which actually found out that may be related to this bug.
request.CRITICAL: Uncaught PHP Exception Doctrine\ORM\EntityNotFoundException: "Entity was not found." at /dev/vendor/doctrine/orm/lib/Doctrine/ORM/Proxy/ProxyFactory.php line 177 {"exception":"[object] (Doctrine\ORM\EntityNotFoundException(code: 0)
To provide some code samples:
$nextItems = $this->itemManager->findNextItemByCatId($catId, 2, $allItems);
and then I am assigning the two returned results, as follows:
$output["next"] = $nextItems[0];
$output["following"] = $nextItems[1];
which then are actually returned via an API.
However, when -for testing purposes- I assign random values:
$output["next"] = "Test value 1";
$output["following"] = "Test value 2";
then no exception and error occurs and the response status is 200, as expected.
Any ideas here?
回答1:
I struggled with this a few hours then i found two solutions:
- apply doctrine workaround, at line 758 of BasicEntityPersister
change:
return $entities ? $entities[0] : null;
to:
return $entities ? $entities[0] : $entity;
regenerate symfony bootstrap cache:
composer run-script post-update-cmd --no-dev
- for 2 i also upgraded mysql to 5.6
回答2:
Maybe could be obviously, but have you checking if your query return values? About your entity, make shure that is with no error (doctrine orm:validate-schema
).
And by the way, i've so some problems with proxy directory - normaly on OS X (Doctrine 2. Auto generating proxies)
来源:https://stackoverflow.com/questions/29919275/strange-doctrine-entitynotfoundexception