Skip to content

Commit 1231735

Browse files
committed
Revert "SQLiteJournal: checking for extension pdo_sqlite is lazy, service cache.journal is created always"
This can leads to unexpected error 500 when GC is started. This reverts commit 7212326.
1 parent 31e95ea commit 1231735

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Bridges/CacheDI/CacheExtension.php

+8-4
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,20 @@ public function loadConfiguration()
2929
{
3030
$builder = $this->getContainerBuilder();
3131

32-
$builder->addDefinition($this->prefix('journal'))
33-
->setClass(Nette\Caching\Storages\IJournal::class)
34-
->setFactory(Nette\Caching\Storages\SQLiteJournal::class, [$this->tempDir . '/cache/journal.s3db']);
32+
if (extension_loaded('pdo_sqlite')) {
33+
$builder->addDefinition($this->prefix('journal'))
34+
->setClass(Nette\Caching\Storages\IJournal::class)
35+
->setFactory(Nette\Caching\Storages\SQLiteJournal::class, [$this->tempDir . '/cache/journal.s3db']);
36+
}
3537

3638
$builder->addDefinition($this->prefix('storage'))
3739
->setClass(Nette\Caching\IStorage::class)
3840
->setFactory(Nette\Caching\Storages\FileStorage::class, [$this->tempDir . '/cache']);
3941

4042
if ($this->name === 'cache') {
41-
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
43+
if (extension_loaded('pdo_sqlite')) {
44+
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
45+
}
4246
$builder->addAlias('cacheStorage', $this->prefix('storage'));
4347
}
4448
}

src/Caching/Storages/SQLiteJournal.php

+3-4
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,15 @@ class SQLiteJournal implements IJournal
3030
*/
3131
public function __construct($path)
3232
{
33+
if (!extension_loaded('pdo_sqlite')) {
34+
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
35+
}
3336
$this->path = $path;
3437
}
3538

3639

3740
private function open()
3841
{
39-
if (!extension_loaded('pdo_sqlite')) {
40-
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
41-
}
42-
4342
if ($this->path !== ':memory:' && !is_file($this->path)) {
4443
touch($this->path); // ensures ordinary file permissions
4544
}

0 commit comments

Comments
 (0)