From c48c7efd402119477e81d09fee4a1f6eb9348258 Mon Sep 17 00:00:00 2001 From: Yury Pikhtarev Date: Fri, 20 Jun 2025 04:28:48 +0400 Subject: [PATCH] refactor(cron): remove demo_mode.php cron job and related functionality - Deleted the demo_mode.php cron job file, which was responsible for managing demo mode operations. - Added a migration to remove the demo_mode.php entry from the bb_cron table, ensuring a clean database state. - Updated the initial schema migration comment to reflect the creation of essential database schema for fresh installations. --- library/includes/cron/jobs/demo_mode.php | 44 ------------------- migrations/20250619000001_initial_schema.php | 2 +- .../20250620001449_remove_demo_mode.php | 44 +++++++++++++++++++ 3 files changed, 45 insertions(+), 45 deletions(-) delete mode 100644 library/includes/cron/jobs/demo_mode.php create mode 100644 migrations/20250620001449_remove_demo_mode.php diff --git a/library/includes/cron/jobs/demo_mode.php b/library/includes/cron/jobs/demo_mode.php deleted file mode 100644 index ec02cc498..000000000 --- a/library/includes/cron/jobs/demo_mode.php +++ /dev/null @@ -1,44 +0,0 @@ -clean(); -foreach (config()->get('cache.engines') as $cache_name => $cache_val) { - CACHE($cache_name)->rm(); -} - -// Drop tables & Insert sql dump -$temp_line = ''; -foreach (file($dump_path) as $line) { - if (str_starts_with($line, '--') || $line == '') { - continue; - } - - $temp_line .= $line; - if (str_ends_with(trim($line), ';')) { - if (!DB()->query($temp_line)) { - $cron_runtime_log[] = date('Y-m-d H:i:s') . " -- Error performing query: " . $temp_line . " | " . DB()->sql_error()['message']; - } - $temp_line = ''; - } -} diff --git a/migrations/20250619000001_initial_schema.php b/migrations/20250619000001_initial_schema.php index cc41b3203..cd36bb326 100644 --- a/migrations/20250619000001_initial_schema.php +++ b/migrations/20250619000001_initial_schema.php @@ -1,7 +1,7 @@ table('bb_cron') + ->getAdapter() + ->execute("DELETE FROM bb_cron WHERE cron_script = 'demo_mode.php'"); + } + + /** + * Migrate Down. + */ + public function down(): void + { + // Restore the demo_mode.php cron job to bb_cron table + $this->table('bb_cron')->insert([ + 'cron_active' => 1, + 'cron_title' => 'Demo mode', + 'cron_script' => 'demo_mode.php', + 'schedule' => 'daily', + 'run_day' => null, + 'run_time' => '05:00:00', + 'run_order' => 255, + 'last_run' => '1900-01-01 00:00:00', + 'next_run' => '1900-01-01 00:00:00', + 'run_interval' => null, + 'log_enabled' => 1, + 'log_file' => 'demo_mode_cron', + 'log_sql_queries' => 1, + 'disable_board' => 1, + 'run_counter' => 0 + ])->save(); + } +}