magento / zf1

ZF1 adopted for Magento 2. Use composer in Magento 2 root to download it.
BSD 3-Clause "New" or "Revised" License
60 stars 61 forks source link

Deprecated Functionality: Zend_Http_UserAgent_Mobile implements the Serializable interface, which is deprecated. Implement __serialize() and __unserialize() instead (or in addition, if support for old PHP versions is necessary) #49

Open manan-india opened 2 years ago

manan-india commented 2 years ago

When calling the match($userAgent, $server) function for mobile view in the module, it is giving error

PHP: 8.1 Magento: 2.4.4

Screenshot from 2022-06-23 18-18-48

xmav commented 2 years ago

Hi! Could you please share more detailed steps to reproduce ?

manan-india commented 2 years ago

Hello!

We have called the function of class(path: vendor/magento/zendframework1/library/Zend/Http/UserAgent/Mobile.php on line 33): This class is implementing the Serializable interface and it is deprecated in PHP 8.1: https://php.watch/versions/8.1/serializable-deprecated. Implementation:

    public function isMobileDevice()
    {
        $userAgent = $this->httpHeader->getHttpUserAgent();
        $server = $this->getRequest()->getServer();
        $isMobileDevice = \Zend_Http_UserAgent_Mobile::match($userAgent, $server);
        if (!$isMobileDevice) {
            return true;
        }
        return false;
    }
indrisepos commented 1 year ago

You can quickly fix it by commenting out Serialize in Device.php: interface Zend_Http_UserAgent_Device //extends Serializable

or by adding the two Serialization methods in AbstractDevice.php: https://github.com/indrisepos/zf1/pull/1