From f5e4bab40b33c088eaabef779ffb26f399d4b7e4 Mon Sep 17 00:00:00 2001 From: Rostislav Wolny Date: Fri, 15 Oct 2021 09:20:51 +0200 Subject: [PATCH] Migrate base64 template images data to new column [MAILPOET-2686] --- lib/Config/Populator.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php index b7d5bb8768..bc06118e62 100644 --- a/lib/Config/Populator.php +++ b/lib/Config/Populator.php @@ -12,6 +12,7 @@ use MailPoet\Cron\Workers\SubscribersLastEngagement; use MailPoet\Cron\Workers\UnsubscribeTokens; use MailPoet\Entities\FormEntity; use MailPoet\Entities\NewsletterEntity; +use MailPoet\Entities\NewsletterTemplateEntity; use MailPoet\Entities\ScheduledTaskEntity; use MailPoet\Entities\SendingQueueEntity; use MailPoet\Entities\StatisticsFormEntity; @@ -184,6 +185,7 @@ class Populator { $this->addPlacementStatusToForms(); $this->migrateFormPlacement(); $this->scheduleSubscriberLastEngagementDetection(); + $this->moveNewsletterTemplatesThumbnailData(); } private function createMailPoetPage() { @@ -899,4 +901,16 @@ class Populator { Carbon::createFromTimestamp($this->wp->currentTime('timestamp')) ); } + + private function moveNewsletterTemplatesThumbnailData() { + if (version_compare($this->settings->get('db_version', '3.71.4'), '3.71.3', '>')) { + return; + } + $newsletterTemplatesTable = $this->entityManager->getClassMetadata(NewsletterTemplateEntity::class)->getTableName(); + $this->entityManager->getConnection()->executeQuery(" + UPDATE " . $newsletterTemplatesTable . " + SET thumbnail_data = thumbnail, thumbnail = NULL + WHERE thumbnail LIKE 'data:image%';" + ); + } }