Access denied for cronjob lightweight with URL

Created on 8 May 2025, 7 days ago

Problem/Motivation

When I want to run the cronjob via URL, for example : https://mysite.com/scheduler/cron/123456789, I got an access denied from Drupal.

This is my log error : Path : /scheduler/cron/xxxx. Drupal\Core\Http\Exception\CacheableAccessDeniedHttpException: in Drupal\Core\Routing\AccessAwareRouter->checkAccess() (.../web/core/lib/Drupal/Core/Routing/AccessAwareRouter.php).

I also noticed that the value of the state in table "key_value" is always "null", so this code in the controller is not giving access.

public function access($cron_key) {
    $valid_cron_key = $this->state()->get(SchedulerCronForm::CRON_ACCESS_KEY, '');
    return AccessResult::allowedIf($valid_cron_key == $cron_key);
  }

Can you help me?

Thanks.

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇨🇦Canada dsim01

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024