Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions features/comment.feature
Original file line number Diff line number Diff line change
Expand Up @@ -249,3 +249,22 @@ Feature: Manage WordPress comments
"""
0
"""

Scenario: Make sure WordPress receives the slashed data it expects
When I run `wp comment create --comment_content='My\Comment' --porcelain`
Then save STDOUT as {COMMENT_ID}

When I run `wp comment get {COMMENT_ID} --field=comment_content`
Then STDOUT should be:
"""
My\Comment
"""

When I run `wp comment update {COMMENT_ID} --comment_content='My\New\Comment'`
Then STDOUT should not be empty

When I run `wp comment get {COMMENT_ID} --field=comment_content`
Then STDOUT should be:
"""
My\New\Comment
"""
2 changes: 2 additions & 0 deletions php/commands/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public function __construct() {
* Success: Created comment 932.
*/
public function create( $args, $assoc_args ) {
$assoc_args = wp_slash( $assoc_args );
parent::_create( $args, $assoc_args, function ( $params ) {
if ( isset( $params['comment_post_ID'] ) ) {
$post_id = $params['comment_post_ID'];
Expand Down Expand Up @@ -96,6 +97,7 @@ public function create( $args, $assoc_args ) {
* Success: Updated comment 123.
*/
public function update( $args, $assoc_args ) {
$assoc_args = wp_slash( $assoc_args );
parent::_update( $args, $assoc_args, function ( $params ) {
if ( !wp_update_comment( $params ) ) {
return new WP_Error( 'Could not update comment.' );
Expand Down