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

Parse URLs in Post text after DB Update

Sadik B

Well-known member
#1
So I migrated a phpBB forum to XF. There were all sorts of <a href> links in posts from which I successfully extracted the link within href attributes using Kier's Find and Replace addon which updated the DB.

So now the posts contain only links like this

http:// somesite.com (displayed as text, have put space here to demonstrate)

However the problem is that now all of these links are just being displayed as text. Meaning they are not parsed and surrounded by the tags. Also many of the links are youtube videos, which I thought would get auto-embedded since I have auto-embed enabled. However the links are just sitting there as text. If I click on "Edit" on a post with a link and save, the link is recognised and converted to url, but obviously I can't manually edit thousands of such posts.

I rebuilt the thread and search caches thinking some thing would trigger the post parser, but no joy... What am I doing wrong? Any suggestions?

Thanks...
 

Jake Bunce

XenForo moderator
Staff member
#3
Auto parsing / embedding happens on save. For your purposes you should use the find / replace tool to convert those plain URLs into hyperlinks and media embeds. Hyperlinks should be surrounded by URL tags. Media embeds should use this format:

Code:
[media=youtube]IDHERE[/media]
 

Sadik B

Well-known member
#4
Auto parsing / embedding happens on save. For your purposes you should use the find / replace tool to convert those plain URLs into hyperlinks and media embeds. Hyperlinks should be surrounded by URL tags. Media embeds should use this format:

Code:
[media=youtube]IDHERE[/media]
Hmmm, I get your point but there is no way to know which url in the post would be hyperlink and which would be a media embed (youtube or similar). I can probably though write a few regex for each url case and run the find replace tool.

I am curious though. If I change a BBCode definition, how does XF handle that? For instance what if I added a SCRIBD embed bbcode and then later wanted to change the embed code. Are you saying that old posts will not update for the changed BBCode?
 

Sadik B

Well-known member
#6
Thanks Jake... I was however wondering about the changing BBCode thing. It's just an academic question since I am not doing any such thing. But what if someone defined a BBCode and later changed it.
 

Jake Bunce

XenForo moderator
Staff member
#7
But what if someone defined a BBCode and later changed it.
Then you can use the find / replace tool to update previous media tags. Or use a query:

Code:
UPDATE xf_post
SET message = REPLACE(message, '[media=oldid]', '[media=newid]')
 
F

Floris

Guest
#9
If they edit their post, it will be parsed anyway, regardless of full url or bbcode