- Issue created by @dpalicepeio@drupbuilder.org
- 🇫🇷France dpalicepeio@drupbuilder.org
Hello,
It seems that the a single update of code of content planer version 8.x-1.2 could work with new version 2.2.0.
I bypass the issue after having applied a change on src/EventSubscriber/SchedulerPublishSubScriber.php
The change consists in adding the two class_alias lines marked by a + (not part of the code, but only to show that line is added)<?php
namespace Drupal\content_calendar\EventSubscriber;
use Drupal\Core\Extension\ModuleHandlerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+ class_alias('Drupal\scheduler\Event\SchedulerEvent', 'Drupal\scheduler\SchedulerEvent');
+ class_alias('Drupal\scheduler\Event\SchedulerNodeEvents', 'Drupal\scheduler\SchedulerEvents');
use Drupal\scheduler\SchedulerEvent;
use Drupal\scheduler\SchedulerEvents; - 🇬🇧United Kingdom jonathan1055
This issue was also reported in the Scheduler queue 💬 Sheduler upgrade 2.2.0 and content planer 8.x-1.2 Active but it had no details. We don't need a duplicate.
Here are the changes in Scheduler 2.2.0 → and the event aliases were moved in 🐛 TypeError: Drupal\content_calendar\EventSubscriber\SchedulerPublishSubScriber::onNodePublish(): Argument #1 ($event) must be of type Drupal\scheduler\SchedulerEvent, Drupal\scheduler\Event\SchedulerEvent given in Drupal\content_calendar\EventSubscriber\Sc Active . There should not have been any disruption, so apologies if we did it the wrong way. They were moved out of /src/ and into .module, and @dieterholvoet and @nkoporec (two of the maintainers of Content Planner) were involved in that issue. So I'm sure we can sort it out.
- 🇬🇧United Kingdom jonathan1055
Does this happen during the update process, or is it afterwards? Can you find out if the scheduler.module file is being loaded, as that is where @dieterholvoet suggested that we moved the aliases.
Just had a quick look at the project source, and I notice that you have scheduler as a dependency in content_planner.info.yml file but not in the composer.json. Can I suggest you add that dependency then try this again. Some processes may use only the composer.json info, and when you were using Scheduler 2.1 the files were automativcally findable due to to the source file names, so you did not notice that the dependency was missing from composer.json. I hope this is the answer, as that's a nice simple solution.
- 🇯🇴Jordan Rajab Natshah Jordan
On a new install or when running
drush cr
ordrush updb
. - 🇧🇪Belgium dieterholvoet Brussels
I don't think adding the dependency to
composer.json
is going to make a difference. The Drupal packager does that automatically:If a module does not have any dependencies, or the dependencies are solely other Drupal modules, then a composer.json is not required. However, having a composer.json does not have a negative impact either.
Regardless of whether or not a developer has a composer.json file, their Drupal module dependencies must still be expressed in their .info.yml files so that Drupal can ensure that the correct modules are enabled.
Source: Add a composer.json file →
@rajab natshah what do you mean by 'on a new install'? Are you enabling both modules for the first time, or is one of them already enabled? And which exact versions are you installing?
- 🇧🇪Belgium dieterholvoet Brussels
We could also change the namespaces to the new ones and bump the minimum required Scheduler version. But still, probably better to figure out what exactly is going wrong here.
- 🇯🇴Jordan Rajab Natshah Jordan
Noticed the following issue
#3498828: Scheduler 2.2.0 breaks code - Drupal\scheduler\SchedulerEvents not found →I have a CI setup that performs a fresh installation of a profile, which enables them.
Also when updating with"drupal/content_planner": "~1", "drupal/scheduler": "~2", "drupal/scheduler_content_moderation_integration": "~3", "drupal/content_moderation_notifications": "~3",
Error: Class "Drupal\scheduler\SchedulerEvents" not found in /app/web/modules/contrib/content_planner/modules/content_calendar/src/EventSubscriber/SchedulerPublishSubScriber.php on line 37 #0 /app/web/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterEventSubscribersPass.php(37): Drupal\content_calendar\EventSubscriber\SchedulerPublishSubScriber::getSubscribedEvents() #1 /app/vendor/symfony/dependency-injection/Compiler/Compiler.php(80): Drupal\Core\DependencyInjection\Compiler\RegisterEventSubscribersPass->process() #2 /app/vendor/symfony/dependency-injection/ContainerBuilder.php(767): Symfony\Component\DependencyInjection\Compiler\Compiler->compile() #3 /app/web/core/lib/Drupal/Core/DrupalKernel.php(1448): Symfony\Component\DependencyInjection\ContainerBuilder->compile() #4 /app/web/core/lib/Drupal/Core/DrupalKernel.php(971): Drupal\Core\DrupalKernel->compileContainer() #5 /app/web/core/lib/Drupal/Core/DrupalKernel.php(515): Drupal\Core\DrupalKernel->initializeContainer() #6 /app/vendor/drush/drush/src/Boot/DrupalBoot8.php(209): Drupal\Core\DrupalKernel->boot() #7 /app/vendor/drush/drush/src/Boot/BootstrapManager.php(211): Drush\Boot\DrupalBoot8->bootstrapDrupalFull() #8 /app/vendor/drush/drush/src/Boot/BootstrapManager.php(397): Drush\Boot\BootstrapManager->doBootstrap() #9 /app/vendor/drush/drush/src/Application.php(219): Drush\Boot\BootstrapManager->bootstrapMax() #10 /app/vendor/drush/drush/src/Application.php(185): Drush\Application->bootstrapAndFind() #11 /app/vendor/symfony/console/Application.php(266): Drush\Application->find() #12 /app/vendor/symfony/console/Application.php(175): Symfony\Component\Console\Application->doRun() #13 /app/vendor/drush/drush/src/Runtime/Runtime.php(110): Symfony\Component\Console\Application->run() #14 /app/vendor/drush/drush/src/Runtime/Runtime.php(40): Drush\Runtime\Runtime->doRun() #15 /app/vendor/drush/drush/drush.php(140): Drush\Runtime\Runtime->run() #16 /app/bin/drush.php(119): include('...') #17 {main} Error: Class "Drupal\scheduler\SchedulerEvents" not found in Drupal\content_calendar\EventSubscriber\SchedulerPublishSubScriber::getSubscribedEvents() (line 37 of /app/web/modules/contrib/content_planner/modules/content_calendar/src/EventSubscriber/SchedulerPublishSubScriber.php). [warning] Drush command terminated abnormally.
- 🇯🇴Jordan Rajab Natshah Jordan
Feels like this should be fixed in the Scheduler module, not in Content Planner.
💬 Sheduler upgrade 2.2.0 and content planer 8.x-1.2 Active
with the MR223 by JonathanI used the following patch to continue debugging upgrades:
"patches": { "drupal/scheduler": { "Issue #3498553: Sheduler upgrade 2.2.0 and content planner 8.x-1.2": "https://git.drupalcode.org/project/scheduler/-/merge_requests/223.diff" } }
https://git.drupalcode.org/project/scheduler/-/merge_requests/223/diffs
- 🇯🇴Jordan Rajab Natshah Jordan
Once Content Planner ~2.0 is released, I’ll switch to it.
from"drupal/content_planner": "~1", "drupal/scheduler": "~2",
to
"drupal/content_planner": "~2", "drupal/scheduler": "~2",
- 🇧🇪Belgium dieterholvoet Brussels
#12 confirms that this is not an issue with content_planner. Let's investigate this further in 💬 Sheduler upgrade 2.2.0 and content planer 8.x-1.2 Active .