Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:29:19+00:00 2026-06-10T21:29:19+00:00

I try to serialize object data to be saved into a file by php

  • 0

I try to serialize object data to be saved into a file by php using serialize package by PHP.js.

Chrome: fine
FF: fine
IE9: fine
IE9 in compatibility mode (essentially IE7): not fine.

Error from console:

SCRIPT5022: Exception thrown and not caught 
serialize.min.js, line 144 character 55

Serialized the data basically looks like this:

a:180:{s:40:"Aleksis Kiven tie 15<br>04200 Kerava<br>";a:2:{i:0;d:60.4012598;i:1;d:25.09659910000005;}

Unserialized:

{"Aleksis Kiven tie 15<br>04200 Kerava<br>": [60.4012598, 25.09659910000005]}

Javascript that handles the caching looks like this:

function saveCache(data) {
    sdata = serialize(data);
    $.ajax({
        type: 'POST',
        url: 'http://localhost/foobar/files/coordinates.php',
        data: {
            'do': 'write',
            'data': sdata
        }
    });
}

I’m caching geocoding results by address into a text file.

Please ask more if I’m not making sense.

MAJOR EDIT: I corrected the examples as pointed out. Also the major thing is that the issue really changed; it isn’t actually an issue with serialize(), but with unserialize().

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:29:20+00:00Added an answer on June 10, 2026 at 9:29 pm

    I figured it out myself after all.

    When I took a closer look it wasn’t serialize() after all that caused the error but rather unserialize() which is in the same package with me.

    At some point the cache went corrupt and for some reason IE9 in comp-mode was the only browser of those I tested that didn’t tolerate it. The reason for the cache corrupting was stacking utf8_encodes/decodes that started messing things up.

    It went like this:

    • Cache is built and serialized using serialize(). All Ok.
    • PHP checks if the data is really UTF-8 and performs an utf8_encode accordingly. Saves data. All Ok.
    • Next page load. PHP returns stored data using AJAX. An UTF-8 header is sent just in case. data is unserialize()d and dealt with accordingly. All Ok.
    • Cache is possibly updatet with new content and serialize()d. Alerting the serialized data yields a surprise: chinese characters and corruption in place of åäö!

    The solution lies in unserialize() performing an unnecessary utf8_decode(). The page is UTF-8. All my javascript files are UTF-8. The cached data is made many times sure to be UTF-8. So there souldn’t be and isn’t any reason to decode UTF-8. I’m not a 100% sure how exactly this crapped out the data, but commenting out the utf8_decode solved the issue.

    I’m a little bit disappointed in the error tolerance of modern browsers. It is too high. But well, good thing I figured it out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Background .NET 4, C#, MVC3, using JsonFx to serialize and deserialize data. Base controller
I have some data in a C# DataSet object. I can serialize it right
I am trying to serialize some Linq objects using this code. private byte[] GetSerializedObj(object
In the following code, I serialize an object into an XML string . But
Currently, I do serialize my model object to the SharedObject instance : try {
Anytime I try to serialize a file I get the error: FileNotFound. Not sure
I am trying to Serialize the content of some text into an XML file
I am using the following code to serialize an object and to attach it
i try to serialize my checkbox items. first, i want to tell you what
When I try to serialize class with protected members, I get the following errors:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.