Skip to content

Commit 7212326

Browse files
committed
SQLiteJournal: checking for extension pdo_sqlite is lazy, service cache.journal is created always
1 parent 9a41df4 commit 7212326

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

composer.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
"latte/latte": "~2.4",
2525
"tracy/tracy": "^2.4"
2626
},
27+
"suggest": {
28+
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
29+
},
2730
"conflict": {
2831
"nette/nette": "<2.2"
2932
},

src/Bridges/CacheDI/CacheExtension.php

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

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-
}
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']);
3735

3836
$builder->addDefinition($this->prefix('storage'))
3937
->setClass(Nette\Caching\IStorage::class)
4038
->setFactory(Nette\Caching\Storages\FileStorage::class, [$this->tempDir . '/cache']);
4139

4240
if ($this->name === 'cache') {
43-
if (extension_loaded('pdo_sqlite')) {
44-
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
45-
}
41+
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
4642
$builder->addAlias('cacheStorage', $this->prefix('storage'));
4743
}
4844
}

src/Caching/Storages/SQLiteJournal.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,16 @@ 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-
}
3633
$this->path = $path;
3734
}
3835

3936

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

0 commit comments

Comments
 (0)