Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291950

Allow symfony/event-dispatcher 4+ to be installed in Drupal 8

$
0
0

Problem/Motivation

With the release of Symfony 4.3 the event dispatching changed: https://symfony.com/blog/new-in-symfony-4-3-simpler-event-dispatching
This already causes issues for drupal regarding the upgrade to Symfony 4.x or 5, for example in
#3055194: [Symfony 5] The signature of the "Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher::dispatch()" method should be updated to "dispatch($event, string $eventName = null)", not doing so is deprecated since Symfony 4.3. and #3055180: [META] Make Drupal 8 work with Symfony 5 (along with Symfony 3 and 4).

But Drupal isn't the only system that has to deal with that. Third party libraries drupal leverages directly or via contributed modules need to adapt to this change. Therefore the symfony project itself provides a migration path by decorating the event dispatcher with LegacyEventDispatcherProxy as described in blog post linked above.

This LegacyEventDispatcherProxy has been released as part of symfony/event-dispatcher 4.3.0.
The event-dispatcher has no dependency to any 4.3 versions of other symfony components but is backward compatible to symfony 3.4 which we use in Drupal 8:

"require-dev": {
        "symfony/dependency-injection": "~3.4|~4.0",
        "symfony/expression-language": "~3.4|~4.0",
        "symfony/config": "~3.4|~4.0",
        "symfony/http-foundation": "^3.4|^4.0",
        "symfony/service-contracts": "^1.1",
        "symfony/stopwatch": "~3.4|~4.0",
        "psr/log": "~1.0"
    },
"conflict": {
        "symfony/dependency-injection": "<3.4"
    },

See https://github.com/symfony/event-dispatcher/blob/4.3/composer.json

But no matter how we deal with the migration within the Drupal project, we already have a critical issue.
As an example, the upcoming 5.1.0 release of the solarium library implements the migration path as recommended by the symfony project:
https://github.com/solariumphp/solarium/pull/690

This library is required by the search_api_solr module that has more than 14,000 active 8.x installations already. search_api_solr injects the Drupal event dispatcher into the solarium Solr Client.

From my point that works perfectly fine. But Drupal prohibits the update because of this version constraint:
"symfony/event-dispatcher": "~3.4.0",

This version constraint is simply wrong as Drupal doesn't use the event dispatcher provided by this module but only it's EventDispatcherInterface which has been kept compatible in symfony 4.x.

So the current situation is that Drupal blocks feature and security updates of third party libraries which use symfony event dispatching and adopting to symfony event dispatching changes in the proposed and compatible way. That has to be considered as critical.

Proposed resolution

Adjust the version requirement like this:
"symfony/event-dispatcher": "~3.4.0|~4.0"
Afterwards composer will resolve the correct combination of module versions without upgrading the other symfony components at all.
Drupal doesn't use the request dispatcher at all but only implements the EventDispatcherInterface which remains the same in Symfony 4.x compared to 3.4.

ProsCons
++ Symfony itself declares event-dispatcher 4.3 to be compatible with symfony 3.4 in general- event-dispatcher 4.3 requires PHP >= 7.1 (but for PHP 7.0 the situation doesn't change and composer takes care of this fact)
++ third party libs that follow Symfony's event-dispatcher >= 4.3 migration concept could be used again- if for whatever reason custom code use the symfony event-dispatcher directly they need to follow symfony's migration path or ensure that dependency for event-dispatcher 3.4 is declared correctly in the project's composer.json or even better use Drupal's event dispatcher implementation
++ future security updates of such third party libs must not lead to Drupal specific forks just to backport the fixes
+ contrib modules aren't blocked to leverage new features of newer versions of third party libs
+ we'll discover contrib modules that erroneously use symfony's event dispatcher instead of Drupal's

Remaining tasks

Just apply the patch.

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Todo, maybe not required at all.


Viewing all articles
Browse latest Browse all 291950

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>