Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.3k views
in Q2A Core by
I understand it can be useful at troubleshooting but it's a turn off to every visitor who stumble upon this page.

What options are there to replace this for a standard 404 error?
Q2A version: 1.5.2

2 Answers

+1 vote
by
This page should never appear in normal operation, so if it is, that's a bug - please tell me!

Anyway you can change what happens for DB errors by overriding qa_page_db_fail_handler(...) in a plugin, e.g. redirecting somewhere else or whatever.
by
edited by
I am not getting 404 not found page, but it shows "Question2Answer query failed". More detailed info:

Question2Answer query failed:

SELECT qa_posts.postid as postid,qa_posts.title as title FROM qa_postmeta, qa_posts WHERE qa_postmeta.meta_key='merged_with' AND qa_postmeta.post_id='privacy-policy' AND qa_posts.postid=qa_postmeta.meta_value

Error 1146: Table 'nitin198_qstacks.qa_postmeta' doesn't exist

My site: http://qstacks.com

My plugins:
1: Widget Anywhere v1.2 by Scott Vivian
2: Share v1.2 by NoahY (latest)
3: Role Markers v1.1 by NoahY (latest unknown)
4: Privileges v0.1 by NoahY (latest)
5: Merge v0.1a by NoahY (latest unknown)
6: Newsletter v0.3 by NoahY (latest)
7: Faq Page v0.3 by NoahY (latest)
8: Embed v1.5 by NoahY (latest)
9: Comment Voting v1.4 by NoahY (latest)
10: Best Users per Month v1.1 by echteinfachtv (latest)

These are my additional plugins other than built in plugins.
Edited: The problem is because of the Post Merge Plugin. When I removed it, the problem disappears.
by
Sounds like an issue with the 'merge' plugin...
by
I've seen this issue quite a few times on my site. Regardless of whether it's in a plugin or not, Q2A shouldn't be outputting SQL queries on production sites...
by
Thanks Scott, I'm interested in your view on this. So you think it would make more sense to make people fish the query out of their web server error logs? I guess I've always done it that way because it made debugging easier, but I can see why it's not ideal...
by
may be search engines wants a "clean 404 not found" page. If the search engine recognizes the query failure as 404, then no issues. However, can you add an option to show this error only for admins or IPs of admins?
by
Yes, the error should be stored somewhere. I guess it depends on the server settings, if the webmaster has display_errors=On and logging turned off, the errors aren't going to be found anywhere.

I suppose you could store it in a file that's accessible via the Q2A admin area for example (and easily found in the filesystem if the error means Q2A is not accessible at all). Q2A has a debug option, right? That could be used to display errors and stuff on the site, in the case a user cannot use logging.

Pretty much anywhere you look it's frowned upon to display errors like that to the user as it is confusing. (Also by hiding errors you do get a little security by obscurity.) This is from php.ini:

; This directive controls whether or not and where PHP will output errors,
; notices and warnings too. Error output is very useful during development, but
; it could be very dangerous in production environments. Depending on the code
; which is triggering the error, sensitive information could potentially leak
; out of your application such as database usernames and passwords or worse.
; It's recommended that errors be logged on production servers rather than
; having the errors sent to STDOUT.
display_errors = Off

; Besides displaying errors, PHP can also log errors to locations such as a
; server-specific log, STDERR, or a location specified by the error_log
; directive found below. While errors should not be displayed on productions
; servers they should still be monitored and logging is a great way to do that.
log_errors = On
+2 votes
by
OK. Q2A 1.6 will hide the error from public view and (as in previous versions) log it via PHP's error_log() function.
...