summaryrefslogtreecommitdiff
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-25 21:42:05 +0300
committerAndrew Dolgov <[email protected]>2021-02-25 21:42:05 +0300
commita1ca62af50047a92692c009b97bebb73f94db7ea (patch)
tree47f884324f34fef0d293add0be4a33a7a22feb1d /classes
parent22ae284db48d03a2a9c52d48add35ce329450a99 (diff)
cache schema version better
Diffstat (limited to 'classes')
-rw-r--r--classes/config.php17
-rw-r--r--classes/dbupdater.php3
-rwxr-xr-xclasses/feeds.php2
-rw-r--r--classes/prefs.php2
-rwxr-xr-xclasses/rssutils.php4
5 files changed, 20 insertions, 8 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:
diff --git a/classes/dbupdater.php b/classes/dbupdater.php
index e923c7fcb..d1df31b40 100644
--- a/classes/dbupdater.php
+++ b/classes/dbupdater.php
@@ -12,8 +12,7 @@ class DbUpdater {
}
function get_schema_version() {
- $row = $this->pdo->query("SELECT schema_version FROM ttrss_version")->fetch();
- return (int) $row['schema_version'];
+ return Config::get_schema_version(true);
}
function is_update_required() {
diff --git a/classes/feeds.php b/classes/feeds.php
index c5f868b1d..416e1c026 100755
--- a/classes/feeds.php
+++ b/classes/feeds.php
@@ -334,7 +334,7 @@ class Feeds extends Handler_Protected {
/* we don't need those */
foreach (["date_entered", "guid", "last_published", "last_marked", "tag_cache", "favicon_avg_color",
- "uuid", "label_cache", "yyiw"] as $k)
+ "uuid", "label_cache", "yyiw", "num_enclosures"] as $k)
unset($line[$k]);
array_push($reply['content'], $line);
diff --git a/classes/prefs.php b/classes/prefs.php
index 5ce1b6104..dabe5eac6 100644
--- a/classes/prefs.php
+++ b/classes/prefs.php
@@ -137,7 +137,7 @@ class Prefs {
/** @var PDO */
private $pdo;
- public static function get_instance() {
+ public static function get_instance() : Prefs {
if (self::$instance == null)
self::$instance = new self();
diff --git a/classes/rssutils.php b/classes/rssutils.php
index b6aecb8c9..11a94162c 100755
--- a/classes/rssutils.php
+++ b/classes/rssutils.php
@@ -53,11 +53,9 @@ class RSSUtils {
}
static function update_daemon_common($limit = null, $options = []) {
- $schema_version = get_schema_version();
-
if (!$limit) $limit = Config::get(Config::DAEMON_FEED_LIMIT);
- if ($schema_version != SCHEMA_VERSION) {
+ if (get_schema_version() != SCHEMA_VERSION) {
die("Schema version is wrong, please upgrade the database.\n");
}