More transactions, more queries on uncommitted data
This commit is contained in:
parent
47b8975bb6
commit
8cab3b5592
6 changed files with 67 additions and 29 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue