- Feature Articles
- CodeSOD
- Error'd
-
Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
I'll take this wrong solution over the modern standard of not doing anything in the frist place and just letting links rot.
Edit Admin
Admin
Also there's no exit() after the header() calls, so any other code later in the page will continue to run. I've found a few sites accidentally emitting some tasty page content after they think the client has been redirected.
Edit Admin
When all you have is a 404, everything looks like a nail.
Edit Admin
Sure, but regardless of it being a wrong-headed solution(1), it's definitely better than doing nothing.
(1) It might have been a progressive thing. When there are two or three links to redirect, the approach here is much more manageable and less costly at runtime, but I agree that once the call to add the second batch of paths to the switch (hooray for C/C++ style switches that don't allow switch()ing on strings), whoever did it should have started thinking about there being a better way.
Well, this unfortunate person should have started thinking.
Edit Admin
TRWTF is that the code isn't written as
switch ($uri) { case "/SOMEURL": case "/SOMEOTHERURL": case "/YETANOTHERURL": // ... THERE ARE 300 of these ... case "/MOREURLS": case "/EVENMOREURLS": $redirect_url="http://www.SOMEWEBSITE.com" . $uri; break; }
No, wait, the real WTF is that this fscking site has absolutely no instructions on how to format the content of a post.
Admin
dpm> ... site has absolutely no instructions on how to format the content of a post.
Instructions!? C'mon. If you're here you're a programmer and we /never/ read instructions, especially not the blokes so why would anyone write instructions? I mean that's almost /documentation/. Now, go away and wash your mouth out with soap for using such nasty language.
Edit Admin
Pretty big talk for someone with a browser history full of "https://stackoverflow.com/xxxxxx"
Admin
I'd like to ignite the code, all right.
Edit Admin
We can all agree that the code would have been more elegantly solved by using a gigantic map instead of a gigantic switch case.
That controller router thing part of a framework, that looks complicated and probably involves having to read some doc or API. Nah, abusing a 404 error handler to return a 301, that's so much easier for later maintenance: the next intern maintaining this won't have to read any docs!
Edit Admin
It uses Markdown.
There you go: now this fscking site has instructions on how to format the content of a post. Just bookmark this comment.
Edit Admin
TRWTF is that the code isn't written as
Edit Admin
uh ... yap?? mebbe, sometimes!! I put a comment in the 10/21 post (https://thedailywtf.com/articles/comments/a-percentage-of-refactoring#comment-685669) and I used the dots and blah blah blah because "Surround a block of text with lines starting with three backticks to make it a code block" and THAT is what it came out as. On 10/21. Other days, I have used the three dots thing and it has worked as expected.
So ... not really "markdown" -- kinda like "marked down for quick sale" turns to "clearance" and eventually "everything must go" versions of this convenience. Then it's back to "markdown" when it feels like it
Edit Admin
... There are three dots above this line. ... There are three dots above this line, too. Wonder if it will work today
Edit Admin
I guess not?