Skip to content

Commit

Permalink
Cron: use component bootstrap/entry point for runner
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen committed Jan 3, 2025
1 parent 87dce32 commit 6b57615
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
8 changes: 5 additions & 3 deletions cli/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@

declare(strict_types=1);

chdir(__DIR__);
chdir('..');
require_once __DIR__ . '/../vendor/composer/vendor/autoload.php';
require_once __DIR__ . '/../artifacts/bootstrap_default.php';

require_once './vendor/composer/vendor/autoload.php';
ilContext::init(ilContext::CONTEXT_CRON);

entry_point('ILIAS Legacy Initialisation Adapter');

$cron = new ILIAS\Cron\CLI\App(
new ILIAS\Cron\CLI\Commands\RunActiveJobsCommand()
Expand Down
8 changes: 1 addition & 7 deletions components/ILIAS/Cron/classes/class.ilCronJobEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,9 @@ public function __construct(private readonly CronJob $job, array $record, privat
*/
private function mapRecord(CronJob $job, array $record): void
{
if (! array_key_exists('job_id', $record)) {
//TODO: remove!
var_dump($record);
die();
}
//$this->jobId = (string) $record['job_id'];
//$this->component = (string) $record['component'];
$this->jobId = $job->getId();
$this->component = $job->getComponent();

$this->scheduleType = is_numeric($record['schedule_type']) ? CronJobScheduleType::tryFrom((int) $record['schedule_type']) : null;
$this->scheduleValue = (int) $record['schedule_value'];
$this->jobStatus = (int) $record['job_status'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public function __construct(

public function getJobInstanceById(string $id): ?ilCronJob
{

$jobs_data = $this->getCronJobData($id);
if ($jobs_data !== [] && $jobs_data[0]['job_id'] === $id) {
return $this->getJobInstance(
Expand Down Expand Up @@ -116,8 +115,6 @@ public function registerJob(
if (!$this->db->tableExists('cron_job')) {
return;
}

//$job = $this->getJobInstance($a_id, $a_component, $a_class, true);
$job = $this->getJobInstance($a_id, $a_component, $a_class);
if ($job) {
$this->createDefaultEntry($job, $a_component, $a_class, $a_path);
Expand Down
7 changes: 0 additions & 7 deletions components/ILIAS/Cron/classes/class.ilCronStartUp.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ public function __construct(
private readonly string $username,
?ilAuthSession $authSession = null
) {
/** @noRector */
ilContext::init(ilContext::CONTEXT_CRON);

// TODO @see mantis 20371: To get rid of this, the authentication service has to provide a mechanism to pass the client_id
$_GET['client_id'] = $this->client;
ilInitialisation::initILIAS();

if (null === $authSession) {
global $DIC;
$authSession = $DIC['ilAuthSession'];
Expand Down

0 comments on commit 6b57615

Please sign in to comment.