Problem/Motivation
symfony_mailer alongside the eca_ui module produces a crash, because eca_ui defines a service which might has undefined use statements.
eca_ui defines the service webprofiler.eca_ui that is implemented by the class Drupal\eca_ui\DataCollector\EcaDataCollector which uses Drupal\webprofiler\DataCollector\DrupalDataCollectorTrait. eca_ui does not depend on webprofiler and afaiu the service in question should only ever be used if the webprofiler module is enabled, which, in my case, it is not. This worked fine so far, i.e. eca_ui worked fine without webprofiler.
Now with symfony_mailer the site crashes, because MailerPass is iterating through all service definitions calling class_exists() for every service, including webprofiler.eca_ui. This causes the definition of Drupal\eca_ui\DataCollector\EcaDataCollector to be evaluated which in turn causes PHP to crash, because Drupal\webprofiler\DataCollector\DrupalDataCollectorTrait is missing.
I'm not sure, if the correct place to fix the issue is symfony_mailer or if rather all service definitions should be assumed to be valid. There have been issues opened at eca in the past concerning the service (see https://www.drupal.org/project/eca/issues/3367660), but my understanding is, that Drupal somehow handles the case, if a service (class) cannot be loaded and that the eca_ui service is intended to only being used, if webprofiler is enabled and else it should be blissfully ignored.
Steps to reproduce
Install eca_ui alongside symfony_mailer and open /update.php.
Proposed resolution
symfony_mailer should not crash, if a service class cannot be loaded. (Although I don't know if and how this would be possible.)
Comments
Comment #2
adamps commentedThanks. I feel that the ECA code is correct - the code will only be loaded when the
webprofilermodule exists, and so the use will be valid.In Symony library
ContainerBuilder::getReflectionClass()the call toclass_exists()is insidetry/catch (\ReflectionException $e) {, so we can do the same. Please can you post the full text of your error message?Comment #3
lukas_w commentedThe error message I get is this one:
Comment #4
adamps commentedStrange, I can see EcaDataCollector only in the 1.x series https://git.drupalcode.org/project/eca/-/blob/1.1.x/modules/ui/src/DataC..., which is no longer supported.
Anyway I edited a Core service to use a non-existent trait and it generates an error that I cannot catch. Then I commented out the code from this module, and still got an error, presumably from one of the Core service passes, which contain calls to
registerForAutoconfiguration()ornew \ReflectionMethod. Strange again, how it generates an error now, but it didn't at first.So I no longer agree that the ECA code is good (and anyway the code seems to have been removed now?). It's common to have a plug-in definition that wouldn't compile, because the code will only be loaded if the module containing the plug-in manager exists anyway. However for a service it's much less common, and can easily trigger an error in a compiler pass.
In summary, I'm not yet convinced that this is a bug here (rather than ECA), and I'm not yet aware of anything that I can do about it.
Comment #5
lukas_w commentedIndeed, the site in question stills uses eca 1.x, I hadn't checked that. I will then update eca and there is nothing to be done here.
Sorry for the noise and thanks for looking into it!
Comment #6
adamps commentedThanks for the update