Incorrect id_topic in quote links

Started by Sir Osis of Liver, April 26, 2018, 04:59:00 PM

Previous topic - Next topic

Sir Osis of Liver

2.0.15 forum is running normally, but some quote links are incorrect.  id_msg 39082/id_topic 626 quotes id_msg 34372/id_topic 626, both are correct, but quote link to original message is to id_msg 34372/id_topic 2192.  id_topic 2192 does not exist.  Ran 'Find and repair any errors' maint task, no help.  DB was upgraded from 1.1.12 (with some difficulty), no reason to believe it's damaged.  Any idea what causes this?  Any way to fix it?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

vbgamer45

Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Sir Osis of Liver

This was a recovery job on an old forum that had been offline for a while.  It was poorly maintained, and changed hands, anything could have been done to it.  No admin log.  Only way I can see to fix it is manually edit each link in db as they're found.  With 40,000 posts, that's a long road. :P
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GigaWatt

Do the ID's exist in the old version of the forum? What I mean is, is everything redirected correctly when clicking on the quote link?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Sir Osis of Liver

Had this forum running in 1.1.12 before upgrade, but these links are scattered among 40,000 posts, so they're not easy to find.  I'm sure they were already bad, as the db contains the incorrect fields, upgrade wouldn't have changed them.
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

GigaWatt

Well, as vbgamer45 wrote, I also think that it's a topic merge/split issue. There isn't any other way that could've happened. If the values were null or a max integer, yeah, that would mean something went wrong with the script before the upgrade, when it was still running 1.1.12, but the values are random, like in user generated topic and post ID.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Illori

this has been fixed for new messages quoted in SMF 2.1, it uses the message id instead of the topic id. i dont think there is a good way to fix this for existing quotes.

GigaWatt

Will 2.1 also properly display the quotes posted in 2.0.x, or will the database converter convert the previous posts in the new system?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Illori

i dont think it will convert the existing but i have not checked. i am not even sure it is easily possible to do that.

GigaWatt

I have a few more questions, but I don't want to ruin the thread further. Could this thread be split in two different threads?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

Quote from: Sir Osis of Liver on April 26, 2018, 07:44:02 PM
Had this forum running in 1.1.12 before upgrade, but these links are scattered among 40,000 posts, so they're not easy to find.  I'm sure they were already bad, as the db contains the incorrect fields, upgrade wouldn't have changed them.

I suspect that a global search & replace from "forumurl/index.php?topic=xxx.msgyyy#msgyyy" format to "forumurl/index.php?msg=yyy" will fix it.   Note the 2nd format works fine, and this will eliminate references to the funky old topics.  I think this will require a somewhat straightforward preg_replace.  Uh...  I recommend testing the bejeebers out of it, of course!

Quote from: GigaWatt on April 27, 2018, 10:34:26 AM
Will 2.1 also properly display the quotes posted in 2.0.x, or will the database converter convert the previous posts in the new system?

The broken links are embedded in the message text, and there is no massaging of message text content in the upgrade to 2.1.   So, if there is a problem in the post in 2.0, it will exist in 2.1.   At some point, the post content must be fixed.

Working links will still work, of course.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

shawnb61

Thought about this while walking the dog... 

A slightly more complicated - but safer - route may be to lookup each link in each message in "forumurl/index.php?topic=xxx.msgyyy#msgyyy" format.  Query the message with ID yyy.  Confirm its topic is xxx.   

If its topic is not xxx, either rewrite the link with the proper topic ID or rewrite it in "forumurl/index.php?msg=yyy" format. 

This will minimize unnecessary updates. 
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

GigaWatt

Quote from: shawnb61 on April 28, 2018, 01:23:14 AM
Working links will still work, of course.

That's what I was asking. If everything was fine (working links) in 2.0, there will be a compatibility layer in 2.1 to cater the needs of it's predecessors, right? So, it would first check if the quote links are in the old or new format, then redirect, right?
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

No.   A broken link in 2.0 will be a broken link in 2.1.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

GigaWatt

I think you misunderstood me :). Everything is working fine in 2.0, quote links are working fine. I've updated to 2.1 which uses the new quote system (message ID only). When a post with a quote made in 2.0 is displayed in 2.1, will 2.1 have a compatibility layer to display and redirect those links properly ("aha, there's a quote in this post, OK, let's see if it's a 2.1 or a 2.0 quote... OK, it's 2.0, let's use the legacy quote system to display and redirect the quote").
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

shawnb61

(3rd try...)   No.    The message content is untouched, i.e., it stays in the old format.

Both formats work properly in 2.0 and 2.1.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

shawnb61

(Sorry if I was terse, above.  In my defense, that was a pre-coffee response...)

Curious to see how common this was, I wrote a quick utility to double-check links in quotes. 

I was expecting to find a few in my forum.  I was surprised to find a LOT - ~1800 broken quote links.  Fixing these manually is certainly not feasible for me.

I was surprised to see a fair amount of deletions also - where the message didn't exist at all anymore, in any topic.  I didn't think posts were deleted that often.  Apparently, they are.

For the curious, my (read only) diagnostic is here:
   https://github.com/sbulen/sjrbTools/blob/master/SMF_Topic_Link_Diag.php

Just dump it in your forum's home directory & execute from your browser.
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

GigaWatt

Yep, there are quite a few broken quote links on my forum too. Some are from deleted messages, but most are from split/merged topics.
"This is really a generic concept about human thinking - when faced with large tasks we're naturally inclined to try to break them down into a bunch of smaller tasks that together make up the whole."

"A 500 error loosely translates to the webserver saying, "WTF?"..."

Sir Osis of Liver

This seems like normal wear & tear to me, don't think there's any practical way to clean it up.  If a post is deleted, or topic is merged and original id_topic is deleted, it's still in message body.  You'd have to run a query that searched all messages (server load on large forums), and what do you do when you find a bad one?  How often does anyone use a quote link?
Ashes and diamonds, foe and friend,
 we were all equal in the end.

                                     - R. Waters

shawnb61

Quote from: Sir Osis of Liver on April 29, 2018, 12:04:22 AM
How often does anyone use a quote link?

Yep.   

BTW it is actually fairly easy to fix.  I have a new version of the above utility that swaps out the incorrect topic with the current one.  I've run it in all of my test environments.  Works fine.  Until the next time someone does a bunch of reorgs...
Address the process rather than the outcome.  Then, the outcome becomes more likely.   - Fripp

Advertisement: