mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-22 14:23:57 -07:00
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.
This commit is contained in:
parent
5af6a9433a
commit
c48c7efd40
3 changed files with 45 additions and 45 deletions
|
@ -1,44 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier – Bull-powered BitTorrent tracker engine
|
||||
*
|
||||
* @copyright Copyright (c) 2005-2025 TorrentPier (https://torrentpier.com)
|
||||
* @link https://github.com/torrentpier/torrentpier for the canonical source repository
|
||||
* @license https://github.com/torrentpier/torrentpier/blob/master/LICENSE MIT License
|
||||
*/
|
||||
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
set_time_limit(600);
|
||||
|
||||
global $cron_runtime_log;
|
||||
|
||||
$dump_path = BB_ROOT . 'install/sql/mysql.sql';
|
||||
|
||||
if (!IN_DEMO_MODE || !is_file($dump_path) || !is_readable($dump_path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clean cache & datastore
|
||||
$datastore->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 = '';
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/**
|
||||
* TorrentPier Initial Schema Migration
|
||||
* Converts install/sql/mysql.sql to Phinx migration
|
||||
* Creates essential database schema for fresh installations
|
||||
*/
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
|
44
migrations/20250620001449_remove_demo_mode.php
Normal file
44
migrations/20250620001449_remove_demo_mode.php
Normal file
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
use Phinx\Migration\AbstractMigration;
|
||||
|
||||
final class RemoveDemoMode extends AbstractMigration
|
||||
{
|
||||
/**
|
||||
* Migrate Up.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
// Delete the demo_mode.php cron job from bb_cron table
|
||||
$this->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();
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue