#34059 closed task (blessed) (fixed)
Abstract functionality from wp-comments-post.php
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 4.4 | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Comments | Keywords: | has-patch has-unit-tests commit |
| Focuses: | Cc: |
Description
wp-comments-post.php is a remnant of days gone past and a great example of technical debt. Everything going in is slashed, and every error condition results in an exit, except when it results in a redirect header followed by an exit.
There's not much we can do about this, but what we can do it abstract a bunch of the code into a function, in order to make the actual process of submitting a comment unit testable.
Attachments (5)
Change History (14)
#2
@
10 years ago
- Keywords has-unit-tests dev-feedback added; needs-unit-tests removed
34059.3.diff introduces tests for comment posting.
Anyone want to review this?
#3
@
10 years ago
34059.4.diff includes updated tests for multisite.
#5
@
10 years ago
Only two things that jumped out at me:
- If the ternaries are aligned like that because they started wrapping to new lines, we might as well just do if/else statements. Or initialize the nulls as null and 0s as 0s first, then do if statements to set values from the
$comment_dataarray. - I think
wp_handle_comment_post()might be a little too ambiguous and easily confused with post as in post type instead of post as in$_POST
#6
@
10 years ago
- Keywords commit added; dev-feedback removed
In 34059.5.diff:
- Renames
wp_handle_comment_post()towp_handle_comment_submission(). - Initialises the
$comment_*variables to avoid the ternaries. - Adds a test for comment content that contains slashes.
I think this is good to go.
Note: See
TracTickets for help on using
tickets.
34059.diff introduces
wp_handle_comment_post()which accepts an unslashed array of comment data and returns aWP_CommentorWP_Errorobject.Unit tests are in progress.