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

Todd Lahman todd at lahman.com
Tue Nov 23 06:43:16 UTC 2010


I would prefer a method that allows the ability to override the behaviors of
wp-comments-post.php through filters, actions, and by way of a function that
also takes arguments. This way wp_die() remains, and control over
wp-comments-post.php is added without having to manually change the file.

Todd

-----Original Message-----
From: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] On Behalf Of John
Blackbourn
Sent: Monday, November 22, 2010 5:33 PM
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