Ask your WordPress questions! Pay money and get answers fast! (more info)

CformsII Persistent Serialized Data Error Fix Needed

  • SOLVED

Posted the issue on WordPress here [[LINK href="https://wordpress.org/support/topic/cformsii-peri?replies=1"]]https://wordpress.org/support/topic/cformsii-peri?replies=1[[/LINK]]

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 [[[LINK href="http://stackoverflow.com/questions/4149030/php-unserialize-error-at-offset-works-on-some-servers-not-others"]]here[[/LINK]]][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:

<blockquote>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.
</blockquote>
Current data is [[[LINK href="https://gist.github.com/jasperf/fabdc46cc93ef89ec1ac"]]here[[/LINK]]][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? Debug + Fix appreciated

NB Table Collation and Engine is the same on live and test server
<strong>NBB</strong> Will try to update to fork as soon as data is working ok
[1]:[[LINK href="http://stackoverflow.com/questions/4149030/php-unserialize-error-at-offset-works-on-some-servers-not-others"]] http://stackoverflow.com/questions/4149030/php-unserialize-error-at-offset-works-on-some-servers-not-others[[/LINK]]
[2]: [[LINK href="https://gist.github.com/jasperf/fabdc46cc93ef89ec1ac"]]https://gist.github.com/jasperf/fabdc46cc93ef89ec1ac[[/LINK]]

Answers (1)

2015-07-15

Bob answers:

so the issue started after cloning the site.

can you please let me know how you cloned a site to your localhost?


rhand comments:

I cloned the site using BackupBuddy complete backup and restored on my ScotchBox Vagrant box using the BB importbuddy.php script and all seemed to go well. The site does look OK, except for some odd question marks in diamonds where apostrophes were supposed to be. That and not a single form being loaded because the Cforms serialized data somehow got corrupted.


rhand comments:

When I unserialized and serialized all data again and added it to the database cforms_settings value field in the database the same warning still showed up and I saw 3 of these odd � again looking at the data in Cforms in the backend where I am offered to get CformsII to fix all or do it all myself. Learned more about var_dump, var_export, serialize and unserialize but al still a bit over my head really.


Bob comments:

I think it is database charset issue.

use database as it is without any update done by you. If you do not have backup clean local import and re-import.

then add this in your wp-config.php file.

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


This is just try. Let's see what happens.


Bob comments:

have you tried cform export and import feature? if there is any.

I think backupbuddy have not replaced url in imported serialized data also.

If there is issue with settings related serialized data only then.

find "<strong>cforms_settings</strong>" in options table of live site. copy it in text file then.

do search and replace for url I can see your are trying to clone (www.ultimatefijivacations.com)
so search it and replace by your local url.

There is also relative path "/home/ufijiv/ultimatefijivacations.com" you need to replace it also with your localhost relative path.

Then update your localhost "<strong>cforms_settings</strong>" via phpmyadmin or whatever too you have.


rhand comments:

Bob you are a genius! All working now. All that time wasted on checking the data just when I had to check the database settings.I need to check how sotchbox stores the databases with Sequel Pro as it should have imported as instructed in the sql files.


Bob comments:

I am glad to know that everything is working now :)