From f71fd1504a934bce9abc4f30fd9269859aa51cf0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Thu, 17 Aug 2023 09:42:23 +0200 Subject: [PATCH] don't log errors when opts table does not exist 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 --- SQLiteDB.php | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/SQLiteDB.php b/SQLiteDB.php index 2604d50..f7981de 100644 --- a/SQLiteDB.php +++ b/SQLiteDB.php @@ -8,7 +8,6 @@ namespace dokuwiki\plugin\sqlite; -use dokuwiki\ErrorHandler; use dokuwiki\Extension\Event; use dokuwiki\Logger; @@ -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 '')";