Uname: Linux webm012.cluster130.gra.hosting.ovh.net 5.15.167-ovh-vps-grsec-zfs-classid #1 SMP Tue Sep 17 08:14:20 UTC 2024 x86_64
Software: Apache
PHP version: 8.0.30 [ PHP INFO ] PHP os: Linux
Server Ip: 145.239.37.162
Your Ip: 216.73.216.190
User: dreampi (1009562) | Group: users (100)
Safe Mode: OFF
Disable Function:
_dyuweyrj4,_dyuweyrj4r,dl

name : Migration_20230111_120000.php
<?php declare(strict_types = 1);

namespace MailPoet\Migrations\Db;

if (!defined('ABSPATH')) exit;


use MailPoet\Entities\SegmentEntity;
use MailPoet\Entities\SettingEntity;
use MailPoet\Migrator\DbMigration;
use MailPoetVendor\Doctrine\DBAL\ArrayParameterType;

class Migration_20230111_120000 extends DbMigration {
  public function run(): void {
    $segmentsTable = $this->getTableName(SegmentEntity::class);
    $settingsTable = $this->getTableName(SettingEntity::class);
    $columnName = 'display_in_manage_subscription_page';

    if ($this->columnExists($segmentsTable, $columnName)) {
      return;
    }

    $this->connection->executeStatement("
      ALTER TABLE {$segmentsTable}
      ADD {$columnName} tinyint(1) NOT NULL DEFAULT 0
    ");

    $subscriptionSetting = $this->connection->fetchOne("
      SELECT value
      FROM {$settingsTable}
      WHERE name = ?", ['subscription']);
    $subscriptionSetting = is_string($subscriptionSetting) ? unserialize($subscriptionSetting) : [];
    $subscriptionSetting = is_array($subscriptionSetting) ? $subscriptionSetting : [];
    $segmentIds = $subscriptionSetting['segments'] ?? [];
    if ($segmentIds) {
      // display only segments from settings.subscription.segments
      $this->connection->executeStatement("
        UPDATE {$segmentsTable}
        SET {$columnName} = 1
        WHERE id IN (?)
      ", [$segmentIds], [ArrayParameterType::INTEGER]);

      $subscriptionSetting['segments'] = [];
      $this->connection->executeStatement(
        "
        UPDATE {$settingsTable}
        SET value = ?
        WHERE name = ?",
        [
          serialize($subscriptionSetting),
          'subscription',
        ]
      );
    } else {
      $this->connection->executeStatement("
        UPDATE {$segmentsTable}
        SET {$columnName} = 1
        WHERE type = ?
      ", [SegmentEntity::TYPE_DEFAULT]);
    }
  }
}
© 2026 GrazzMean-Shell