XF 2.2 URL unfurling, can it be (re)applied to existing post links?

bzcomputers

Well-known member
I have a XenForo site that is about to go through a domain change. In the testing process I went through and updated the old url domain links that existed in posts to the new domain name.

SQL:
UPDATE `xf_post` set `message` = replace(`message`, '/www.olddomain.com/', '/www.newdomain.com/')

This has caused all unfurled links to no longer show the enhanced unfurl view and the link appears as a normal link. When previewing the link it still shows
Code:
 [URL unfurl="true"]link here[/URL]
for each link.

My question is... Is there anyway to reapply the unfurl process, that occurs when submitting a post, to all the already existing post links?
 
I see the xf_unfurl_result table has a url_hash column which is likely why the new url is not working.

Seems a complete url unfurl rebuild process should be available.

Anyone have some feedback?
 
I am going to give this one a try...

My plan:
1) Empty the current xf_unfurl_result table
2) Edit posts with old site domain using this sql
SQL:
UPDATE `xf_post` set `message` = replace(`message`, '/www.olddomain.com/', '/www.newdomain.com/')
3) Resave all posts with addon

I'll report results.
@AndyB any idea if this might work?
 
Just a thought, we had a similar issue after changing servers, and it turned out to be connected to the server not the Unfurl.

More here:

 
unfurling is a pain tbh. it would only work if you have a raw url processed on posting the post reply link. that adds an entry into the database. without that raw processing, it just does not work. if you have a bbcode url, it would not get processed. even if you manually add unfurl="true" to link bbcode, it would not work. it might work if the links are unlinked and you process the post through the resave all post addon.
 
it would not work. it might work if the links are unlinked and you process the post through the resave all post addon.

This does work, but it is still not as straight forward as you would hope.

When moving a XenForo site to a new domain, I first thought updating the the domain url in links and removing the unfurl bb code and resaving would be simple fix to get all the unfurl data updated... I was wrong.

First thought was to do this (DO NOT DO THIS):
1) Clear current unfurl code from posts
SQL:
UPDATE `xf_post` set `message` = replace(`message`, '/www.olddomain.com/', '/www.newdomain.com/')
UPDATE `xf_post` set `message` = replace(`message`, '[URL unfurl="true"]', '')
UPDATE `xf_post` set `message` = replace(`message`, '[/URL]', '')
2) Truncate the xf_unfurl_result table
3) Then resave all posts

This would have worked but removing "[/URL]" code from message links will also remove it from all the non-unfurl links found in posts. Then if you are looking at targeting older links that were around before unfurl was an option you will run into more issues. Issues like... there appears to have been some changes in how links were saved by XenForo over the years. I've only been running XenForo since 2.0 and some links have "URL" some "url" some "url=" and I believe at least one other bbcode for links I came across when searching the database. Not sure what posts from XenForo versions prior to 2.0 might have. The main issue is targeting ALL the links that can be unfurled and removing their bbcode and then resaving the posts.

Then in order for the additional unfurl link data to be stored into the database (title, description, image url, fav icon url) the post must be reloaded/refreshed by going to the actual page, otherwise the data does not repopulate until some does (which isn't really a big deal). This would normally happen when you make a post and the browser refreshes the page after the post is saved, this does not happen when resaving all posts with the add-on linked above.

XenForo also does not unfurl all links by default (even with unfurl option turned on). For example automatic posts created when adding a resource or updating a resource have links that are created that are not unfurled even with unfurl option turned on. May be an oversight or bug, but it has never happened since unfurl was introduced.

The only real sane way for this to be done would be for XenForo to add it as an option, or for an add-on to be created for it.

If you want an easier way to rebuild or fix unfurl issues I suggest you support the suggestion below:
https://xenforo.com/community/threads/url-unfurl-rebuild-process-for-internal-own-site.210218/
 
Back
Top Bottom