Changeset 49273
- Timestamp:
- 10/22/2020 02:45:47 AM (4 years ago)
- Location:
- branches/5.5
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.5
-
branches/5.5/src/wp-includes/class-wp-xmlrpc-server.php
r48590 r49273 3913 3913 3914 3914 if ( get_option( 'require_name_email' ) ) { 3915 if ( strlen( $comment['comment_author_email'] < 6 )|| '' === $comment['comment_author'] ) {3915 if ( strlen( $comment['comment_author_email'] ) < 6 || '' === $comment['comment_author'] ) { 3916 3916 return new IXR_Error( 403, __( 'Comment author name and email are required.' ) ); 3917 3917 } elseif ( ! is_email( $comment['comment_author_email'] ) ) { -
branches/5.5/tests/phpunit/tests/xmlrpc/wp/newComment.php
r47122 r49273 96 96 } 97 97 98 /** 99 * Ensure anonymous comments can be made via XML-RPC. 100 * 101 * @ticket 51595 102 */ 103 function test_allowed_anon_comments() { 104 add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' ); 105 $this->make_user_by_role( 'administrator' ); 106 $post = self::factory()->post->create_and_get(); 107 108 $comment_args = array( 109 1, 110 '', 111 '', 112 $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 $this->make_user_by_role( 'administrator' ); 133 $post = self::factory()->post->create_and_get(); 134 135 $comment_args = array( 136 1, 137 '', 138 '', 139 $post->ID, 140 array( 141 'author' => 'WordPress', 142 'author_email' => 'noreply at wordpress.org', 143 'content' => 'Test Anon Comments', 144 ), 145 ); 146 147 $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); 148 $this->assertIXRError( $result ); 149 $this->assertSame( 403, $result->code ); 150 } 151 152 /** 153 * Ensure valid users don't use the anon flow. 154 * 155 * @ticket 51595 156 */ 157 function test_username_avoids_anon_flow() { 158 add_filter( 'xmlrpc_allow_anonymous_comments', '__return_true' ); 159 $this->make_user_by_role( 'administrator' ); 160 $post = self::factory()->post->create_and_get(); 161 162 $comment_args = array( 163 1, 164 'administrator', 165 'administrator', 166 $post->ID, 167 array( 168 'author' => 'WordPress', 169 'author_email' => 'noreply at wordpress.org', 170 'content' => 'Test Anon Comments', 171 ), 172 ); 173 174 $result = $this->myxmlrpcserver->wp_newComment( $comment_args ); 175 $comment = get_comment( $result ); 176 $user_id = get_user_by( 'login', 'administrator' )->ID; 177 178 $this->assertSame( $user_id, (int) $comment->user_id ); 179 } 98 180 }
Note: See TracChangeset
for help on using the changeset viewer.