Problem/Motivation

The upgrade of Scheduler 2.1.0 to 2.2.0 creates an issue with content planner 8.x-1.2.
Does it possible to avoid the upgrade of scheduler when they are other modules that uses it?

Issue fork scheduler-3498553

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

jonathan1055’s picture

There was not much change in the 2.2.0 release except to make it compatible with PHP8.4. There is nothing to force you to upgrade a module. It depends on your own procedures and how your site is set up. I can't help much more than that.

Maybe talk to the maintainers of the project that has the problem, and see if it can be fixed or if they can specify the maximum version of Scheduler that it is compatible with.

jonathan1055’s picture

Title: Sheduler upgrade 2.2.0 and content planer 8.x-1.2 » Sheduler upgrade 2.2.0 and content planner 8.x-1.2
Status: Active » Closed (duplicate)

I am closing this as a duplicate, because you also asked the same thing in Content Planner #3498530: Not compatible with Scheduler 2.2.0 and that issue has more detail.

jonathan1055’s picture

Component: Miscellaneous » Code
Category: Support request » Task
Status: Closed (duplicate) » Active

The event aliases we moved to .module in #3476369: Argument #1 ($event) must be of type Drupal\scheduler\SchedulerEvent, Drupal\scheduler\Event\SchedulerEvent given But there are scenarios where a 3rd-party module has implemeted an eventSubscriber and the .module file is not loaded early in the process. Running a Database update is one case.

So Scheduler might be able to make things easier by re-instating the /src class files which contain the alias. We will need to investigate if there are problems in having them defined in both places. Or we may be able to use class_exists in the .module to prevent an error.

rajab natshah’s picture

Attached a static scheduler--2025-01-17--3498553--mr-223.patch file for MR223 by Jonathan up to this point. ( Thanks, Jonathan!)
To be used with Composer Patches

jonathan1055’s picture

Hi rajab natshah
Let me know how you get on. Does this solve your problem?
I can commit this and quickly release 2.2.1 if that will help you, providing that this is the correct fix and no side-effects.

dieterholvoet’s picture

dieterholvoet’s picture

@rajab natshah could you try out the new MR? Since it changes composer.json, just applying it as a patch won't work. You need to add the following to the repositories in composer.json:

{
  "type": "vcs",
  "url": "https://git.drupalcode.org/issue/scheduler-3498553.git"
}

Make sure to add it before the https://packages.drupal.org/8 repository. Afterwards, run composer require drupal/scheduler:"dev-3498553-autoload-file as 2.1.0".

Never mind, autoloading class_aliases.php doesn't work either because when that file is autoloaded, the classes that are being aliased aren't autoloaded yet.

dieterholvoet’s picture

Title: Sheduler upgrade 2.2.0 and content planner 8.x-1.2 » BC class aliases are not always being loaded
Category: Task » Bug report
dieterholvoet’s picture

If I understand it correctly:

  • The scheduler.module file is not always loaded, e.g. before a drush updb, so it's not enough to put the aliases there.
  • The SchedulerEvent and SchedulerEvents aren't always autoloaded either. I have a suspicion that it has to do with the way the Composer autoloader is built. For example, as described here, when you dump the autoloader using --classmap-authoritative files with only a class_alias statement are not autoloaded.

The best option might be to - as you said - add these class_alias statements to both places and prefix them with @ to suppress errors. A bit dirty, but I don't know if there's a better way.

jonathan1055’s picture

Thanks @dieterholvoet for working on this, and for the extra ideas. There is also more explanation on the issue linked from the one you added #3414766: Resolve edge case where kernel event subscribers crash because class aliases aren't defined yet

I also have not been able to recreate the error, and I need to be able to do that to check that any change we make solves the problem. I have tried

  • Fresh install of core 10.4 with Scheduler 2.0.1 and SCMI 3.0.3 and Content Planner 8.x-1.2
  • Enable article for scheduling and add it to the default moderation workflow
  • Update Scheduler to 2.2.0 and run drush updb

There must be more to it than this.

I've added @ to the class_alias() statements just for safety, but it is all a bit guess-work without being able to replicate the problem.

dieterholvoet’s picture

@rajab natshah in #3498530: Not compatible with Scheduler 2.2.0 you mentioned that this happens in a CI pipeline. Do you have a composer dump-autoload somewhere in that pipeline and if so, what options are being passed? Or is this also happening in environments where you didn't explicitly dump the autoloader?

rajab natshah’s picture

Dieter, with you. Thanks for following.

Sometimes after drush site-install, the modules might not be fully enabled yet, or something like scheduler.module isn’t loaded properly. A quick drush cr right after can save trouble later!

Not using dump-autoload in the CI
Using the following in the composer

    "drupal/content_planner": "~1",
    "drupal/scheduler": "~2",

Having this simplified job

drush site-install  --locale="en" install_configure_form.enable_update_status_emails=NULL -vvv
drush pm:enable scheduler --yes
drush pm:enable content_planner --yes
drush cache:rebuild

Using MR223 to minimize errors

dieterholvoet’s picture

Status: Active » Reviewed & tested by the community

I have just been (accidentally) able to reproduce this issue when updating a project with scheduler and scheduler_content_moderation_integration. I can confirm that the current state of the MR fixes the issue. Not the cleanest fix, but good enough for now I'd say, because I have no idea how else to fix this.

jonathan1055’s picture

I have just been (accidentally) able to reproduce this issue

That's good to hear. What info do you have about the update? here are some questions:

  1. what core version?
  2. what was the starting version of Scheduer?
  3. what was the starting version of SCMI?
  4. did you also have Content Planner module?
  5. how many other updates were there? was it due to batching up some updates in groups?
  6. were you doing it via website UI or drush or another way?

I am tempted to merge this MR but I still do not know if there could be any side-effects to having the aliases defined twice.

dieterholvoet’s picture

  1. Core version 9.5.11
  2. Scheduler 1.5.0 to 2.2.0
  3. SCMI 1.4.0 to 3.0.3
  4. No Content Planner
  5. Lots of updates, core & all contrib
  6. Drush
jonathan1055’s picture

Thanks @dieterholvoet. With that info I did manage to replicate the error, but it was only for the duration of the database update. The message showed probably when Scheduler was updated earlier in the list before SCMI. But after the update was complete there was no lingering problem and the site functioned fine. However, it seems there is no downside to having the aliases declared twice, so I'm going to commit this then release 2.2.1

  • jonathan1055 committed a1c56c25 on 2.x
    Issue #3498553 by jonathan1055, dieterholvoet, rajab natshah: BC event...
jonathan1055’s picture

Issue summary: View changes
Status: Reviewed & tested by the community » Fixed

Merged. Thank you all for your contributions here.

I have now released 2.2.1 with this fix
https://www.drupal.org/project/scheduler/releases/2.2.1

Status: Fixed » Closed (fixed)

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