mirror of
https://git.sekbaer.de/Friendica/friendica.git
synced 2025-06-11 17:44:27 +02:00
Use a constant for the contact photos / dom't cache them
This commit is contained in:
parent
4a1cf0e00a
commit
ce2af84cba
4 changed files with 33 additions and 20 deletions
|
@ -41,6 +41,8 @@ require_once "include/dba.php";
|
|||
*/
|
||||
class Photo
|
||||
{
|
||||
const CONTACT_PHOTOS = 'Contact Photos';
|
||||
|
||||
/**
|
||||
* Select rows from the photo table and returns them as array
|
||||
*
|
||||
|
@ -408,7 +410,7 @@ class Photo
|
|||
$micro = "";
|
||||
|
||||
$photo = DBA::selectFirst(
|
||||
"photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "album" => "Contact Photos"]
|
||||
"photo", ["resource-id"], ["uid" => $uid, "contact-id" => $cid, "scale" => 4, "album" => self::CONTACT_PHOTOS]
|
||||
);
|
||||
if (!empty($photo['resource-id'])) {
|
||||
$resource_id = $photo["resource-id"];
|
||||
|
@ -437,7 +439,7 @@ class Photo
|
|||
if ($Image->isValid()) {
|
||||
$Image->scaleToSquare(300);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 4);
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 4);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
|
@ -445,7 +447,7 @@ class Photo
|
|||
|
||||
$Image->scaleDown(80);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 5);
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 5);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
|
@ -453,7 +455,7 @@ class Photo
|
|||
|
||||
$Image->scaleDown(48);
|
||||
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, "Contact Photos", 6);
|
||||
$r = self::store($Image, $uid, $cid, $resource_id, $filename, self::CONTACT_PHOTOS, 6);
|
||||
|
||||
if ($r === false) {
|
||||
$photo_failure = true;
|
||||
|
@ -561,8 +563,8 @@ class Photo
|
|||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra
|
||||
GROUP BY `album` ORDER BY `created` DESC",
|
||||
intval($uid),
|
||||
DBA::escape("Contact Photos"),
|
||||
DBA::escape(DI::l10n()->t("Contact Photos"))
|
||||
DBA::escape(self::CONTACT_PHOTOS),
|
||||
DBA::escape(DI::l10n()->t(self::CONTACT_PHOTOS))
|
||||
);
|
||||
} else {
|
||||
// This query doesn't do the count and is much faster
|
||||
|
@ -570,8 +572,8 @@ class Photo
|
|||
FROM `photo` USE INDEX (`uid_album_scale_created`)
|
||||
WHERE `uid` = %d AND `album` != '%s' AND `album` != '%s' $sql_extra",
|
||||
intval($uid),
|
||||
DBA::escape("Contact Photos"),
|
||||
DBA::escape(DI::l10n()->t("Contact Photos"))
|
||||
DBA::escape(self::CONTACT_PHOTOS),
|
||||
DBA::escape(DI::l10n()->t(self::CONTACT_PHOTOS))
|
||||
);
|
||||
}
|
||||
DI::cache()->set($key, $albums, Duration::DAY);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue