Server IP : 192.158.238.246 / Your IP : 18.116.60.124 Web Server : LiteSpeed System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64 User : jenniferflocom ( 1321) PHP Version : 8.1.32 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /proc/7779/task/7779/cwd/plugins/give/src/Framework/Migrations/Actions/ |
Upload File : |
<?php namespace Give\Framework\Migrations\Actions; use Exception; use Give\Framework\Migrations\Contracts\Migration; use Give\Framework\Migrations\MigrationsRunner; class ManuallyRunMigration { /** * Manually runs the migration and then marks the migration as finished if successful * * @since 2.9.2 * * @param Migration $migration * */ public function __invoke(Migration $migration) { global $wpdb; $wpdb->query('START TRANSACTION'); try { $migration->run(); } catch (Exception $exception) { $wpdb->query('ROLLBACK'); give_record_log('Migration Failed', print_r($exception, true), 0, 'update'); give()->notices->register_notice( [ 'id' => 'migration-failure', 'description' => sprintf( '%1$s <a href="https://givewp.com/support/">https://givewp.com/support</a>', esc_html__( 'There was a problem running the migrations. Please reach out to GiveWP support for assistance:', 'give' ) ), ] ); throw $exception; } // Commit transaction if successful $wpdb->query('COMMIT'); $this->updateMigrationsSetting($migration::id()); } /** * Updates the completed migrations to include the migration if not yet included * * @since 2.9.2 * * @param string $migrationId */ private function updateMigrationsSetting($migrationId) { $completedMigrations = get_option(MigrationsRunner::MIGRATION_OPTION); if (in_array($migrationId, $completedMigrations, true)) { return; } $completedMigrations[] = $migrationId; update_option(MigrationsRunner::MIGRATION_OPTION, $completedMigrations); } }