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

Design Issue Permalinks can be broken upon post deletion in a thread.

Discussion in 'Resolved Bug Reports' started by TimWF, Feb 15, 2011.

  1. TimWF

    TimWF Active Member

    The way that the permalinks are formatted it is possible for them to be broken when posts are removed from a thread if the post that is deleted comes before a post in the thread that is linked to with a permalink before the deletion. The reason for this is because whenever a post is deleted the posts that happened after that are all shifted in their place within the thread and can move from one page to another in that process and the permalink itself specifies a specific page with an anchor on it. Example as I'm sure you are aware of:


  2. Brogan

    Brogan XenForo Moderator Staff Member

    That link works fine for me.
    Did you perhaps mean to link to another post?

    For the record, deleted posts have the same post ID as the one immediately preceding them.
    So if for example there were 3 deleted posts before this one, they would all have an ID of 1.
  3. TimWF

    TimWF Active Member

    That isn't an example of it breaking, just an example of the format. If you were to delete a post before that post in particular (on pages 1-4) that would move that post onto page 4 and then the link above would be broken.
  4. Brogan

    Brogan XenForo Moderator Staff Member

    The permalink updates for all posts after the deleted post, when a post is deleted.

    You can test this on your own forum by having a thread with 2 or 3 pages of posts, check the permalink of the first post on page 2 or 3, delete a post from page 1 and the first post on each page will shift to the previous page with a new permalink URL.
  5. Digital Doctor

    Digital Doctor Well-Known Member

  6. TimWF

    TimWF Active Member

    Yes, that isn't the issue though, sorry, I'm not being as descriptive as I could be. :)

    XF updates the link on the page, but that changes a link that was supposed to be a peramalink to the post, so it becomes and non-permalink as anyone that linked to that specific post before the deletion now has a link that doesn't link to the post it should anymore. :)
  7. Brogan

    Brogan XenForo Moderator Staff Member

    I think what Tim means is if you create a link to a post on a page which then shifts to the page before due to a post being deleted, then that link will no longer take you to the post as it will load the incorrect page.

    Is that right?

    Edit: Ninja'ed :D
  8. TimWF

    TimWF Active Member

    Exactly what I'm getting at, just not the clearest communication on my part I'm sure. :)

    Just by chance in looking at my notification for posts in this thread it seems that someone might have noticed/thought of this before during development as the links in the emails are formatted in a way that doesn't seem to have that problem:

  9. James

    James Well-Known Member

    Wouldn't this be as designed? The only way to change it would be to redirect the old permalink to the new permalink...

    It's the same for anything... delete it and its link will no longer work... right? [​IMG]

    or am I completely missing the bigger picture here...
  10. Brogan

    Brogan XenForo Moderator Staff Member

    I expect it is as designed as the original position would need to be stored in a table, along with the new position to be able to redirect any historic links (using the current URL format).
    The only field in the xf_post table is the position field.

    I'm sure Kier or Mike will be along to confirm before too long.
  11. TimWF

    TimWF Active Member

    I would be surprised if it intended for permalinks to change/break as it is opposed to the very idea. It could be that my interpretation that they are intended to be permanent links to individual posts is incorrect though, that is possible.

    Another angle to think of on this, changing the messages per page setting in the admin under "Options" > "Threads, Discussions..." would mess up previously linked content all over the site.

    The easy fix is to change the format of the permalink to a format that doesn't change when portions of a thread are removed.
  12. Mike

    Mike XenForo Developer Staff Member

    You can change the link to {xen:link posts, $post} and it would work, but you end up with a much less useful looking link - this is how it was originally actually. We optimized for the common case though, so yes this can happen.
    James likes this.
  13. TimWF

    TimWF Active Member

    Cool, thanks Mike. That is exactly what I was planning on looking into doing (formatting the link as it is in the emails, I'm guessing that that is what your suggestion does). :) I'm sure you know this, but you don't have to choose between a useful looking link and one that works all the time. I think that would require changing the link that is now used slightly so something along the lines of (random example from above that I used):


    Then you could easily redirect the link to the right page if it had been moved without maintaining any sort of lookup table as Brogan suggested.

    I'm fine with changing the link in the template as you suggest, but still would recommend that default be updated. :)
  14. James

    James Well-Known Member

    The reason that the link was changed from /posts/postid to /thread-title.id/#inline-anchor-id is because the /posts/ link carries an SEO penalty.

    The link format you suggested above I don't agree with. Posts shouldn't form part of the URL structure as that would suggest you are linking to a direct post, when in fact you're linking to a thread. It also imposes a problem with SEO because your above link will be considered an actual link to search engines, whereas the inline anchors aren't followed by SEs.
    Brogan likes this.
  15. TimWF

    TimWF Active Member

    Interesting perspective James, thanks for elaborating on the reasoning behind why the change was likely made. I still think it isn't the best way to go from the perspective that it doesn't function under some conditions the way it is as a default now, I love seeing SEO being considered to that detail most certainly, but hate to see functionality suffer at the expense of it. Either way looks like I have a workaround.
  16. James

    James Well-Known Member

Share This Page