make sure featured image object is fully populated before caching, else it still lazy-queries tags each time

This commit is contained in:
Shish 2012-06-23 23:25:53 +01:00
parent ee1162309a
commit 5a93e650c1

View File

@ -60,10 +60,13 @@ class Featured extends Extension {
global $config, $database, $page, $user; global $config, $database, $page, $user;
$fid = $config->get_int("featured_id"); $fid = $config->get_int("featured_id");
if($fid > 0) { if($fid > 0) {
$image = $database->cache->get("featured_image_object"); $image = $database->cache->get("featured_image_object-$fid");
if(empty($image)) { if($image === false) {
$image = Image::by_id($fid); $image = Image::by_id($fid);
$database->cache->set("featured_image_object", $image, 60); if($image) { // make sure the object is fully populated before saving
$image->get_tag_array();
}
$database->cache->set("featured_image_object-$fid", $image, 60);
} }
if(!is_null($image)) { if(!is_null($image)) {
if(class_exists("Ratings")) { if(class_exists("Ratings")) {