1
1
Fork 0

More transactions, more queries on uncommitted data

This commit is contained in:
Michael Vogel 2016-10-24 08:10:27 +00:00
commit 8cab3b5592
6 changed files with 67 additions and 29 deletions

View file

@ -670,6 +670,12 @@ class Photo {
dbesc($deny_gid)
);
}
// Update the cached values
if ($album != 'Contact Photos') {
photo_albums($uid, true);
}
return $r;
}
}}
@ -1059,3 +1065,23 @@ function store_photo($a, $uid, $imagedata = "", $url = "") {
return($image);
}
function photo_albums($uid, $update = false) {
$sql_extra = permissions_sql($uid);
$key = "photo_albums:".$uid.":".local_user().":".remote_user();
$albums = Cache::get($key);
if (is_null($albums) OR $update) {
/// @todo This query needs to be renewed. It is really slow
// At this time we just store the data in the cache
$albums = qu("SELECT count(distinct `resource-id`) AS `total`, `album`
FROM `photo` USE INDEX (`uid_album_created`)
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra
GROUP BY `album` ORDER BY `created` DESC",
intval($uid),
dbesc('Contact Photos'),
dbesc(t('Contact Photos'))
);
Cache::set($key, $albums, CACHE_DAY);
}
return $albums;
}