From 65999bd183ebf9d990667ccd46b682cecd40cbf1 Mon Sep 17 00:00:00 2001 From: Hugo Sales Date: Fri, 16 Apr 2021 16:11:34 +0000 Subject: [PATCH] [Poll] Move tables from core to plugin --- {src => plugins/Poll}/Entity/Poll.php | 0 {src => plugins/Poll}/Entity/PollResponse.php | 0 src/Entity/AttachmentThumbnail.php | 6 +++++- 3 files changed, 5 insertions(+), 1 deletion(-) rename {src => plugins/Poll}/Entity/Poll.php (100%) rename {src => plugins/Poll}/Entity/PollResponse.php (100%) diff --git a/src/Entity/Poll.php b/plugins/Poll/Entity/Poll.php similarity index 100% rename from src/Entity/Poll.php rename to plugins/Poll/Entity/Poll.php diff --git a/src/Entity/PollResponse.php b/plugins/Poll/Entity/PollResponse.php similarity index 100% rename from src/Entity/PollResponse.php rename to plugins/Poll/Entity/PollResponse.php diff --git a/src/Entity/AttachmentThumbnail.php b/src/Entity/AttachmentThumbnail.php index 74e332644a..d3e9149562 100644 --- a/src/Entity/AttachmentThumbnail.php +++ b/src/Entity/AttachmentThumbnail.php @@ -21,6 +21,7 @@ namespace App\Entity; +use App\Core\Cache; use App\Core\DB\DB; use App\Core\Entity; use App\Core\Event; @@ -118,7 +119,10 @@ class AttachmentThumbnail extends Entity public static function getOrCreate(Attachment $attachment, ?int $width = null, ?int $height = null, ?bool $crop = null) { try { - return DB::findOneBy('attachment_thumbnail', ['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height]); + return Cache::get('thumb-' . $attachment->getId() . "-{$width}x{$height}", + function () use ($attachment, $width, $height) { + return DB::findOneBy('attachment_thumbnail', ['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height]); + }); } catch (NotFoundException $e) { $thumbnail = self::create(['attachment_id' => $attachment->getId(), 'width' => $width, 'height' => $height, 'attachment' => $attachment]);