[wp-hackers] Phasing out use of wp_die() for comment errors

Lazyest Hacker lazyest at brimosoft.nl
Tue Nov 23 10:48:48 UTC 2010


I would support option #2. This is more like how most sites handle incorrect
forms.

Marcel 

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of John
Blackbourn
Sent: Tuesday, November 23, 2010 2:33 AM
To: wp-hackers at lists.automattic.com
Subject: [wp-hackers] Phasing out use of wp_die() for comment errors

I'd like to see what people think about replacing wp_die() for comment
errors with something a bit more graceful.

Here are the three potential errors that can occur when a comment is posted:

 * Missing required fields
 * Duplicate comment detected
 * Posting comments too quickly

These are currently handled by wp_die(). This isn't a user friendly
experience as it stops the user dead in their tracks and by default they
have to use browser navigation to return to where they were.

It is possible to override the wp_die_handler function so themes can make
this a little more user friendly, but it's still not great. What would be
ideal would be to return the user to the page they came from (in most cases
the post permalink) and show a helpful error message within context.

What are people's thoughts on how we could go about phasing out using
wp_die() in this situation? I'm thinking it would be something that a theme
would add support for. For example:

add_theme_support( 'error-handlers');

That might need a better name, but you get the idea. The theme would then
handle displaying errors (at the top of the page in a big yellow box, for
example).

Two ways this could be done:

 1. Redirect the browser back to the post permalink with an error code query
var appended which maps to a list of predefined, filterable error messages
(much like the 'message' query var used in the admin area).
 2. Instead of using 'wp-comments-post.php' for the comment form action, we
could switch to using the post permalink (the form for password protected
posts uses this). This would allow us to continue execution and use the
$_POST data to repopulate the comment form fields when required fields were
missing.

I had a look through Trac to see if anything to do with wp_die() had been
discussed recently, but didn't spot anything.

Thoughts?

John
_______________________________________________
wp-hackers mailing list
wp-hackers at lists.automattic.com
http://lists.automattic.com/mailman/listinfo/wp-hackers



More information about the wp-hackers mailing list