Changeset 49271
- Timestamp:
- 10/22/2020 02:40:06 AM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-xmlrpc-server.php
r49183 r49271 3914 3914 3915 3915 if ( get_option( 'require_name_email' ) ) { 3916 if ( strlen( $comment['comment_author_email'] < 6 )|| '' === $comment['comment_author'] ) {3916 if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) { 3917 3917 return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); 3918 3918 } elseif ( ! is_email( $comment['comment_author_email'] ) ) { -
trunk/tests/phpunit/tests/xmlrpc/wp/newComment.php
r49268 r49271 97 97 $this->assertSame( 403, $result->code ); 98 98 } 99 100 /** 101 * Ensure anonymous comments can be made via XML-RPC. 102 * 103 * @ticket 51595 104 */ 105 function test_allowed_anon_comments() { 106 add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' ); 107 108 $comment_args = array( 109 1, 110 '', 111 '', 112 self::$post->ID, 113 array( 114 'author' => 'WordPress', 115 'author_email' => 'noreply@wordpress.org', 116 'content' => 'Test Anon Comments', 117 ), 118 ); 119 120 $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); 121 $this->assertNotIXRError( $result ); 122 $this->assertInternalType( 'int', $result ); 123 } 124 125 /** 126 * Ensure anonymous XML-RPC comments require a valid email. 127 * 128 * @ticket 51595 129 */ 130 function test_anon_comments_require_email() { 131 add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' ); 132 133 $comment_args = array( 134 1, 135 '', 136 '', 137 self::$post->ID, 138 array( 139 'author' => 'WordPress', 140 'author_email' => 'noreply at wordpress.org', 141 'content' => 'Test Anon Comments', 142 ), 143 ); 144 145 $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); 146 $this->assertIXRError( $result ); 147 $this->assertSame( 403, $result->code ); 148 } 149 150 /** 151 * Ensure valid users don't use the anon flow. 152 * 153 * @ticket 51595 154 */ 155 function test_username_avoids_anon_flow() { 156 add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' ); 157 158 $comment_args = array( 159 1, 160 'administrator', 161 'administrator', 162 self::$post->ID, 163 array( 164 'author' => 'WordPress', 165 'author_email' => 'noreply at wordpress.org', 166 'content' => 'Test Anon Comments', 167 ), 168 ); 169 170 $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); 171 $comment = get_comment( $result ); 172 $user_id = get_user_by( 'login', 'administrator' )->ID; 173 174 $this->assertSame( $user_id, (int) $comment->user_id ); 175 } 99 176 }
Note: See TracChangeset
for help on using the changeset viewer.