-
-
Notifications
You must be signed in to change notification settings - Fork 159
/
FailTolerantProxyCacheWarmer.php
53 lines (43 loc) · 1.25 KB
/
FailTolerantProxyCacheWarmer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php
declare(strict_types=1);
/*
* This file is part of Contao.
*
* (c) Leo Feyer
*
* @license LGPL-3.0-or-later
*/
namespace Contao\CoreBundle\Doctrine\ORM;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception as DoctrineDbalException;
use Symfony\Bridge\Doctrine\CacheWarmer\ProxyCacheWarmer;
class FailTolerantProxyCacheWarmer extends ProxyCacheWarmer
{
private ProxyCacheWarmer $inner;
private Connection $connection;
public function __construct(ProxyCacheWarmer $inner, Connection $connection)
{
$this->inner = $inner;
$this->connection = $connection;
}
public function isOptional(): bool
{
return (bool) $this->inner->isOptional();
}
/**
* @return array<string>
*/
public function warmUp(string $cacheDir): array
{
// If there are no DB credentials yet (install tool) and the
// server_version was not configured, we have to skip the ORM warmup to
// prevent a DBAL exception during the automatic version detection
try {
$this->connection->getDatabasePlatform();
} catch (DoctrineDbalException | \mysqli_sql_exception $e) {
return [];
}
$this->inner->warmUp($cacheDir);
return [];
}
}