Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
72 views
in Technique[技术] by (71.8m points)

How to fix WordPress option_value with serialized data

In changing http to https in several option_values I lost page content. So I reverted the site url back to http and tried to replace an option_value in the wp_options table with data from a recent backup using phpmyadmin, and checked the data saved correctly. However when the website is loaded the data is replaced with

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

The data includes serialized data. I realise that the string lenght values need to be correct, but the backup data was from when it was working so that should be correct. Is there other related data that needs updating?

Here's the content including backslashes for sql import and split into new lines for easy reading:

a:13:{
i:1;a:0:{}
i:2;a:4:{s:5:"title";s:8:"About Us";s:4:"text";s:0:"";s:6:"filter";b:1;s:6:"visual";b:1;}
i:3;a:4:{s:5:"title";s:0:"";s:4:"text";
s:216:"<a href="http://someurl"><img class="wp-image-367  alignleft" src="http://someimageurl" alt="" width="117" height="84" /></a>";
s:6:"filter";b:1;s:6:"visual";b:1;}
i:5;a:4:{s:5:"title";s:0:"";s:4:"text";s:0:"";s:6:"filter";b:1;s:6:"visual";b:1;}
i:6;a:4:{s:5:"title";s:8:"Approach";s:4:"text";s:425:"some long text.

[embed]https://www.youtube.com/watch?v=someid[/embed]";s:6:"filter";b:1;s:6:"visual";b:1;}
i:7;a:4:{s:5:"title";s:8:"Our Team";s:4:"text";s:3016:"<a href="https://www.linkedin.com/in/someid/"><img class="wp-image-4308 size-full alignleft" src="http://someimageurl" alt="" width="270" height="287" /></a>

sometext

<strong>sometext</strong>

somelongtext.";s:6:"filter";b:1;s:6:"visual";b:1;}
i:8;a:4:{s:5:"title";s:10:"Contact Us";s:4:"text";s:23:"someemail";s:6:"filter";b:1;s:6:"visual";b:1;}
i:9;a:4:{s:5:"title";s:0:"";s:4:"text";s:23:"someemail";s:6:"filter";b:1;s:6:"visual";b:1;}
s:12:"_multiwidget";i:1;
i:11;a:4:{s:5:"title";s:4:"test";s:4:"text";s:7:"testing";s:6:"filter";b:1;s:6:"visual";b:1;}
i:13;a:4:{s:5:"title";s:0:"";s:4:"text";s:53:"https://www.youtube.com/watch?v=someid

&nbsp;";s:6:"filter";b:1;s:6:"visual";b:1;}
i:15;a:4:{s:5:"title";s:0:"";s:4:"text";s:68:"[embed]https://www.youtube.com/watch?v=someid&amp;t=51s[/embed]";s:6:"filter";b:1;s:6:"visual";b:1;}
i:16;a:4:{s:5:"title";s:0:"";s:4:"text";s:64:"[embed]https://www.youtube.com/watch?v=someid&t=51s[/embed]";s:6:"filter";b:1;s:6:"visual";b:1;}}
question from:https://stackoverflow.com/questions/65831458/how-to-fix-wordpress-option-value-with-serialized-data

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Solved it by creating an update sql command from the backup insert sql, saving in a file using Notepad++, and imported via phpmyadmin. Maybe there had been an issue with extra newline characters or missing backslash escape characters when I tried before.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...