Deprecate notices in tests.
Symfony\Component\EventDispatcher\Event is deprecated in drupal:9.1.0 and will be replaced by Symfony\Contracts\EventDispatcher\Event in drupal:10.0.0. A new Drupal\Component\EventDispatcher\Event class is available to bridge the two versions of the class. See https://www.drupal.org/node/3159012

deprecation are in D9.1 can't be done until 9.1 is lowest-supported version of Drupal core.

CommentFileSizeAuthor
#12 3241541-12-event.patch864 bytestr
#5 3241541-5.patch946 bytestr
#2 3241541-2.patch948 bytesaardwolf

Comments

AardWolf created an issue. See original summary.

aardwolf’s picture

StatusFileSize
new948 bytes
tr’s picture

Status: Active » Needs review
tr’s picture

The D9 test failures are branch failures not related to this patch.

The D8 test failures are because this patch is incompatible with D8 (and with D9.0).

I would suggest postponing this issue for a few months until D9.1 is the lowest-supported version of Drupal core, that way this fix won't break any existing sites.

tr’s picture

StatusFileSize
new946 bytes

Where did you see this deprecation error? I don't see it in any of the test output. I do see a similar warning when running drupal-check though.

Why did you do this:

-use Symfony\Component\EventDispatcher\Event;
+use Symfony\Contracts\EventDispatcher\Event;

instead of the backwards-compatible:

-use Symfony\Component\EventDispatcher\Event;
+use Drupal\Component\EventDispatcher\Event;

which is described in the change record?

The biggest problem with these changes to events is the backwards compatibility with all currently-supported versions of Drupal and with contrib. We should try to take advantage of the BC layer when possible.

Here is a new check. It removes the drupal-check warning for me.

Status: Needs review » Needs work

The last submitted patch, 5: 3241541-5.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

tr’s picture

Status: Needs work » Needs review

The results of #5 are the same as the branch test. But since these deprecations don't show up in the Drupal CI test results I wouldn't expect to see any differences when using the patch ...

aardwolf’s picture

https://api.drupal.org/api/drupal/vendor%21symfony%21event-dispatcher%21...
@deprecated since Symfony 4.3, use "Symfony\Contracts\EventDispatcher\Event" instead

tr’s picture

The relevant document is the change record at https://www.drupal.org/node/3159012 (including the references in the CR) which explains how Drupal is handling the changes between Symfony 4 and Symfony 5, and the plan for keeping backwards compatibility with existing code until Drupal 10.

berdir’s picture

Status: Needs review » Closed (duplicate)

All D10 deprecations have been fixed in #3267595: Support Drupal 10, the module is passing test against D10 now.

tr’s picture

Status: Closed (duplicate) » Active

And that D10 issue was done without reference to any of what I wrote above, so it did the wrong thing. This really should have been handled here where the discussion was.

The patch used the Contracts version of Event rather than the Drupal BC layer like the change record recommended:

Instead, to enable both forward compatibility with Symfony 5, and backwards compatibility with existing Drupal 9 contributed modules, a new Drupal\Component\EventDispatcher\Event class has been added. This should be used instead of Symfony\Component\EventDispatcher\Event when dispatching events.

tr’s picture

Status: Active » Needs review
StatusFileSize
new864 bytes

Re-roll of #5 to apply after the changes from #3267595: Support Drupal 10

mglaman’s picture

Status: Needs review » Reviewed & tested by the community

I missed that the other issue didn't use Drupal's compatibility layer for the event. +1 for this

  • mglaman committed efc5ae4 on 8.x-1.x authored by TR
    Issue #3241541 by TR, AardWolf: Deprecate notices in tests for Event...
mglaman’s picture

Status: Reviewed & tested by the community » Fixed

Committed, thanks @TR

Status: Fixed » Closed (fixed)

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