Incompatible with non-core logger-factory

Created on 1 February 2023, almost 2 years ago

Problem/Motivation

When instantiating the ActivityTrackingService service on a site using a non-core logger factory (e.g. Monolog), the following error is triggered:

The website encountered an unexpected error. Please try again later.
TypeError: Drupal\activity_tracking\Services\ActivityTrackingService::__construct(): Argument #5 ($loggerFactory) must be of type Drupal\Core\Logger\LoggerChannelFactory, Drupal\monolog\Logger\MonologLoggerChannelFactory given, called in /var/www/html/web/core/lib/Drupal/Component/DependencyInjection/Container.php on line 259 in Drupal\activity_tracking\Services\ActivityTrackingService->__construct() (line 55 of modules/contrib/activitytracking/src/Services/ActivityTrackingService.php).
Drupal\activity_tracking\Services\ActivityTrackingService->__construct(Object, Object, Object, Object, Object) (Line: 259)
Drupal\Component\DependencyInjection\Container->createService(Array, 'activity_tracking.logger') (Line: 177)
Drupal\Component\DependencyInjection\Container->get('activity_tracking.logger') (Line: 197)
Drupal::service('activity_tracking.logger') (Line: 43)
activity_tracking_entity_update(Object)
...

Install the module.
Install monolog or add a custom default logger channel implementation.
Update any entity.

Proposed resolution

Change the service constructor DI to expect an interface implementation instead of a core channel factory instance.

ActivityTrackingService.php
Change: LoggerChannelFactory $loggerFactory
To: LoggerChannelFactoryInterface $loggerFactory

Remaining tasks

Apply attached patch.

User interface changes

n/a

API changes

n/a

Data model changes

n/a

πŸ› Bug report
Status

Active

Version

1.5

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States bfuzze9898

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024