Drupal 10 LoggerChannelPartForV3 log method not compatible with psr/log interface

Created on 11 October 2023, 9 months ago
Updated 16 October 2023, 9 months ago

Problem/Motivation

After upgrading to Drupal 10 core, I'm seeing an incompatibility in the drupal/purge module that causes a white screen of death:

Fatal error: Declaration of Drupal\purge\Logger\LoggerChannelPartForV3::log($level, Stringable|string $message, array $context = []): void must be compatible with Drupal\Core\Logger\LoggerChannel::log($level, $message, array $context = []) in /var/www/html/docroot/modules/contrib/purge/src/Logger/LoggerChannelPartForV3.php on line 15

the log() method signature in the LoggerChannelPartForV3 class is not compatible with the interface method, Psr\Log\LoggerInterface::log, which is the interface it's using if you follow up the class and interface inheritance chain.

So I'm thinking there must be some version of psr/log that is compatible, but I haven't found it yet. Has anyone else dealt with this?

Steps to reproduce

1. On a site that has the drupal/purge module installed at the latest version, upgrade to Drupal 10.
2. Go to the site in a browser.
- See a white screen with the following error:

Fatal error: Declaration of Drupal\purge\Logger\LoggerChannelPartForV3::log($level, Stringable|string $message, array $context = []): void must be compatible with Drupal\Core\Logger\LoggerChannel::log($level, $message, array $context = []) in /var/www/html/docroot/modules/contrib/purge/src/Logger/LoggerChannelPartForV3.php on line 15

Proposed resolution

Install a version of psr/log that has a compatible interface for the log() method, or create a patch for drupal/purge to fix the incompatibility in Drupal\purge\Logger\LoggerChannelPartForV3::log

Remaining tasks

🐛 Bug report
Status

Closed: works as designed

Version

3.0

Component

Code

Created by

🇺🇸United States anthonyf

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

Comments & Activities

  • Issue created by @anthonyf
  • Assigned to Shreya_98
  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.5 + Environment: PHP 7.4 & MySQL 5.7
    last update 9 months ago
    610 pass
  • @shreya_th opened merge request.
  • Issue was unassigned.
  • Status changed to Needs review 9 months ago
  • 🇮🇳India Shreya_98

    Hi @SqyD,
    I have fixed this issue and also created MR for this issue i.e. "Drupal 10 LoggerChannelPartForV3 log method not compatible with psr/log interface". Kindly review the changes.

    Thank you.

  • 🇺🇸United States anthonyf

    Hi @Shreya_th,
    I tested your branch in local dev and it resolved the fatal error for me.

    Thanks!

  • Status changed to RTBC 9 months ago
  • Status changed to Postponed 9 months ago
  • 🇺🇸United States anthonyf

    @Shreya_th,
    I'm thinking that the real issue might have been that I don't have the correct set of Symfony packages installed that would be compatible with the D10 version of the Purge module.

    At this point, I don't recommend merging any fix for this issue. I'm going to try to update some Symfony packages and see if that resolves things.

  • Status changed to Closed: works as designed 9 months ago
  • 🇺🇸United States anthonyf

    I'm confirming that the incompatibility issue was caused by having the wrong version of Symfony packages installed after a first attempt to upgrade from Drupal 9.5 to Drupal 10. It may have been because I failed to "composer remove" all "require-dev" packages from the project before doing the composer "requires" for the Drupal core upgrade. Though removing the drupal/core-recommended package also helped.

Production build 0.69.0 2024