Php prompts PHPclassxhasnounserializer solution

Source: Internet
Author: User
PHP has come out of the stable version 538, so it is almost ready to upgrade the PHP on the company's production server from 5217 to 538, but found a strange problem during the testing server debugging:

PHP has come out of the stable version 5.3.8, so we are about to upgrade PHP on the company's production server from 5.2.17 to 5.3.8. we found a strange problem during debugging on the test server:

After the PHP environment is installed, an error is reported for the code that can run normally in 5.2.17, prompting PHP class x has no unserializer. the same set of code can be used on the same server with 5.3.8 without any problems. google found that there was no useful information. it seems that I encountered a cold door problem, so I began to debug the check gradually and found that the error was found in the part where memcache was used to retrieve data, when I retrieve data cached in memcache, the system prompts that my class has no deserialization function, but this code runs in 5.3.8 without any problems.

As the only clue is the deserialization prompt, I searched the php official serialization information and first found the serialization interface Serializable introduction, here I noticed that this interface has an unserializ method, which is an excuse for calling the deserialization class. at the same time, php's memcache extension will serialize php Data objects when they are stored in memcache. Is it because my own object does not implement the Serializable interface? After tracing the code, I found that the class in memcache is inherited from the Array_Object class, so I ran to the introduction page of the official Array_Object.

Array_Object has implemented the Serializable interface since 5.3.0, But 5.2 has not. Here, the cause of this problem is clear, and the analysis is as follows:

The program runs in two versions of PHP but uses the same memcache Cache pool. I tested version 5.3.8 first, so the Array_Object object in PHP5.3 is stored, this object can be normally serialized and deserialized under 5.3, and then I went to access the program running under PHP5.2, which already has a cache object in memcache, therefore, 5.2 reads the serialized Array_Object object in 5.3. in 5.2, Array_Object does not implement the Serializable interface, so an error occurs during deserialization, this is why PHP class x has no unserializer is prompted.

The solution to this problem is simple. each program uses a different cache pool to avoid data pollution and version compatibility issues.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.