- Issue created by @nkoporec
- 🇸🇮Slovenia nkoporec Slovenia
This will require a new major release since its not BC, just putting it here for now and let people test it before we merge this.
- 🇧🇪Belgium dieterholvoet Brussels
Instead of replacing the class I would add a
class_exists
check, that way we can keep it backwards compatible. Also, please start a MR, patches have been deprecated for a while on Drupal.org. - 🇮🇳India zartab farooquee
The error occurs because the SchedulerEvent class was moved from Drupal\scheduler\SchedulerEvent to Drupal\scheduler\Event\SchedulerEvent in a newer version of the Scheduler module.
Update this old namespace use Drupal\scheduler\SchedulerEvent; // to New namespace use Drupal\scheduler\Event\SchedulerEvent;
- 🇧🇪Belgium dieterholvoet Brussels
The src/SchedulerEvent.php file in the scheduler module contains a class_alias statement that should prevent this error, but it seems like that file isn't being autoloaded. If I copy-paste that statement to the start of the subscriber file, the error doesn't occur. Maybe we could try manually instructing Composer to autoload that file.
- 🇧🇪Belgium dieterholvoet Brussels
Here's a simpler idea: let's add the class aliases to the
scheduler.module
file. Drupal core does this as well, insdc.module
. - 🇬🇧United Kingdom jonathan1055
Hi dieterholvoet
Please can you give a link to the core code where there is the example of doing this.Also I think the version of Scheduler you mean for this change is 2.x ? I guess that this issue's version 8.x-1.x was a left-over from when it was raised in the Content Planner queue.
- 🇧🇪Belgium dieterholvoet Brussels
Yes, I changed the version. Here's sdc.module.
- 🇬🇧United Kingdom jonathan1055
I think you are doing some work on this, as I see you created the issue fork 30 mins ago. The version was 8.x-1.x then, so you will need to update the fork to 2.x
- 🇬🇧United Kingdom jonathan1055
This looks good, thanks for doing the changes.
I am going to add test coverage for the aliases, as that was not included before. - 🇬🇧United Kingdom jonathan1055
The tests work as expected. PHPUnit passes with the aliases moved, and there is one more test showing in the Events group.
The test only changes job, that is the new test but without the changes to the non-test code, failed as expected with the same error you got:
TypeError: Drupal\scheduler_api_legacy_test\EventSubscriber::apiTestNodePrePublish(): Argument #1 ($event) must be of type Drupal\scheduler\SchedulerEvent, Drupal\scheduler\Event\SchedulerEvent given
-
jonathan1055 →
committed 46b1988b on 2.x authored by
dieterholvoet →
Issue #3476369 by dieterholvoet, jonathan1055, zartab farooquee:...
-
jonathan1055 →
committed 46b1988b on 2.x authored by
dieterholvoet →
- 🇬🇧United Kingdom jonathan1055
Merged and fixed.
Can you use the -dev version of Scheduler to test this?
I could also make a new release soon, if it is urgent to fix your site? - 🇧🇪Belgium dieterholvoet Brussels
Not urgent for me! I'm sure any other people can use the patch until a new release is created.
- 🇬🇧United Kingdom jonathan1055
OK thanks for the feedback. This is the only bug fixed since 2.1.0 released 15 August , so I don't think we need a new release just yet
Automatically closed - issue fixed for 2 weeks with no activity.