From d8a31ce75c5c5e47f744c89f26e8dee5312c6bb3 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 23 Mar 2011 11:15:39 +0000 Subject: [PATCH] caching for featured image --- contrib/featured/main.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/contrib/featured/main.php b/contrib/featured/main.php index 7f47754a..12f06b08 100644 --- a/contrib/featured/main.php +++ b/contrib/featured/main.php @@ -55,10 +55,14 @@ class Featured extends SimpleExtension { } public function onPostListBuilding($event) { - global $config, $page, $user; + global $config, $database, $page, $user; $fid = $config->get_int("featured_id"); if($fid > 0) { - $image = Image::by_id($fid); + $image = $database->cache->get("featured_image_object"); + if(empty($image)) { + $image = Image::by_id($fid); + $database->cache->set("featured_image_object", $image, 60); + } if(!is_null($image)) { if(class_exists("Ratings")) { if(strpos(Ratings::get_user_privs($user), $image->rating) === FALSE) {