Problem/Motivation
This issue was initially reported in #3501146: Installation fails if cron runs in parallel. During the Drupal/Drupal CMS installation, the process fails if an automated cron job is triggered and executed in parallel to the installation. This can occur when certain routes, like CSS/JS asset paths, are accessed during the installation batch process.
Steps to reproduce
- Begin the installation of the Drupal Standard profile via the installation interface.
- During the installation batch process, manually access any CSS/JS asset route, such as:
<YOUR_DOMAIN>/sites/default/files/css/test.css
- This access will trigger automated_cron, potentially causing the installation to fail.
Proposed resolution
As the Cron execution was removed during the installation by #2422681: Remove the automatic cron run from the installer, if we introduce a validation step to ensure the cron job is only executed after the installation is fully completed. This can be done by modifying the run()
function in Cron.php
to include a check for the install_time
state variable.
Proposed code snippet:
// We can only run cron if the installation has been completed.
if (!$this->state->get('install_time')) {
$this->logger->warning('Attempting to run cron while the website is not fully installed.');
return FALSE;
}
This adjustment will prevent cron jobs from running prematurely during the installation process and help avoid failures.