Reputation: 838
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?
Upvotes: 3
Views: 8376
Reputation: 605
In my case, I was focused to much on incorrect annotations (as most responses suggest) and failed to see a simple problem. I had just imported a corrupted database dump.
So if anyone ever has the same problem again:
(1) Use orm:schema-tool:validate to check not only correct annotations, but also if your DB is in sync.
(2) Always check downloaded databases with a checksum!
Upvotes: 0
Reputation: 2342
I struggled with this a few hours then i found two solutions:
change:
return $entities ? $entities[0] : null;
to:
return $entities ? $entities[0] : $entity;
regenerate symfony bootstrap cache:
composer run-script post-update-cmd --no-dev
Upvotes: 4
Reputation: 367
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)
Upvotes: 2