Skip to content

Commit d84d532

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 3e237cb commit d84d532

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

src/Bridges/CacheDI/CacheExtension.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,20 @@ public function loadConfiguration()
3737

3838
$builder = $this->getContainerBuilder();
3939

40-
$builder->addDefinition($this->prefix('journal'))
41-
->setClass(Nette\Caching\Storages\IJournal::class)
42-
->setFactory(Nette\Caching\Storages\SQLiteJournal::class, [$this->tempDir . '/cache/journal.s3db']);
40+
if (extension_loaded('pdo_sqlite')) {
41+
$builder->addDefinition($this->prefix('journal'))
42+
->setClass(Nette\Caching\Storages\IJournal::class)
43+
->setFactory(Nette\Caching\Storages\SQLiteJournal::class, [$this->tempDir . '/cache/journal.s3db']);
44+
}
4345

4446
$builder->addDefinition($this->prefix('storage'))
4547
->setClass(Nette\Caching\IStorage::class)
4648
->setFactory(Nette\Caching\Storages\FileStorage::class, [$this->tempDir . '/cache']);
4749

4850
if ($this->name === 'cache') {
49-
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
51+
if (extension_loaded('pdo_sqlite')) {
52+
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
53+
}
5054
$builder->addAlias('cacheStorage', $this->prefix('storage'));
5155
}
5256
}

src/Caching/Storages/SQLiteJournal.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,15 @@ class SQLiteJournal implements IJournal
2929

3030
public function __construct(string $path)
3131
{
32+
if (!extension_loaded('pdo_sqlite')) {
33+
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
34+
}
3235
$this->path = $path;
3336
}
3437

3538

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

0 commit comments

Comments
 (0)