Advertisement:

Author Topic: 404 on Missing Topics/Boards  (Read 4378 times)

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
404 on Missing Topics/Boards
« on: November 17, 2014, 12:19:51 PM »
Link to Mod


404 STATUS ON MISSING BOARDS/TOPICS v2.3
By Dougiefresh -> Link to Mod


Install Requirements
This mod was tested on SMF 2.0.9, but should work on SMF 2.1 Beta 1 thru 3, as well as SMF 2.0 and up. SMF 1.x is not and will not be supported.

Introduction
This mod makes a minor change to the forum to return HTML error codes when topics and boards are missing or inaccessible.

Per Arantor's suggestion in his post, error handling has been changed so that:
=> Board number too high returns 404 (Not Found)
=> Deleted boards return 410 (Gone)
=> Inaccessible boards return 403 (Forbidden)
=> Topic number too high returns 404 (Not Found)
=> Deleted topics return 410 (Gone)
=> Inaccessible topics return 403 (Forbidden)

By definition, a 404 error code (Not Found) is this:
Quote
The requested resource could not be found but may be available again in the future. Subsequent requests by the client are permissible.
A 410 error code (Gone) is this:
Quote
Indicates that the resource requested is no longer available and will not be available again. This should be used when a resource has been intentionally removed and the resource should be purged. Upon receiving a 410 status code, the client should not request the resource again in the future. Clients such as search engines should remove the resource from their indices. [citation needed] Most use cases do not require clients and search engines to purge the resource, and a "404 Not Found" may be used instead.
A 403 error code (Forbidden) is this:
Quote
The request was a valid request, but the server is refusing to respond to it. Unlike a 401 Unauthorized response, authenticating will make no difference. On servers where authentication is required, this commonly means that the provided credentials were successfully authenticated but that the credentials still do not grant the client permission to access the resource (e.g. a recognized user attempting to access restricted content).

Admin Settings
There are no admin settings.  To disable it, you must remove this mod.

Related Discussion
o Is there a way to disable specific URL

Other Information
o This mod at my GitHub repository
o This Mod at XPtsp.com
o This mod on SMF's Customization Site

License
Copyright (c) 2014 - 2019, Douglas Orend
All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
« Last Edit: January 16, 2015, 07:26:31 PM by dougiefresh »

Offline Arantor

  • Resident Overthinker
  • SMF Friend
  • SMF Legend
  • *
  • Posts: 71,982
    • StoryBB/StoryBB on GitHub
Re: 404 on Missing Topics/Boards
« Reply #1 on: November 17, 2014, 12:32:47 PM »
I really like the idea. I am slightly wary on the implementation - please bear with me as I explain my reasoning.

There's consequences to 404 vs 410 that are not simple to deal with. 404 is, officially, a temporary response code. Receiving a 404 to any resource indicates that it 'may' be available in future. A topic that is not visible may or may not be technically 'gone'. 410 means 'won't be back, ever' and there's nothing in SMF to indicate whether this is really the case or not - which is potentially an issue for search engines.

Moving a topic out of a public board - and moving it back - is one case. Unapproving is another.

I don't think I'd actually encourage 410 for this; I know I mentioned it before but having gone away and studied what others do, I'm not sure it's right.

The biggest problem is that the error has no context for 'exists but not visible' vs 'doesn't exist'. The latter is clearly 404/410 while the former is 403 territory. Technically there are consequences for exposing 404 vs 410 vs 403 too in terms of people poking at content to see if it exists.

If I had to be brutally honest, I'd actually be inclined to suggest 403 for all fatal errors as a general state of affairs - if the topic is not available, and authentication wouldn't (necessarily) make a difference (as per HTTP spec). Hmm.

There's not really a good answer to this. I think what you've got is a *huge* improvement on what SMF does, but I'm not sure it's the best it could be - but I'm also not sure it *isn't*. This stuff is tricky to be perfectly semantically correct, and honestly any 4xx code would be better than a 200 response for an error page because the request cannot be satisfied and it is not because the server is 'incapable'.
Don’t try to tell me that some power can corrupt a person. You haven’t had enough to know what it’s like.

No good deed goes unpunished / No act of charity goes unresented.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #2 on: January 16, 2015, 07:26:05 PM »
v1.1 - January 16th, 2015
o License change to Simplified BSD.  No functionality change.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #3 on: April 06, 2015, 04:37:50 PM »
Uploaded v1.2 - April 6th, 2015
o Updated for SMF 2.1 Beta 1

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #4 on: September 20, 2016, 05:26:50 PM »
Uploaded v2.0 - September 20th, 2016
o Per Arantor's suggestion, error handling has been changed so that:
=> Deleted boards return 410 (Gone)
=> Inaccessible boards return 403 (Forbidden)
=> Board number too high returns 404 (Not Found)
=> Deleted topics return 410 (Gone)
=> Inaccessible topics return 403 (Forbidden)
=> Topic number too high returns 404 (Not Found)



@Arantor:  Thank you for your thoughts on my mod!  Your suggestion has been implemented, at least I think it has been fairly well....

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #5 on: July 12, 2017, 01:45:44 PM »
Uploaded July 5th, 2017
o Added support for SMF 2.1 Beta 3.
o Removed support for SMF 2.1 Beta 1 and 2.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #6 on: October 08, 2018, 09:50:48 PM »
Uploaded v2.2 - October 8th, 2018
o No functionality change.
o Updated documentation to point to new website and GitHub repository.

Offline dougiefresh

  • SMF Hero
  • ******
  • Posts: 2,859
  • Mod King
    • XPtsp.com Community
Re: 404 on Missing Topics/Boards
« Reply #7 on: May 22, 2019, 09:35:07 AM »
Uploaded v2.3 - May 22nd, 2018
o Updated for SMF 2.1 RC1 and RC2.