diff options
author | Andrew Dolgov <[email protected]> | 2021-02-25 21:42:05 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-02-25 21:42:05 +0300 |
commit | a1ca62af50047a92692c009b97bebb73f94db7ea (patch) | |
tree | 47f884324f34fef0d293add0be4a33a7a22feb1d /classes/config.php | |
parent | 22ae284db48d03a2a9c52d48add35ce329450a99 (diff) |
cache schema version better
Diffstat (limited to 'classes/config.php')
-rw-r--r-- | classes/config.php | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/classes/config.php b/classes/config.php index 2c46e1784..ee1d3cb4a 100644 --- a/classes/config.php +++ b/classes/config.php @@ -107,8 +107,9 @@ class Config { private static $instance; private $params = []; + private $schema_version = null; - public static function get_instance() { + public static function get_instance() : Config { if (self::$instance == null) self::$instance = new self(); @@ -133,6 +134,20 @@ class Config { } } + static function get_schema_version(bool $nocache = false) { + return self::get_instance()->_schema_version($nocache); + } + + function _schema_version(bool $nocache = false) { + if (empty($this->schema_version) || $nocache) { + $row = Db::pdo()->query("SELECT schema_version FROM ttrss_version")->fetch(); + + $this->schema_version = (int) $row["schema_version"]; + } + + return $this->schema_version; + } + static function cast_to(string $value, int $type_hint) { switch ($type_hint) { case self::T_BOOL: |