Skip to content

Commit

Permalink
don't log errors when opts table does not exist
Browse files Browse the repository at this point in the history
This is to be expected on new setups and not an error. Other errors
would be problematic though.

This should be the last commit related to #80
  • Loading branch information
splitbrain committed Aug 17, 2023
1 parent 7467a79 commit f71fd15
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions SQLiteDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

namespace dokuwiki\plugin\sqlite;

use dokuwiki\ErrorHandler;
use dokuwiki\Extension\Event;
use dokuwiki\Logger;

Expand Down Expand Up @@ -460,18 +459,20 @@ protected function currentDbVersion()
$version = $this->getOpt('dbversion', 0);
return (int)$version;
} catch (\PDOException $e) {
// temporary logging for #80
Logger::error(
'SQLite: Could not read dbversion from opt table. Should only happen on new plugin install',
[
'dbname' => $this->dbname,
'exception' => get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
],
__FILE__,
__LINE__
);
if (!preg_match('/no such table/', $e->getMessage())) {
// if this is not a "no such table" error, there is something wrong see #80
Logger::error(
'SQLite: Could not read dbversion from opt table due to unexpected error',
[
'dbname' => $this->dbname,
'exception' => get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
],
__FILE__,
__LINE__
);
}

// add the opt table - if this fails too, let the exception bubble up
$sql = "CREATE TABLE IF NOT EXISTS opts (opt TEXT NOT NULL PRIMARY KEY, val NOT NULL DEFAULT '')";
Expand Down

0 comments on commit f71fd15

Please sign in to comment.