Problem/Motivation

Currently the ProtectedPagesSendEmailForm includes logger.channel as one of its dependencies, unfortunately instead of referencing the dependency interface it type hints the logger channel factory dependency.

This is fine as long as you are not using a module which overrides the logger.

However if you are using, for example, the redirect 404 module then this will (quite acceptably) implement the LoggerChannelFactoryInterface without extending LoggerChannelFactory, making it unacceptable to this module and throwing an error.

TypeError: Argument 7 passed to Drupal\protected_pages\Form\ProtectedPagesSendEmailForm::__construct() must be an instance of Drupal\Core\Logger\LoggerChannelFactory, instance of Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /app/docroot/modules/contrib/protected_pages/src/Form/ProtectedPagesSendEmailForm.php on line 110 in Drupal\protected_pages\Form\ProtectedPagesSendEmailForm->__construct() (line 89 of /app/docroot/modules/contrib/protected_pages/src/Form/ProtectedPagesSendEmailForm.php)

Steps to reproduce

  1. Install this module
  2. Install a module that implements the LoggerChannelFactoryInterface (e.g. redirect 404)
  3. Try to access the "Send email" form

Proposed resolution

Type hint using the LoggerChannelFactoryInterface instead of LoggerChannelFactory directly in the constructor for the SendEmail form.

Comments

andy_w created an issue. See original summary.

andy_w’s picture

andy_w’s picture

Status: Active » Needs review
michelle-buckby’s picture

Applied the patch #2 to a Drupal 8.9.6, PHP 7.3 project, working great thank you!

michelle-buckby’s picture

Status: Needs review » Reviewed & tested by the community

  • oksana-c committed e9eeb75 on 8.x-1.x authored by andy_w
    Issue #3177758 by andy_w: Send email form expects a LoggerChannelFactory...
oksana-c’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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