Problem/Motivation
Loggers can be other things than core's LoggerChannelInterface. For example if you use the monolog library.
Generally we say that loggers are LoggerInterface (from psr/log) in core.
This is not the case for core/modules/migrate_drupal/src/FieldDiscovery.php
This in turn crashes things that invoke this class, when the logger is not set as a LoggerChannel. A typical error would then be:
TypeError: Argument 3 passed to Drupal\migrate_drupal\FieldDiscovery::__construct() must implement interface Drupal\Core\Logger\LoggerChannelInterface, instance of Psr\Log\NullLogger given, called in /my-site/drupal/core/lib/Drupal/Component/DependencyInjection/Container.php on line 277 in Drupal\migrate_drupal\FieldDiscovery->__construct() (line 110 of /my-site/drupal/core/modules/migrate_drupal/src/FieldDiscovery.php).
Proposed resolution
Replace it with LoggerInterface. In fact, in core, this is the only place we specify the type to be LoggerChannelInterface (did a quick search).
Remaining tasks
Create a patch and commit.
User interface changes
None
API changes
Well I guess theoretically, but LoggerChannelInterface extends LoggerInterface
Data model changes
None
Release notes snippet
n/a
Comment | File | Size | Author |
---|---|---|---|
#5 | 3101818-5.patch | 3.79 KB | ravi.shankar |
#2 | 3101818.patch | 3.85 KB | eiriksm |
Comments
Comment #2
eiriksmComment #3
longwaveThis looks fine. No API change as LoggerChannelInterface already extends LoggerInterface, so this just fixes the bug and any existing callers will still work.
Comment #4
alexpottThis looks good but unfortunately we need a 9.0.x version too so we can commit this there too. core/modules/migrate_drupal/src/FieldDiscovery.php has diverged.
Comment #5
ravi.shankar CreditAttribution: ravi.shankar at OpenSense Labs commentedHere I have done patch #2 on Drupal 9.0.x
Comment #6
longwaveComment #7
alexpottCommitted 0c3891e and pushed to 9.0.x. Thanks!
Committed and pushed 0a7c6dc9cd to 8.9.x and 3416efa646 to 8.8.x. Thanks!
Backported to 8.8.x as this is a simple widening of an constructor.