• Resolved ablears

    (@ablears)


    >PHP Fatal error: Declaration of Psr\Log\NullLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerInterface::log($level, Stringable|string $message, array $context = []): void in /var/www/z/wp-content/plugins/mpdf-addon-for-pdf-invoices/vendor/psr/log/Psr/Log/NullLogger.php on line 26

    PHP 8.1
    Plugin version 1.2.1

    This causes a fatal error whenever an order is marked as complete (hence generating the invoice). Refreshing the page shows the order page correctly but trying to download the invoice triggers the error too.

    I changed line 26 to:
    public function log($level, $message, array $context = []): void

    That fixed the error. Is this something you can add to the next release?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @ablears,

    Thanks for reaching out.

    We were unable to replicate the error mentioned, which seems to be related to the PSR NullLogger. We can confirm that the NullLogger is fully compatible with the LoggerInterface. Applying the suggested code changes may result in a fatal error. Additionally, it seems that the LoggerInterface code is unrelated to our plugin. Kindly check. Our LoggerInterface is defined as follows:

    Psr\Log\LoggerInterface::log($level, $message, array $context = [])

    The reported LoggerInterface is defined as follows:

    Psr\Log\LoggerInterface::log($level, Stringable|string $message, array $context = []): void

    Thread Starter ablears

    (@ablears)

    I had to make the code change to your plugin to prevent the fatal errors. I’m not sure what else I can do, considering this is the only plug-in that generates this error on our WordPress network.

    Thread Starter ablears

    (@ablears)

    I had a look on the server, searching for other instances of Psr\Log\LoggerInterface::log and found that WooCommerce was logging errors on one domain only on this network, and that is the one showing the error. It backtraces to woocommerce/includes/class-woocommerce.php.

    3:2024-09-09T20:22:02+00:00 CRITICAL Declaration of Psr\Log\NullLogger::log($level, $message, array $context = []) must be compatible with Psr\Log\LoggerInterface::log($level, Stringable|string $message, array $context = []): void CONTEXT: {“error”:{“type”:64,”file”:”/var/www/z/wp-content/plugins/mpdf-addon-for-pdf-invoices/vendor/psr/log/Psr/Log/NullLogger.php”,”line”:26},”backtrace”:[{“file”:”/var/www/z/wp-content/plugins/woocommerce/includes/class-woocommerce.php”,”line”:359,”function”:”critical”,”class”:”WC_Logger”,”type”:”->”},{“function”:”log_errors”,”class”:”WooCommerce”,”type”:”->”}]}

    Running ack 'LoggerInterface' . showed a number of themes and plugins using it, but mpdf is the only one that generates a fatal error.

    • This reply was modified 2 months, 2 weeks ago by ablears. Reason: more detail
    Plugin Support WebToffee Support

    (@webtoffeesupport)

    Hi @ablears,

    We have fixed the issue in the latest release of the plugin. You may update the plugin to its latest version and check.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.