Skip to content

PHP8 compatibility with sending mail #54

@Monica-Wood

Description

@Monica-Wood

I am using PHP 8.1 and receiving the following error when sending mail.

Fatal error: Uncaught TypeError: array_key_exists(): Argument #2 ($array) must be of type array, Zend_Registry given in /var/www/ca/vendor/magento/zendframework1/library/Zend/Registry.php:207

The way array_key_exists has changed in php 8

For backward compatibility reasons, array_key_exists() will also return true if key is a property defined within an object given as array. This behaviour is deprecated as of PHP 7.4.0, and removed as of PHP 8.0.0.

Since the bit of code that is causing the TypeError was put into place to fix a previous bug, I have commented out the entire offsetExists() function in Registry.php so it would fall back to the function in ArrayObject.

Mail is now sending successfully with this function commented out.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions