REDROOM
PHP 8.2.31
Path:
Logout
Edit File
Size: 2.54 KB
Close
/home/nshryvcy/himaltourism.com/wp-content/plugins/mailpoet/lib/Migrator/Migrator.php
Text
Base64
<?php declare(strict_types = 1); namespace MailPoet\Migrator; if (!defined('ABSPATH')) exit; class Migrator { const MIGRATION_STATUS_NEW = 'new'; const MIGRATION_STATUS_STARTED = 'started'; const MIGRATION_STATUS_COMPLETED = 'completed'; const MIGRATION_STATUS_FAILED = 'failed'; /** @var Repository */ private $repository; /** @var Runner */ private $runner; /** @var Store */ private $store; public function __construct( Repository $repository, Runner $runner, Store $store ) { $this->repository = $repository; $this->runner = $runner; $this->store = $store; } public function run(Logger $logger = null): void { $this->store->ensureMigrationsTable(); $migrations = $this->getStatus(); if ($logger) { $logger->logBefore($migrations); } foreach ($migrations as $migration) { if ($migration['unknown'] || $migration['status'] === self::MIGRATION_STATUS_COMPLETED) { continue; } if ($logger) { $logger->logMigrationStarted($migration); } $this->runner->runMigration($migration['name']); if ($logger) { $logger->logMigrationCompleted($migration); } } if ($logger) { $logger->logAfter(); } } /** @return array{name: string, status: string, started_at: string|null, completed_at: string|null, retries: int|null, error: string|null, unknown: bool}[] */ public function getStatus(): array { $defined = $this->repository->loadAll(); $processed = $this->store->getAll(); $processedMap = array_combine(array_column($processed, 'name'), $processed) ?: []; $all = array_unique(array_merge($defined, array_keys($processedMap))); sort($all); $status = []; foreach ($all as $name) { $data = $processedMap[$name] ?? []; $status[] = [ 'name' => $name, 'status' => $data ? $this->getMigrationStatus($data) : self::MIGRATION_STATUS_NEW, 'started_at' => $data['started_at'] ?? null, 'completed_at' => $data['completed_at'] ?? null, 'retries' => isset($data['retries']) ? (int)$data['retries'] : null, 'error' => $data && $data['error'] ? mb_strimwidth($data['error'], 0, 20, '…') : null, 'unknown' => !in_array($name, $defined, true), ]; } return $status; } private function getMigrationStatus(array $data): string { if (!isset($data['completed_at'])) { return self::MIGRATION_STATUS_STARTED; } return isset($data['error']) ? self::MIGRATION_STATUS_FAILED : self::MIGRATION_STATUS_COMPLETED; } }
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 10
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
Cli.php
4.47 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.php
0 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Logger.php
796 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Migration.php
1.72 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MigrationTemplate.php
543 B
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Migrator.php
2.54 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
MigratorException.php
1.24 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Repository.php
1.83 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Runner.php
1.39 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Store.php
2.25 KB
lrw-r--r--
2023-04-04 05:35:40
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).