Skip to content

Commit 485c09a

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

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
@@ -23,6 +23,9 @@
2323
"nette/di": "~2.3",
2424
"latte/latte": "~2.3.0"
2525
},
26+
"suggest": {
27+
"ext-pdo_sqlite": "to use SQLiteStorage or SQLiteJournal"
28+
},
2629
"conflict": {
2730
"nette/nette": "<2.2"
2831
},

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')
35-
->setFactory('Nette\Caching\Storages\SQLiteJournal', [$this->tempDir . '/cache/journal.s3db']);
36-
}
32+
$builder->addDefinition($this->prefix('journal'))
33+
->setClass('Nette\Caching\Storages\IJournal')
34+
->setFactory('Nette\Caching\Storages\SQLiteJournal', [$this->tempDir . '/cache/journal.s3db']);
3735

3836
$builder->addDefinition($this->prefix('storage'))
3937
->setClass('Nette\Caching\IStorage')
4038
->setFactory('Nette\Caching\Storages\FileStorage', [$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
@@ -28,15 +28,16 @@ class SQLiteJournal extends Nette\Object implements IJournal
2828
*/
2929
public function __construct($path = ':memory:')
3030
{
31-
if (!extension_loaded('pdo_sqlite')) {
32-
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
33-
}
3431
$this->path = $path;
3532
}
3633

3734

3835
private function open()
3936
{
37+
if (!extension_loaded('pdo_sqlite')) {
38+
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
39+
}
40+
4041
$this->pdo = new \PDO('sqlite:' . $this->path);
4142
$this->pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
4243
$this->pdo->exec('

0 commit comments

Comments
 (0)