Add migration to update sent unsubscribe links to be instant

[MAILPOET-2736]
This commit is contained in:
Rostislav Wolny
2020-04-28 16:10:19 +02:00
committed by Veljko V
parent d19e7714c3
commit 84adf104c9

View File

@ -16,6 +16,7 @@ use MailPoet\Form\Util\Styles;
use MailPoet\Mailer\MailerLog;
use MailPoet\Models\Form;
use MailPoet\Models\Newsletter;
use MailPoet\Models\NewsletterLink;
use MailPoet\Models\ScheduledTask;
use MailPoet\Models\Segment;
use MailPoet\Models\SendingQueue;
@ -163,6 +164,7 @@ class Populator {
$this->scheduleBeamer();
$this->updateLastSubscribedAt();
$this->enableStatsNotificationsForAutomatedEmails();
$this->updateSentUnsubscribeLinksToInstantUnsubscribeLinks();
$this->scheduleUnsubscribeTokens();
$this->scheduleSubscriberLinkTokens();
@ -678,6 +680,20 @@ class Populator {
$this->settings->set(Worker::SETTINGS_KEY, $settings);
}
private function updateSentUnsubscribeLinksToInstantUnsubscribeLinks() {
if (version_compare($this->settings->get('db_version', '3.46.13'), '3.46.12', '>')) {
return;
}
$query = "UPDATE `%s` SET `url` = '%s' WHERE `url` = '%s';";
global $wpdb;
$wpdb->query(sprintf(
$query,
NewsletterLink::$_table,
NewsletterLink::INSTANT_UNSUBSCRIBE_LINK_SHORT_CODE,
NewsletterLink::UNSUBSCRIBE_LINK_SHORT_CODE
));
}
private function moveGoogleAnalyticsFromPremium() {
global $wpdb;
if (version_compare($this->settings->get('db_version', '3.38.2'), '3.38.1', '>')) {