Skip to content

Commit

Permalink
changes to work with php8
Browse files Browse the repository at this point in the history
  • Loading branch information
tgloeggl committed Jun 27, 2024
1 parent 8362397 commit 135eb3c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions migrations/005_cronjob_refresh_series.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ public function description()
}
public function up()
{
$task_id = CronjobScheduler::registerTask(self::FILENAME, true);
$scheduler = CronjobScheduler::getInstance();
$task_id = $scheduler->registerTask(self::FILENAME, true);

// Schedule job to run every 30 minutes
if ($task_id) {
CronjobScheduler::schedulePeriodic($task_id, -30); // negative value means "every x minutes"
$scheduler->schedulePeriodic($task_id, -30); // negative value means "every x minutes"
}

//add mkdate columns for suitable tables
Expand Down Expand Up @@ -42,8 +43,9 @@ public function up()
}
function down()
{
$scheduler = CronjobScheduler::getInstance();
if ($task_id = CronjobTask::findByFilename(self::FILENAME)->task_id) {
CronjobScheduler::unregisterTask($task_id);
$scheduler->registerTask($task_id);
}


Expand Down
8 changes: 5 additions & 3 deletions migrations/007_cronjob_refresh_scheduled_events.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@ public function description()
}
public function up()
{
$task_id = CronjobScheduler::registerTask(self::FILENAME, true);
$scheduler = CronjobScheduler::getInstance();
$task_id = $scheduler->registerTask(self::FILENAME, true);

// Schedule job to run every 360 minutes
if ($task_id) {
CronjobScheduler::schedulePeriodic($task_id, -120); // negative value means "every x minutes"
$scheduler->schedulePeriodic($task_id, -120); // negative value means "every x minutes"
}
}
function down()
{
$scheduler = CronjobScheduler::getInstance();
if ($task_id = CronjobTask::findByFilename(self::FILENAME)->task_id) {
CronjobScheduler::unregisterTask($task_id);
$scheduler->unregisterTask($task_id);
}
}
}
8 changes: 5 additions & 3 deletions migrations/016_fix_cronjobs.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,18 @@ public function description()

public function up()
{
$scheduler = CronjobScheduler::getInstance();

foreach (self::FILENAMES as $filename) {

if (!$task_id = CronjobTask::findByFilename($filename)[0]->task_id) {
$task_id = CronjobScheduler::registerTask($filename, true);
$task_id = $scheduler->registerTask($filename, true);
}

// Schedule job to run every 60 minutes
if ($task_id) {
CronjobScheduler::cancelByTask($task_id);
CronjobScheduler::schedulePeriodic($task_id, -60); // negative value means "every x minutes"
$scheduler->cancelByTask($task_id);
$scheduler->schedulePeriodic($task_id, -60); // negative value means "every x minutes"
CronjobSchedule::findByTask_id($task_id)[0]->activate();
}
}
Expand Down

0 comments on commit 135eb3c

Please sign in to comment.