8

While browsing a specific deleted question on MSE I noticed something strange: it's almost impossible to get to the second page of results. There are supposed to be 34 answers. The first page shows 30. I'm not sure why this is happening and I haven't been able to replicate this with any other question.

Clicking on "2" or "next" (which have the same URL) goes to https://meta.stackexchange.com/questions/22795#tab-top which scrolls to "34 answers" and shows the first page of answers.

The revision history of one of the missing answers can be viewed here. Clicking "Return to Answer" goes to https://meta.stackexchange.com/questions/22795#22802, which goes to the question, showing the first page of answers beneath.


Note: Because all these posts are deleted, you need 10k rep here to see them.

  • As an aside, while trying to repro this on mobile, I noticed that it displays "0 answers" despite being able to see the deleted answers, which looks really weird. But there are no spam/offensive deleted answers on tbat question. – animuson Jan 19 at 23:37
  • Out of curiosity, could you clarify what you mean by redirect? Does clicking the link to another page just not properly add the page parameter to the URL, or is it literally redirecting from page 2 back to page 1, changing the URL? – animuson Jan 19 at 23:42
  • @animuson I've found the bug's cause. Will post an answer with details. – Sonic the Anonymous WizHog Jan 19 at 23:49
  • FYI: The development branch of the SOUP user script now has a workaround for this. Try installing the development version and check to see if this issue still exists. – Sonic the Anonymous WizHog Apr 10 at 8:00
  • Cross-site duplicate on MSO: meta.stackoverflow.com/questions/385951/… – Sonic the Anonymous WizHog Jun 14 at 4:48
10

I think I've discovered the cause of this bug. The post you linked not only has helpful spam or abuse flags, but it was also locked after being deleted, so the system treats it as if it were deleted as spam or abuse (those are locked at the same time as being deleted), and as such attempts to strip the title from the URL. The regex that removes the title from URLs of posts deleted as spam or abuse is a little bit too lenient: it also chops off query strings from the title when it shouldn't.

Most questions that are deleted (for any reason other than spam or abusive) don't have their URL title slug removed, and going to a short link or any link redirects to the full-form link that contains the title:

/questions/[post ID]/title-of-deleted-post

As an example, try clicking on this link: https://meta.stackexchange.com/q/321293. Even if you're a <10k user, the title of that deleted post will still be visible in the URL after the redirect.

In the past, this was true for all deleted questions. However, later on, spammers began to exploit this fact (e.g. https://meta.stackexchange.com/q/234567), so the team decided to strip the URL slug out from such posts*. Therefore, links like:

/q/22795

or:

/questions/22795/placeholder-for-title-of-question

redirect to:

/questions/22795

This happens for all users, 10k+ or not.

The bug lies in the fact that when performing the title stripping, the system considers everything after the ID to be part of the title, and strips them out. This means that things like ?page=2 get stripped out.

I've discovered that the stripping logic does not take place if I manually remove the title from the URL, and links like:

/questions/22795?page=2

...work properly and go to the second page. Even if you insert a / between the post ID and the query string, it works correctly.

The pagination links, however, use the below type of link:

/questions/22795/placeholder-for-title-of-question?page=2

...which triggers the bug and everything after the post ID is stripped out.

I can think of a few possible fixes:

  • Do not include the title URL slug in the pagination link if the post is considered to have been deleted as spam or abuse. This seems a little too specific for this edge case; it's extremely rare for a question with lots of answers to occupy multiple pages to be deleted as spam or abuse, or for it to be manually locked after being deleted.

  • Do not include the title URL slug in the pagination link at all. This seems like it would result in too many redirects.

  • Do not strip out titles from URLs if the user has 10k+ rep. This might be too complicated.

  • Fix the stripping logic to not remove query strings. I think this is the best solution.

You may have noticed that fragments (e.g. #22802) don't get removed. This is because they're not sent to the server, where the URL stripping takes place.

I think the same applies for the answer links: the "Return to Answer" links include the post title in the URL, which results in everything after the question ID getting stripped, including the part of the URL that results in the page changing if the answer is not on the first page.

Update: The development branch of the SOUP user script now contains a workaround for the page link issue. (It doesn't resolve the issue with the "Return to Answer" links.) This is planned for the next stable release (1.56).


* As the user was destroyed instead of the post being deleted as spam, it wasn't locked at the same time as being deleted, so it still remains as a live example. The change was applied retroactively to all posts, including the one you linked.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .