Fatal Error RfcLoggerTrait::Log

Created on 23 May 2023, over 1 year ago
Updated 24 May 2023, over 1 year ago

Problem/Motivation

Upon enabling Push Logs, a fatal error is generated:

Fatal error: Declaration of Drupal\push_logs\Logger\PushedLog::log($level, $message, array $context = []) must be compatible with Drupal\Core\Logger\RfcLoggerTrait::log($level, Stringable|string $message, array $context = []): void in /------/------/modules/contrib/push_logs/src/Logger/PushedLog.php on line 79

Steps to reproduce

  1. Install Push Logs via Composer:
    composer require 'drupal/push_logs:^1.0'
  2. Enable Push Logs with Drupal 10 UI.
  3. Immediate fatal error:
    Fatal error: Declaration of Drupal\push_logs\Logger\PushedLog::log($level, $message, array $context = []) must be compatible with Drupal\Core\Logger\RfcLoggerTrait::log($level, Stringable|string $message, array $context = []): void in /------/------/web/modules/contrib/push_logs/src/Logger/PushedLog.php on line 79

Proposed resolution

From that I can see, it appears to be a matter of adding a "void" to the function argument default values:

public function log($level, $message, array $context = []): void {
vs.
public function log($level, $message, array $context = []) {

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

πŸ› Bug report
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States emathy El Sobrante, CA

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

Comments & Activities

Production build 0.71.5 2024