• Resolved Alexey

    (@dvascheta)


    Hello! Sorry if question is silly, but I can’t google an answer.

    Sometimes we need to replace one text constant to another in the whole db, for example when we move site to another domain. The best way I know is to make db dump, edit it as a text document and upload to db again.

    Sometimes constants look like this:

    (178, 18, 'page', 'https://dvascheta.ru/contacts'),

    and here is no problem, but sometimes like this:

    a:5:{s:4:"home";s:19:"https://dvascheta.ru";s:4:"link";

    And here is a problem because “s:19” means that a 19 chars long string follows.

    Today I moved my site to httpS and had to replace all “http” to “https”. As soon as I did it, I found out that my theme settings were set to defaults (it forgot header and background image, all widgets etc). I found out that the problem was in string length and I had to correct string length everywhere. I.e. changing “https://dvascheta.ru” to “https://dvascheta.ru” I had also to change “s:19” to “s:20”

    It was very much work to do because domain name was the part of very different strings of different length. I couldn’t use autoreplacement and had to change every occasion manually.

    I noticed this length a long time ago and as soon as I remember I made string replacement without correcting length and everything was ok earlier. But now I’ve got a problem.

    So the questions are:
    1) What’s the sense of this length and what part of WP uses it?
    2) Do you know any good automated way to replace constants and correct length?

    Thanks in advance!

    • This topic was modified 7 years, 10 months ago by Alexey.
    • This topic was modified 7 years, 10 months ago by bdbrown.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘String constant length in db’ is closed to new replies.