PHP Fatal error: Declaration of Logging\Log
-
Hi there,
I am getting since the 2 latest updates the following error message with my site WordPress in black out mode:
2025/01/13 16:58:00 [error] 128486#128486: *95812 FastCGI sent in stderr: “PHP message: PHP Fatal error: Declaration of WooCommerce\WooCommerce\Logging\Logger\WooCommerceLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void in /www/seriousconnection_462/public/wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/WooCommerceLogger.php on line 58” while reading response header from upstream, client: 54.36.148.157, server: https://www.seriousconnection.com, request: “GET /mentions-legales?yith_wcan=1&query_type_freinage=or&filter_freinage=full-hs HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php8.1-fpm-seriousconnection.sock:”, host: “www.seriousconnection.com:57745”
here is the WordPress error message with all the versions details :Si vous cherchez de l’aide pour ce problème, les informations suivantes pourraient vous être demandées :
WordPress version 6.7.1
Thème actif : Woodmart (version 8.0.6)
Extension actuelle : WooCommerce PayPal Payments (version 2.9.6)
PHP version 8.1.28 Détails de l’erreurUne erreur de type E_COMPILE_ERROR a été causée dans la ligne 58 du fichier /www/seriousconnection_462/public/wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/WooCommerceLogger.php. Message d’erreur : Declaration of WooCommerce\WooCommerce\Logging\Logger\WooCommerceLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void
I had also another error message after fixing first one:
2025/01/13 17:24:22 [error] 128486#128486: *96262 FastCGI sent in stderr: “PHP message: PHP Fatal error: Declaration of WooCommerce\WooCommerce\Logging\Logger\NullLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerTrait::log($level, Stringable|string $message, array $context = []): void in /www/seriousconnection_462/public/wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/NullLogger.php on line 31” while reading response header from upstream, client: 138.199.22.179, server: https://www.seriousconnection.com, request: “GET /p/manette-de-frein-trialtech-carthy-signature-droit/?add-to-cart=28660 HTTP/2.0”, upstream: “fastcgi://unix:/var/run/php8.1-fpm-seriousconnection.sock:”, host: “www.seriousconnection.com:57745”
Could you please help? Let me know of there is a github to fix this issue.
I used the following code to fix it in /wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/WooCommerceLogger.php/**
* Logs a message.
*
* @param mixed $level The logging level.
* @param stringable|string $message The message.
* @param array $context The context.
*/
public function log( $level, $message, array $context = array() ): void {
if ( ! isset( $context['source'] ) ) {
$context['source'] = $this->source;
}
$this->wc_logger->log( $level, $message, $context );
}And the following code in /wp-content/plugins/woocommerce-paypal-payments/modules/woocommerce-logging/src/Logger/NullLogger.php
/**
* Class NullLogger
*/
class NullLogger implements LoggerInterface {
use LoggerTrait;
/**
* Logs a message. Since its a NullLogger, it does not log at all.
*
* @param mixed $level The logging level.
* @param \Stringable|string $message The message.
* @param array $context The context.
*/
public function log( $level, $message, array $context = array() ): void {
}
}Let me know if you need more information
Jose
- You must be logged in to reply to this topic.