Unfortunately `$category['attributes'])` contains a Doctrine Collection and blows up on `count()` or `foreach`.  Simply commenting out the code works, but that's not the point :)

I think it's all part of a proxy so it's blowing up when trying to run an SQL statement. Specifically in the stacktrack you can see:-

`Doctrine\ORM\Persisters\BasicEntityPersister.php(1599): Doctrine\DBAL\Connection->executeQuery('SELECT t0.name ...', Array, Array)`