1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.4 Mass replacing text in posts

Discussion in 'XenForo Questions and Support' started by bloop, Jul 3, 2015.

  1. bloop

    bloop Member

    I recently changed domain names and we have some posts that use the old forum domain name. How would I go about doing this? Through sql queries?

    I've tried using Post Content Find / Replace 1.0.0 but the amount of posts that it needed to replace was too large and it ended up freezing mysql and server.

    Thanks for reading!
  2. Brogan

    Brogan XenForo Moderator Staff Member

    UPDATE xf_post SET message = REPLACE(message,'current_content','new_content');
    RoldanLT and bloop like this.
  3. bloop

    bloop Member

    Thanks @Brogan, is there a way to do per node or thread? Would the server freeze up if I did that through phpmyadmin? Around 60k threads would need updating

    I found another post of yours regarding updating prefixes, could you tell me if this would work?

    UPDATE xf_post SET where node_id in (9,15,18) message = REPLACE(message,'current_content','new_content');
  4. Mike

    Mike XenForo Developer Staff Member

    In theory you can do it but it's much more complex than that since the node isn't part of the post.

    If you have a large forum, it may be worth closing the forum when running the query, but otherwise it may take some time, but it should work.

    Please take a backup before running any queries like that. It can't necessarily be undone.
    bloop likes this.
  5. bloop

    bloop Member

    I ran the query successfully, but I noticed some (not all) threads still show the old content, but when I click edit for the post with the old content it automatically changes back to the new content name. Not sure what to do now, I thought the next thing I should do is to rebuild posts but there isnt an option for that.

    What should I do?

    Thanks for the help! @Mike @Brogan
  6. Brogan

    Brogan XenForo Moderator Staff Member

    That sounds to me like some sort of caching is involved.

    Try disabling and enabling the 'Cache BB Code output' option.
    bloop likes this.
  7. bloop

    bloop Member

    Thanks @Brogan that sorta did it. When I have bb code disabled all posts were replaced with the new content but when I enabled it again, some posts still had the old content but less than before. I'm running maxcdn as well so I'm assuming that may be causing it.

    Anyhow, the amount of posts that had incorrect info was small so I just ended up manually editing each one.

  8. RoldanLT

    RoldanLT Well-Known Member

    I have some issue Brogan.
    I want to replace:

    Old content: ’
    Correct character: '

    Here's my query:
    But I got an error:
  9. RoldanLT

    RoldanLT Well-Known Member

  10. wang

    wang Well-Known Member

    Try this.

    UPDATE xf_post SET message REPLACE(message,'’'" ' ");
    But make a backup first of your post table.
  11. Brogan

    Brogan XenForo Moderator Staff Member

    Try escaping it.
  12. RoldanLT

    RoldanLT Well-Known Member

    But that will add space.
    I just want to replace ’ with a single '.
  13. RoldanLT

    RoldanLT Well-Known Member

    UPDATE xf_post SET message REPLACE(message,'’','\'');
    That one?
  14. RoldanLT

    RoldanLT Well-Known Member

    This works for me:
    UPDATE xf_post SET message REPLACE(message,'’','''');

Share This Page