Skip to content

Commit

Permalink
Revert "SQLiteJournal: checking for extension pdo_sqlite is lazy, ser…
Browse files Browse the repository at this point in the history
…vice cache.journal is created always"

This can leads to unexpected error 500 when GC is started.

This reverts commit 7212326.
  • Loading branch information
dg committed Aug 30, 2017
1 parent 31e95ea commit 1231735
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
12 changes: 8 additions & 4 deletions src/Bridges/CacheDI/CacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,20 @@ public function loadConfiguration()
{
$builder = $this->getContainerBuilder();

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

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

if ($this->name === 'cache') {
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
if (extension_loaded('pdo_sqlite')) {
$builder->addAlias('nette.cacheJournal', $this->prefix('journal'));
}
$builder->addAlias('cacheStorage', $this->prefix('storage'));
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/Caching/Storages/SQLiteJournal.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,15 @@ class SQLiteJournal implements IJournal
*/
public function __construct($path)
{
if (!extension_loaded('pdo_sqlite')) {
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
}
$this->path = $path;
}


private function open()
{
if (!extension_loaded('pdo_sqlite')) {
throw new Nette\NotSupportedException('SQLiteJournal requires PHP extension pdo_sqlite which is not loaded.');
}

if ($this->path !== ':memory:' && !is_file($this->path)) {
touch($this->path); // ensures ordinary file permissions
}
Expand Down

0 comments on commit 1231735

Please sign in to comment.