1

I am upgrading to 2.4.5

I am getting this error all through out Magento including the command line, which is being caused by the Manadev extension, do you know what this may be?

PHP Fatal error:  Declaration of Manadev\Core\LoggerHandlers\DefaultHandler::write(array $record) must be compatible with Magento\Framework\Logger\Handler\Base::write(array $record): void in app/code/Manadev/Core/LoggerHandlers/DefaultHandler.php on line 52

DefaultHandler.php write function -->

    public function write(array $record) {
        if (isset($record['file'])) {
            $url = empty($record['file'])
                ? BP . '/var/log/mana.log'
                : BP . '/var/log/mana/' . $record['file'] . '.log';

            unset($record['file']);
        }
        else {
            $url = BP . '/var/log/mana.log';
        }

        if ($this->url != $url) {
            $this->close();
            $this->url = $url;
        }

        parent::write($record);
    }

Thank you

1 Answer 1

1

Compare the method from magento core to your method, your method missing declare return type, and it must be void.

So, change your code to:

    public function write(array $record): void {
        if (isset($record['file'])) {
            $url = empty($record['file'])
                ? BP . '/var/log/mana.log'
                : BP . '/var/log/mana/' . $record['file'] . '.log';

            unset($record['file']);
        }
        else {
            $url = BP . '/var/log/mana.log';
        }

        if ($this->url != $url) {
            $this->close();
            $this->url = $url;
        }

        parent::write($record);
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.