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
- Install this module
- Install a module that implements the LoggerChannelFactoryInterface (e.g. redirect 404)
- 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.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 3177758-protected-pages-logger-factory-interface.patch | 1.96 KB | andy_w |
Comments
Comment #2
andy_w commentedComment #3
andy_w commentedComment #4
michelle-buckby commentedApplied the patch #2 to a Drupal 8.9.6, PHP 7.3 project, working great thank you!
Comment #5
michelle-buckby commentedComment #7
oksana-c commented