Skip to content

Commit 2793cb9

Browse files
committed
avoid exception on cache warmup when database does not exist yet.
1 parent 9641d8b commit 2793cb9

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

Doctrine/Orm/RouteProvider.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
use Doctrine\Common\Persistence\ManagerRegistry;
1515
use Doctrine\Common\Persistence\ObjectRepository;
16+
use Doctrine\DBAL\Exception\TableNotFoundException;
1617
use Symfony\Cmf\Component\Routing\Candidates\CandidatesInterface;
1718
use Symfony\Component\Routing\RouteCollection;
1819
use Symfony\Component\Routing\Exception\RouteNotFoundException;
@@ -89,7 +90,11 @@ public function getRoutesByNames($names = null)
8990
return array();
9091
}
9192

92-
return $this->getRouteRepository()->findBy(array(), null, $this->routeCollectionLimit ?: null);
93+
try {
94+
return $this->getRouteRepository()->findBy(array(), null, $this->routeCollectionLimit ?: null);
95+
} catch (TableNotFoundException $e) {
96+
return array();
97+
}
9398
}
9499

95100
$routes = array();

Doctrine/Phpcr/RouteProvider.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
namespace Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr;
1313

14+
use Doctrine\DBAL\Exception\TableNotFoundException;
1415
use PHPCR\RepositoryException;
1516
use PHPCR\Util\UUIDHelper;
1617
use Doctrine\Common\Persistence\ManagerRegistry;
@@ -156,8 +157,17 @@ private function getAllRoutes()
156157
return array();
157158
}
158159

159-
/** @var $dm DocumentManager */
160-
$dm = $this->getObjectManager();
160+
try {
161+
/** @var $dm DocumentManager */
162+
$dm = $this->getObjectManager();
163+
} catch (RepositoryException $e) {
164+
// special case: there is not even a database existing. this means there are no routes.
165+
if ($e->getPrevious() instanceof TableNotFoundException) {
166+
return array();
167+
}
168+
169+
throw $e;
170+
}
161171
$qb = $dm->createQueryBuilder();
162172

163173
$qb->from('d')->document('Symfony\Component\Routing\Route', 'd');

0 commit comments

Comments
 (0)