From ad80f143dc3c94d79a6ceb7730ac0bc1c3d3d663 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 14 Dec 2002 23:23:35 +0000 Subject: - Fixed bug related to recent cache changes. --- modules/forum.module | 18 ++++++++++++------ modules/forum/forum.module | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'modules') diff --git a/modules/forum.module b/modules/forum.module index 7825f7eeb..41a8e1c3e 100644 --- a/modules/forum.module +++ b/modules/forum.module @@ -86,9 +86,9 @@ function forum_block($op = "list", $delta = 0) { } else { if (user_access("access content")) { - $content = cache_get("forum:block"); + $cache = cache_get("forum:block"); - if (!$content) { + if (empty($cache)) { unset($items); $content = node_title_list(db_query("SELECT n.nid, n.title, u.uid, u.name, GREATEST(n.created, MAX(c.timestamp)) AS sort FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'forum' AND n.nid = f.nid AND f.shadow = 0 AND n.status = 1 GROUP BY n.nid ORDER BY sort DESC LIMIT ". variable_get("forum_block_num", "5")), t("Active forum topics:")); $content .= "
"; @@ -102,9 +102,12 @@ function forum_block($op = "list", $delta = 0) { cache_set("forum:block", $content, time() + variable_get("cache_clear", 120)); } + else { + $content = $cache->data; + } $blocks["subject"] = t("Forum topics"); - $blocks["content"] = $content->data; + $blocks["content"] = $content; } } @@ -310,9 +313,9 @@ function forum_get_forums($tid = 0) { $tid = 0; } - $forums = cache_get("forum:$tid"); + $cache = cache_get("forum:$tid"); - if (!$forums) { + if (empty($cache)) { $forums = array(); $_forums = taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $tid); $n = 0; @@ -331,9 +334,11 @@ function forum_get_forums($tid = 0) { cache_set("forum:$tid", serialize($forums), time() + variable_get("cache_clear", 120)); } + else { + $forums = unserialize($cache->data); + } if ($user->uid && $forums) { - $forums = unserialize($forums); foreach (_forum_topics_read($user->uid) as $tid => $old) { if ($forums[$tid]) { $forums[$tid]->old_topics = $old; @@ -353,6 +358,7 @@ function forum_get_parents($tid) { $parents = array_merge($parents, $parent); $n++; } + return $parents; } diff --git a/modules/forum/forum.module b/modules/forum/forum.module index 7825f7eeb..41a8e1c3e 100644 --- a/modules/forum/forum.module +++ b/modules/forum/forum.module @@ -86,9 +86,9 @@ function forum_block($op = "list", $delta = 0) { } else { if (user_access("access content")) { - $content = cache_get("forum:block"); + $cache = cache_get("forum:block"); - if (!$content) { + if (empty($cache)) { unset($items); $content = node_title_list(db_query("SELECT n.nid, n.title, u.uid, u.name, GREATEST(n.created, MAX(c.timestamp)) AS sort FROM node n, forum f LEFT JOIN comments c ON c.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'forum' AND n.nid = f.nid AND f.shadow = 0 AND n.status = 1 GROUP BY n.nid ORDER BY sort DESC LIMIT ". variable_get("forum_block_num", "5")), t("Active forum topics:")); $content .= "
"; @@ -102,9 +102,12 @@ function forum_block($op = "list", $delta = 0) { cache_set("forum:block", $content, time() + variable_get("cache_clear", 120)); } + else { + $content = $cache->data; + } $blocks["subject"] = t("Forum topics"); - $blocks["content"] = $content->data; + $blocks["content"] = $content; } } @@ -310,9 +313,9 @@ function forum_get_forums($tid = 0) { $tid = 0; } - $forums = cache_get("forum:$tid"); + $cache = cache_get("forum:$tid"); - if (!$forums) { + if (empty($cache)) { $forums = array(); $_forums = taxonomy_get_tree(variable_get("forum_nav_vocabulary", ""), $tid); $n = 0; @@ -331,9 +334,11 @@ function forum_get_forums($tid = 0) { cache_set("forum:$tid", serialize($forums), time() + variable_get("cache_clear", 120)); } + else { + $forums = unserialize($cache->data); + } if ($user->uid && $forums) { - $forums = unserialize($forums); foreach (_forum_topics_read($user->uid) as $tid => $old) { if ($forums[$tid]) { $forums[$tid]->old_topics = $old; @@ -353,6 +358,7 @@ function forum_get_parents($tid) { $parents = array_merge($parents, $parent); $n++; } + return $parents; } -- cgit v1.2.3