From: Andrew Dolgov Date: Sat, 3 Nov 2018 18:52:38 +0000 (+0300) Subject: db_prefs: fix cache never being used on read(); remove unnecessary X-Git-Tag: 18.12~48 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=22366ccc5b4b82f6867ded767b318b1ac9978270;p=tt-rss.git db_prefs: fix cache never being used on read(); remove unnecessary sprintf()s to integer --- diff --git a/classes/db/prefs.php b/classes/db/prefs.php index 64238bc7..70d8b24c 100644 --- a/classes/db/prefs.php +++ b/classes/db/prefs.php @@ -53,16 +53,14 @@ class Db_Prefs { function read($pref_name, $user_id = false, $die_on_error = false) { - $profile = false; - if (!$user_id) { $user_id = $_SESSION["uid"]; @$profile = $_SESSION["profile"]; } else { - $user_id = sprintf("%d", $user_id); + $profile = false; } - if (isset($this->cache[$pref_name]) && !$user_id) { + if ($user_id == $_SESSION['uid'] && isset($this->cache[$pref_name])) { $tuple = $this->cache[$pref_name]; return $this->convert($tuple["value"], $tuple["type"]); } @@ -114,8 +112,6 @@ class Db_Prefs { if (!$user_id) { $user_id = $_SESSION["uid"]; @$profile = $_SESSION["profile"]; - } else { - $user_id = sprintf("%d", $user_id); } if (!$profile || get_schema_version() < 63) $profile = null; @@ -149,7 +145,7 @@ class Db_Prefs { $value = "false"; } } else if ($type_name == "integer") { - $value = sprintf("%d", $value); + $value = (int)$value; } if ($pref_name == 'USER_TIMEZONE' && $value == '') {