Changeset 43110
- Timestamp:
- 05/02/2018 03:43:37 AM (6 years ago)
- Location:
- branches/4.9
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/4.9
-
branches/4.9/src/wp-admin/includes/ajax-actions.php
r43107 r43110 4256 4256 * 4257 4257 * @type string $callback Callable eraser that accepts an email address and 4258 * a page and returns an array with the number of items4259 * removed, the number of itemsretained and any messages4258 * a page and returns an array with boolean values for 4259 * whether items were removed or retained and any messages 4260 4260 * from the eraser, as well as if additional pages are 4261 4261 * available. … … 4324 4324 } 4325 4325 4326 if ( ! array_key_exists( ' num_items_removed', $response ) ) {4326 if ( ! array_key_exists( 'items_removed', $response ) ) { 4327 4327 wp_send_json_error( 4328 4328 sprintf( 4329 4329 /* translators: 1: eraser friendly name, 2: array index */ 4330 __( 'Expected num_items_removed key in response array from %1$s eraser (index %2$d).' ),4330 __( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ), 4331 4331 esc_html( $eraser_friendly_name ), 4332 4332 $eraser_index … … 4335 4335 } 4336 4336 4337 if ( ! array_key_exists( ' num_items_retained', $response ) ) {4337 if ( ! array_key_exists( 'items_retained', $response ) ) { 4338 4338 wp_send_json_error( 4339 4339 sprintf( 4340 4340 /* translators: 1: eraser friendly name, 2: array index */ 4341 __( 'Expected num_items_retained key in response array from %1$s eraser (index %2$d).' ),4341 __( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ), 4342 4342 esc_html( $eraser_friendly_name ), 4343 4343 $eraser_index … … 4381 4381 // No erasers, so we're done. 4382 4382 $response = array( 4383 ' num_items_removed' => 0,4384 ' num_items_retained' => 0,4385 'messages' 4386 'done' 4383 'items_removed' => false, 4384 'items_retained' => false, 4385 'messages' => array(), 4386 'done' => true, 4387 4387 ); 4388 4388 } -
branches/4.9/src/wp-admin/js/xfn.js
r43092 r43110 137 137 var erasersCount = $action.data( 'erasers-count' ); 138 138 139 var removedCount = 0;140 var retainedCount = 0;139 var hasRemoved = false; 140 var hasRetained = false; 141 141 var messages = []; 142 142 … … 148 148 var summaryMessage = strings.noDataFound; 149 149 var classes = 'notice-success'; 150 if ( 0 === removedCount) {151 if ( 0 === retainedCount) {150 if ( false === hasRemoved ) { 151 if ( false === hasRetained ) { 152 152 summaryMessage = strings.noDataFound; 153 153 } else { … … 156 156 } 157 157 } else { 158 if ( 0 === retainedCount) {158 if ( false === hasRetained ) { 159 159 summaryMessage = strings.foundAndRemoved; 160 160 } else { … … 188 188 } 189 189 var responseData = response.data; 190 if ( responseData. num_items_removed ) {191 removedCount += responseData.num_items_removed;192 } 193 if ( responseData. num_items_retained ) {194 retainedCount += responseData.num_items_removed;190 if ( responseData.items_removed ) { 191 hasRemoved = hasRemoved || responseData.items_removed; 192 } 193 if ( responseData.items_retained ) { 194 hasRetained = hasRetained || responseData.items_retained; 195 195 } 196 196 if ( responseData.messages ) { -
branches/4.9/src/wp-includes/comment.php
r43092 r43110 3283 3283 if ( empty( $email_address ) ) { 3284 3284 return array( 3285 ' num_items_removed' => 0,3286 ' num_items_retained' => 0,3287 'messages' 3288 'done' 3285 'items_removed' => false, 3286 'items_retained' => false, 3287 'messages' => array(), 3288 'done' => true, 3289 3289 ); 3290 3290 } 3291 3291 3292 3292 // Limit us to 500 comments at a time to avoid timing out. 3293 $number = 500; 3294 $page = (int) $page; 3295 $num_items_removed = 0; 3293 $number = 500; 3294 $page = (int) $page; 3295 $items_removed = false; 3296 $items_retained = false; 3296 3297 3297 3298 $comments = get_comments( … … 3340 3341 } 3341 3342 3343 $items_retained = true; 3344 3342 3345 continue; 3343 3346 } … … 3350 3353 3351 3354 if ( $updated ) { 3352 $ num_items_removed++;3355 $items_removed = true; 3353 3356 clean_comment_cache( $comment_id ); 3357 } else { 3358 $items_retained = true; 3354 3359 } 3355 3360 } … … 3358 3363 3359 3364 return array( 3360 ' num_items_removed' => $num_items_removed,3361 ' num_items_retained' => count( $comments ) - $num_items_removed,3362 'messages' 3363 'done' 3365 'items_removed' => $items_removed, 3366 'items_retained' => $items_retained, 3367 'messages' => $messages, 3368 'done' => $done, 3364 3369 ); 3365 3370 } 3371 -
branches/4.9/tests/phpunit/tests/comment.php
r43093 r43110 766 766 $actual = wp_comments_personal_data_eraser( 'nocommentsfound@local.host' ); 767 767 $expected = array( 768 ' num_items_removed' => 0,769 ' num_items_retained' => 0,770 'messages' 771 'done' 768 'items_removed' => false, 769 'items_retained' => false, 770 'messages' => array(), 771 'done' => true, 772 772 ); 773 773 … … 797 797 $actual = wp_comments_personal_data_eraser( $args['comment_author_email'] ); 798 798 $expected = array( 799 ' num_items_removed' => 1,800 ' num_items_retained' => 0,801 'messages' 802 'done' 799 'items_removed' => true, 800 'items_retained' => false, 801 'messages' => array(), 802 'done' => true, 803 803 ); 804 804 … … 828 828 $actual = wp_comments_personal_data_eraser( $args['comment_author_email'], 2 ); 829 829 $expected = array( 830 ' num_items_removed' => 0,831 ' num_items_retained' => 0,832 'messages' 833 'done' 830 'items_removed' => false, 831 'items_retained' => false, 832 'messages' => array(), 833 'done' => true, 834 834 ); 835 835 … … 864 864 865 865 $expected = array( 866 ' num_items_removed' => 0,867 ' num_items_retained' => 1,868 'messages' 869 'done' 866 'items_removed' => false, 867 'items_retained' => true, 868 'messages' => array( $message ), 869 'done' => true, 870 870 ); 871 871 … … 900 900 901 901 $expected = array( 902 ' num_items_removed' => 0,903 ' num_items_retained' => 1,904 'messages' 905 'done' 902 'items_removed' => false, 903 'items_retained' => true, 904 'messages' => array( $message ), 905 'done' => true, 906 906 ); 907 907
Note: See TracChangeset
for help on using the changeset viewer.