WordPress.org

Forums

WordPress deletes text_widget settings in wp_options (6 posts)

  1. TrickleUp
    Member
    Posted 4 years ago #

    Hi,

    I have a local copy of a wordpress site that I use to develop, on my mac (10.5.8), which is a mirror of a site on the internet. Periodically I dump the sql from the real site and import it locally, so that I can work with the actual content of the site. When doing this, all my text widgets dissappear.

    What happens is that on first load of the local site after the import of new data, the row in wp_options that contains the serialized array for the text widgets, gets reset to a blank text widget, like this:

    a:2:{i:2;a:0:{}s:12:"_multiwidget";i:1;}

    I've tested the serialized string, and it is not corrupt, meaning that PHP is able to create an array from it. I also recreated the text widgets locally, and looked at the array that was created, and it has the same structure.

    Could the issue have something to do with the keys in the array, that they somehow double already existing keys in wp's data structure. I just don't see how that would happen, since also in the database there were other (custom) widgets, that imported just fine, but not the standard text widget.

    So, finally, what is WP looking for when validating these arrays? Where in the code can I find this? Any other ideas?

    Both local and remote site run the same version of wp, 3.0.1.

    Please don't respond with that I have to copy and paste and redo all the text widgets, I know how to do this, but that is not what I'm asking. I want to have an automated way of doing this, since it is something I do very often for a number of different sites.

  2. blizzy
    Member
    Posted 4 years ago #

    I have the same problem when I moved my site from one server to another. The text_widget content gets deleted and is replaced with the standard row (a:2:{........)
    If you, or anyone else has the solution to this, please post =)

  3. dspilka
    Member
    Posted 4 years ago #

    I'm seeing this same behavior. Did you figure out a solution?

  4. TrickleUp
    Member
    Posted 4 years ago #

    I have not, unfortunately. I stopped looking into it, thinking someone must have solved it before me. If I have time and solve it I'll post the solution here.

  5. dspilka
    Member
    Posted 4 years ago #

    I believe I just found a solution! The issue seems to be with the copying of the wp_options table.

    This table (wp_options) stores a number of options for the site and configuration settings for plugins. Some of the data in these settings are stored in a serialized array. These arrays not only contain the string, but also contain the length of that string. These need to match for security reasons. So for example, if you change the url from http://www.blah.com to http://www.newdomain.com, you'd also need to change the length setting to the new length of http://www.newdomain.com.

    For example, this value:

    a:2:{s:8:"hostname";s:12:"www.blah.com"}

    Would need to change to this value:

    a:2:{s:8:"hostname";s:17:"www.newdomain.com"}

    If you look closely, not only did the url change, but so did the number stating it's length.

    After I manually did this to the values, the text widgets appeared and did not get reset like we had been seeing.

  6. relaxedguy
    Member
    Posted 4 years ago #

    I am still looking for the definitive guide for copying wp_options widget-related rows from one database to another. The above it very helpful, but I'm trying to figure out the sql query to:

    Find all relevant rows
    Save to text file, download
    import into another database

Topic Closed

This topic has been closed to new replies.

About this Topic