From 49ac3503c19db19bd7fd08a4525a5974547d6429 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Sun, 26 Mar 2023 14:45:50 +0700 Subject: [PATCH] Added SQLite3 installed check [Cache/Datastore] (#652) --- src/Legacy/Cache/Sqlite.php | 9 +++++++++ src/Legacy/Datastore/Sqlite.php | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/src/Legacy/Cache/Sqlite.php b/src/Legacy/Cache/Sqlite.php index b099acc14..e88457fc1 100644 --- a/src/Legacy/Cache/Sqlite.php +++ b/src/Legacy/Cache/Sqlite.php @@ -36,6 +36,10 @@ class Sqlite extends Common public function __construct($cfg, $prefix = null) { + if (!$this->is_installed()) { + die('Error: SQLite3 extension not installed'); + } + $this->cfg = array_merge($this->cfg, $cfg); $this->db = new SqliteCommon($this->cfg); $this->prefix = $prefix; @@ -110,4 +114,9 @@ class Sqlite extends Common $result = $this->db->query("DELETE FROM " . $this->cfg['table_name'] . " WHERE cache_expire_time < $expire_time"); return $result ? $this->db->changes() : 0; } + + public function is_installed() + { + return class_exists('SQLite3'); + } } diff --git a/src/Legacy/Datastore/Sqlite.php b/src/Legacy/Datastore/Sqlite.php index 177b71cef..47a106cf7 100644 --- a/src/Legacy/Datastore/Sqlite.php +++ b/src/Legacy/Datastore/Sqlite.php @@ -35,6 +35,10 @@ class Sqlite extends Common public function __construct($cfg, $prefix = null) { + if (!$this->is_installed()) { + die('Error: SQLite3 extension not installed'); + } + $this->cfg = array_merge($this->cfg, $cfg); $this->db = new SqliteCommon($this->cfg); $this->prefix = $prefix; @@ -77,4 +81,9 @@ class Sqlite extends Common } $this->db->debug('stop'); } + + public function is_installed() + { + return class_exists('SQLite3'); + } }