Problem/Motivation

Ultimate cron implements hook_modules_installed.
As mentioned in #3186352-19: Module is incompatible with Drupal Configuration Sync processes, we could improve the implementation by avoiding calling \Drupal::service('ultimate_cron.discovery')->discoverCronJobs() during configuration import.
Also, not fully tested, when installing a site from an installation profile using existing configuration (for example via drush site:install --existing-config), the Ultimate Cron module triggers cron job discovery during configuration synchronization. During config sync, configuration entities may not yet be fully available, which can lead to fatal errors or broken installs.

Steps to reproduce

Proposed resolution

Update ultimate_cron_modules_installed() to respect the $is_syncing flag and skip cron job discovery during configuration synchronization.

function ultimate_cron_modules_installed($modules, $is_syncing) {
  if (!$is_syncing) {
    \Drupal::service('ultimate_cron.discovery')->discoverCronJobs();
  }
}

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

tuwebo created an issue. See original summary.

tuwebo’s picture

Assigned: tuwebo » Unassigned
Status: Active » Needs review

I've added the check to avoid calling \Drupal::service('ultimate_cron.discovery')->discoverCronJobs(); during sinchronization. Tests seem to be passing for previous version and failing for this one, but I think it is not related to this particular change. So I am moving it to Needs review.

berdir’s picture

can we remove hook_install() completely which also doesn't check this as I think hook_modules_installed() is also called for itself?

primsi made their first commit to this issue’s fork.

berdir’s picture

Status: Needs review » Needs work

Tests contain explicit calls to the install hook, that needs to be updated.

primsi’s picture

Status: Needs work » Needs review

  • berdir committed 72f026c2 on 8.x-2.x authored by tuwebo
    feat: #3564853 Prevent cron job discovery in hook_modules_installed()...
berdir’s picture

Status: Needs review » Fixed

Merging.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.