Hello! Thanks for this helpful module. Reporting a bug that I ran into, but for which I'm not sure my fix is the route to take, so I'd appreciate any feedback.

I installed this on a Drupal 8.9.x site and got the following error on all pages:
Error: Class 'Symfony\Contracts\EventDispatcher\Event' not found in include() (line 12 of /var/www/html/web/modules/contrib/permissionspolicy/src/Event/PolicyAlterEvent.php)

I can see that the class (and the entire file) was added as a fix for #3216634.

From what I can glean looking at other issues, the class currently in use will work in Drupal 9 and above, but not in Drupal 8, due to differences in Symfony versions. I patched it on my site by using Symfony\Component\EventDispatcher\Event instead. That said, that class is deprecated in Symfony 4.3 (per #3055198), so I don't know if there's a better alternative to use that works with both Drupal 8 and Drupal 9+. (I did find a Rules Webform issue suggesting that class is still available in D9, if that's useful to note.)

The patch that worked for my 8.9.x site is attached, but additional feedback from anyone who's more familiar with the Symfony parts of Drupal would be much appreciated – thanks!

Comments

KurtTrowbridge created an issue. See original summary.

gapple’s picture

Thanks for using the module, and creating an issue and patch!

I appear to have just been over-eager in paying attention to my IDE's deprecation warnings, since I was developing on D9, and your patch is the right solution to keep the module compatible with D8.9 (and Symfony ^3 || ^4). When the module drops support for D8.9, it can update to use the new Event class so that it's compatible with ^4.3 || ^5

  • gapple committed b6c4a2e on 1.0.x authored by KurtTrowbridge
    Issue #3222698 by KurtTrowbridge: Fix compatibility with Drupal 8.9 /...
gapple’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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