• I cloned a WordPress site to a local developer server and all was running well except for CformsII 14.6 plugin (older version than current fork) which is used for several forms. The plugin stated there was an issue with the serialized data. Using its built in fix option resulted to nothing or the no longer loading of any old data.

    With the help of thread at SO [here][1] I managed to fix the serialized data, that is fix any string lenght issues. I used

    $data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data);
    //var_dump(unserialize($data));
    echo $data;

    With the code I was able to unserialize without any issues and print the fixed code. So I re-added the data to the options table row value cforms_settings.
    But still the form data won’t load and I still get the error:

    Corrupted cforms settings array (raw code)
    Depending on your WordPress/PHP skills you may want to try and fix the serialized data below, then hit the fix button or try just like that, cforms may magically fix it for you.

    Current data is [here][2] at Github. Quite a bit of code to paste here.
    There must be either issues with the way the new local database deals with the imported data. But I have no idea how to debug.

    Any ideas how I can debug any further to resuscitate the forms?

    NB Table Collation and Engine is the same on live and test server
    [1]: https://stackoverflow.com/questions/4149030/php-unserialize-error-at-offset-works-on-some-servers-not-others
    [2]: https://gist.github.com/jasperf/fabdc46cc93ef89ec1ac

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Rhand

    (@rhand)

    When I unserialized using https://stackoverflow.com/questions/10152904/unserialize-function-unserialize-error-at-offset code

    $data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data);
    var_dump(unserialize($data));

    just now and stored is as a php file and checked for errors I had an error on line 2

    <?php
    array(5) {
      ["global"]=>
      array(50) {
        ["plugindir"]=>

    PHP Parse error: syntax error, unexpected '{' in /var/www/public/unserialized.php on line 2

    Thread Starter Rhand

    (@rhand)

    Was a standard var_dump though so data seems OK. Just need to serialize it in a way that will make CformsII load it properly and WordPress not mangle it somehow. Ideas are welcome.
    NB Checking out https://stackoverflow.com/questions/3531857/convert-var-dump-of-array-back-to-array-variable for var export and serialize

    Thread Starter Rhand

    (@rhand)

    With

    $data = preg_replace('!s:(\d+):"(.*?)";!e', "'s:'.strlen('$2').':\"$2\";'", $data);
    var_export(unserialize($data));

    and running the file and saving the date in a new file:
    php test5.php >> unserialized2.php
    I was able to re-create the array which can be parsed by PHP. Only a final semi-colon or ; was missing. No other errors. Will see if I can serialize and import the data again and then have all restored without errors asap.

    Thread Starter Rhand

    (@rhand)

    Unserializing and serializing done and added to the options table key cforms_settings, but still getting the same plugin error as before.

    Thread Starter Rhand

    (@rhand)

    When I added

    define( 'DB_CHARSET', 'utf8' );
    define( 'DB_COLLATE', 'utf8_general_ci' );

    all was fine again. The database I was using was utf8 already so I am not entirely sure why this was needed so will keep this thread open for more feedback.The issue with question marks in diamonds indicated a charset issue and I guess that was an issue for the serialized data with some ' showing up as diamond shaped question marks in the browser as well. Would love to hear anyone who ever had the issue and has a better explantations than me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘CformsII Persistent Serialized Data Error’ is closed to new replies.