cache db-prefs (reset on preferences -> save), misc query optimizations
This commit is contained in:
parent
798f722b01
commit
11de82c37d
11
backend.php
11
backend.php
|
@ -1914,8 +1914,8 @@
|
||||||
$_SESSION["pref_sort_feeds"] = $feeds_sort;
|
$_SESSION["pref_sort_feeds"] = $feeds_sort;
|
||||||
|
|
||||||
if ($feed_search) {
|
if ($feed_search) {
|
||||||
$search_qpart = "(UPPER(title) LIKE UPPER('%$feed_search%') OR
|
$search_qpart = "(UPPER(F1.title) LIKE UPPER('%$feed_search%') OR
|
||||||
UPPER(feed_url) LIKE UPPER('%$feed_search%')) AND";
|
UPPER(F1.feed_url) LIKE UPPER('%$feed_search%')) AND";
|
||||||
} else {
|
} else {
|
||||||
$search_qpart = "";
|
$search_qpart = "";
|
||||||
}
|
}
|
||||||
|
@ -2363,9 +2363,10 @@
|
||||||
ttrss_filter_types.description AS filter_type_descr,
|
ttrss_filter_types.description AS filter_type_descr,
|
||||||
feed_id,
|
feed_id,
|
||||||
ttrss_filter_actions.description AS action_description,
|
ttrss_filter_actions.description AS action_description,
|
||||||
(SELECT title FROM ttrss_feeds WHERE id = feed_id) AS feed_title
|
ttrss_feeds.title AS feed_title
|
||||||
FROM
|
FROM
|
||||||
ttrss_filters,ttrss_filter_types,ttrss_filter_actions
|
ttrss_filters,ttrss_filter_types,ttrss_filter_actions LEFT JOIN
|
||||||
|
ttrss_feeds ON (feed_id = ttrss_feeds.id)
|
||||||
WHERE
|
WHERE
|
||||||
filter_type = ttrss_filter_types.id AND
|
filter_type = ttrss_filter_types.id AND
|
||||||
ttrss_filter_actions.id = action_id AND
|
ttrss_filter_actions.id = action_id AND
|
||||||
|
@ -2995,6 +2996,8 @@
|
||||||
|
|
||||||
$_SESSION["prefs_op_result"] = "save-config";
|
$_SESSION["prefs_op_result"] = "save-config";
|
||||||
|
|
||||||
|
$_SESSION["prefs_cache"] = false;
|
||||||
|
|
||||||
foreach (array_keys($_POST) as $pref_name) {
|
foreach (array_keys($_POST) as $pref_name) {
|
||||||
|
|
||||||
$pref_name = db_escape_string($pref_name);
|
$pref_name = db_escape_string($pref_name);
|
||||||
|
|
23
db-prefs.php
23
db-prefs.php
|
@ -1,9 +1,12 @@
|
||||||
<?
|
<?
|
||||||
// TODO cache last query results
|
|
||||||
|
|
||||||
require_once "config.php";
|
require_once "config.php";
|
||||||
require_once "db.php";
|
require_once "db.php";
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
if (!$_SESSION["prefs_cache"])
|
||||||
|
$_SESSION["prefs_cache"] = array();
|
||||||
|
|
||||||
function get_pref($link, $pref_name, $user_id = false) {
|
function get_pref($link, $pref_name, $user_id = false) {
|
||||||
|
|
||||||
$pref_name = db_escape_string($pref_name);
|
$pref_name = db_escape_string($pref_name);
|
||||||
|
@ -12,6 +15,11 @@
|
||||||
$user_id = $_SESSION["uid"];
|
$user_id = $_SESSION["uid"];
|
||||||
} else {
|
} else {
|
||||||
$user_id = sprintf("%d", $user_id);
|
$user_id = sprintf("%d", $user_id);
|
||||||
|
$prefs_cache = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($_SESSION["prefs_cache"] && $_SESSION["prefs_cache"][$pref_name]) {
|
||||||
|
return $_SESSION["prefs_cache"][$pref_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = db_query($link, "SELECT
|
$result = db_query($link, "SELECT
|
||||||
|
@ -29,13 +37,18 @@
|
||||||
$type_name = db_fetch_result($result, 0, "type_name");
|
$type_name = db_fetch_result($result, 0, "type_name");
|
||||||
|
|
||||||
if ($type_name == "bool") {
|
if ($type_name == "bool") {
|
||||||
return $value == "true";
|
$retv = $value == "true";
|
||||||
} else if ($type_name == "integer") {
|
} else if ($type_name == "integer") {
|
||||||
return sprintf("%d", $value);
|
$retv = sprintf("%d", $value);
|
||||||
} else {
|
} else {
|
||||||
return $value;
|
$retv = $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user_id = $_SESSION["uid"]) {
|
||||||
|
$_SESSION["prefs_cache"][$pref_name] = $value;
|
||||||
|
}
|
||||||
|
return $value;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
die("Fatal error, unknown preferences key: $pref_name");
|
die("Fatal error, unknown preferences key: $pref_name");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue