Migration_20221028_105818_App.php
3 years ago
Migration_20230109_144830.php
3 years ago
Migration_20230131_121621.php
3 years ago
Migration_20230419_080000.php
3 years ago
Migration_20230425_211517.php
3 years ago
Migration_20230712_180341.php
3 years ago
Migration_20230803_200413_App.php
2 years ago
Migration_20230825_093531_App.php
1 year ago
Migration_20231128_120355_App.php
1 year ago
Migration_20240202_130053_App.php
2 years ago
Migration_20240207_105912_App.php
1 year ago
Migration_20240322_110443_App.php
2 years ago
Migration_20240730_212419_App.php
2 years ago
Migration_20241015_105511_App.php
1 year ago
Migration_20241128_114257_App.php
1 year ago
Migration_20250120_094614_App.php
1 year ago
Migration_20250501_114655_App.php
11 months ago
Migration_20260421_155908_App.php
3 months ago
Migration_20260515_120000_App.php
3 months ago
Migration_20260623_120000_App.php
1 month ago
Migration_20260805_120000_App.php
1 week ago
index.php
3 years ago
Migration_20260805_120000_App.php
42 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Migrations\App; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\Migrator\AppMigration; |
| 9 | use MailPoet\Settings\SettingsController; |
| 10 | use MailPoet\Subscribers\TrackingConsentController; |
| 11 | |
| 12 | class Migration_20260805_120000_App extends AppMigration { |
| 13 | /** |
| 14 | * The Yes/No toggle the three-state "Subscriber choice" setting replaces. |
| 15 | * Read once here and then ignored; the value is left in place so a downgrade |
| 16 | * still finds what it wrote. |
| 17 | */ |
| 18 | const LEGACY_TRACK_UNKNOWN = 'tracking.consent.track_unknown'; |
| 19 | |
| 20 | public function run(): void { |
| 21 | $settings = $this->container->get(SettingsController::class); |
| 22 | |
| 23 | // New installs start at the code default; there is nothing to carry over. |
| 24 | if (!$settings->hasSavedValue('db_version')) { |
| 25 | return; |
| 26 | } |
| 27 | |
| 28 | // A site that deliberately turned the old toggle off was running strict |
| 29 | // opt-in, so it keeps asking everyone. Every other existing site — the vast |
| 30 | // majority, who never touched it — moves to the new default and loses the |
| 31 | // manage-subscription control it never asked for. |
| 32 | $trackedUnknownSubscribers = (bool)$settings->get(self::LEGACY_TRACK_UNKNOWN, true); |
| 33 | |
| 34 | $settings->set( |
| 35 | TrackingConsentController::SETTING_SUBSCRIBER_CHOICE, |
| 36 | $trackedUnknownSubscribers |
| 37 | ? TrackingConsentController::CHOICE_TRACK_ALL |
| 38 | : TrackingConsentController::CHOICE_ASK_ALL |
| 39 | ); |
| 40 | } |
| 41 | } |
| 42 |