fix type error in layout_builder_perms access manager logger channel factory with LoggerChannelFactoryInterface

Created on 25 January 2025, 3 months ago

Problem/Motivation

Facing the following issue
On install with Redirect 404 module

TypeError: Drupal\layout_builder_perms\Access\AccessManager::__construct(): Argument #6 ($logger_factory) must be of type Drupal\Core\Logger\LoggerChannelFactory, Drupal\redirect_404\Render\Redirect404LogSuppressor given in Drupal\layout_builder_perms\Access\AccessManager->__construct() (line 87 of modules/contrib/layout_builder_perms/src/Access/AccessManager.php).
Drupal\layout_builder_perms\Access\AccessManager->__construct()
ReflectionClass->newInstanceArgs() (Line: 1140)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 586)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1258)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1210)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1110)
Symfony\Component\DependencyInjection\ContainerBuilder->createService() (Line: 586)
Symfony\Component\DependencyInjection\ContainerBuilder->doGet() (Line: 1258)
Symfony\Component\DependencyInjection\ContainerBuilder->doResolveServices() (Line: 1203)
Symfony\Component\DependencyInjection\ContainerBuilder->resolveServices() (Line: 1214)
Symfony\Component\DependencyInjection\ContainerBuilder->Symfony\Component\DependencyInjection\{closure}() (Line: 62)
Symfony\Component\DependencyInjection\ServiceLocator->doGet() (Line: 43)
Symfony\Component\DependencyInjection\ServiceLocator->get() (Line: 121)
Drupal\Core\Access\CheckProvider->loadCheck() (Line: 153)
Drupal\Core\Access\CheckProvider->applies() (Line: 106)
Drupal\Core\Access\CheckProvider->setChecks() (Line: 191)
Drupal\Core\Routing\RouteBuilder->rebuild() (Line: 83)
Drupal\Core\ProxyClass\Routing\RouteBuilder->rebuild() (Line: 67)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRouteProvider() (Line: 76)
Drupal\Core\Routing\RouteProviderLazyBuilder->getRouteCollectionForRequest() (Line: 258)
Drupal\Core\Routing\Router->getInitialRouteCollection() (Line: 148)
Drupal\Core\Routing\Router->matchRequest() (Line: 92)
Drupal\Core\Routing\AccessAwareRouter->matchRequest() (Line: 152)
Drupal\Core\Routing\AccessAwareRouter->match() (Line: 167)
Drupal\Core\Path\PathValidator->getPathAttributes() (Line: 128)
Drupal\Core\Path\PathValidator->getUrl() (Line: 83)
Drupal\Core\Path\PathValidator->getUrlIfValid() (Line: 124)

Proposed resolution

Switch to use LoggerChannelFactoryInterface to allow for other modules to integrate logs

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.2

Component

Code

Created by

🇯🇴Jordan Rajab Natshah Jordan

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

Merge Requests

Comments & Activities

  • Issue created by @Rajab Natshah
  • 🇯🇴Jordan Rajab Natshah Jordan

    Attached a static layout_builder_perms--2025-01-25--3502237--mr-25.patch file up to this point for MR25
    To be used with the Composer Patches

  • 🇨🇭Switzerland das-peter

    Encountered this issue too.
    Patch fixed the issue.
    From what I gather using the concrete LoggerChannelFactory instead an interface was an outlier when checking the constructor.
    Previously required concrete implementation actually implements the interface. So unless there's some "unsanctioned" use something that only the concrete implementations provides this should be just fine :)

  • 🇩🇪Germany guido_s Cologne

    It also needs to be changed in the submodules like here:

    TypeError: Drupal\layout_builder_perms_node\Plugin\Derivative\NodeLayoutBuilderPermissions::__construct(): Argument #3 ($logger_factory) must be of type Drupal\Core\Logger\LoggerChannelFactory, Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /app/web/modules/contrib/layout_builder_perms/modules/layout_builder_perms_node/src/Plugin/Derivative/NodeLayoutBuilderPermissions.php on line 61 in Drupal\layout_builder_perms_node\Plugin\Derivative\NodeLayoutBuilderPermissions->__construct() (line 51 of modules/contrib/layout_builder_perms/modules/layout_builder_perms_node/src/Plugin/Derivative/NodeLayoutBuilderPermissions.php).

  • 🇵🇹Portugal developer-rocha

    I'm also experiencing the same issue when attempting to enable the layout_builder_perms_block_types_per_layout submodule. The site breaks, and the error log shows the same TypeError related to the InlineBlockTypeInLayoutPermissions class.

    TypeError: Drupal\layout_builder_perms_block_types_per_layout\Plugin\Derivative\InlineBlockTypeInLayoutPermissions::__construct(): Argument #3 ($logger_factory) must be of type Drupal\Core\Logger\LoggerChannelFactory, Drupal\redirect_404\Render\Redirect404LogSuppressor given, called in /var/www/html/ibfd/web/modules/contrib/layout_builder_perms/modules/layout_builder_perms_block_types_per_layout/src/Plugin/Derivative/InlineBlockTypeInLayoutPermissions.php on line 61 in Drupal\layout_builder_perms_block_types_per_layout\Plugin\Derivative\InlineBlockTypeInLayoutPermissions->__construct() (line 51 of /var/www/html/ibfd/web/modules/contrib/layout_builder_perms/modules/layout_builder_perms_block_types_per_layout/src/Plugin/Derivative/InlineBlockTypeInLayoutPermissions.php).

    Drupal version: 10.4.5
    module: 2.2.0

Production build 0.71.5 2024