Changeset 43061
- Timestamp:
- 05/01/2018 07:26:53 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/ajax-actions.php
r43060 r43061 4565 4565 * 4566 4566 * @type string $callback Callable eraser that accepts an email address and 4567 * a page and returns an array with the number of items4568 * removed, the number of itemsretained and any messages4567 * a page and returns an array with boolean values for 4568 * whether items were removed or retained and any messages 4569 4569 * from the eraser, as well as if additional pages are 4570 4570 * available. … … 4633 4633 } 4634 4634 4635 if ( ! array_key_exists( ' num_items_removed', $response ) ) {4635 if ( ! array_key_exists( 'items_removed', $response ) ) { 4636 4636 wp_send_json_error( 4637 4637 sprintf( 4638 4638 /* translators: %1$s: eraser friendly name, %2$d: array index */ 4639 __( 'Expected num_items_removed key in response array from %1$s eraser (index %2$d).' ),4639 __( 'Expected items_removed key in response array from %1$s eraser (index %2$d).' ), 4640 4640 esc_html( $eraser_friendly_name ), 4641 4641 $eraser_index … … 4644 4644 } 4645 4645 4646 if ( ! array_key_exists( ' num_items_retained', $response ) ) {4646 if ( ! array_key_exists( 'items_retained', $response ) ) { 4647 4647 wp_send_json_error( 4648 4648 sprintf( 4649 4649 /* translators: %1$s: eraser friendly name, %2$d: array index */ 4650 __( 'Expected num_items_retained key in response array from %1$s eraser (index %2$d).' ),4650 __( 'Expected items_retained key in response array from %1$s eraser (index %2$d).' ), 4651 4651 esc_html( $eraser_friendly_name ), 4652 4652 $eraser_index … … 4690 4690 // No erasers, so we're done. 4691 4691 $response = array( 4692 ' num_items_removed' => 0,4693 ' num_items_retained' => 0,4694 'messages' 4695 'done' 4692 'items_removed' => false, 4693 'items_retained' => false, 4694 'messages' => array(), 4695 'done' => true, 4696 4696 ); 4697 4697 } -
trunk/src/wp-admin/js/xfn.js
r43012 r43061 142 142 var erasersCount = $action.data( 'erasers-count' ); 143 143 144 var removedCount = 0;145 var retainedCount = 0;144 var hasRemoved = false; 145 var hasRetained = false; 146 146 var messages = []; 147 147 … … 153 153 var summaryMessage = strings.noDataFound; 154 154 var classes = 'notice-success'; 155 if ( 0 === removedCount) {156 if ( 0 === retainedCount) {155 if ( false === hasRemoved ) { 156 if ( false === hasRetained ) { 157 157 summaryMessage = strings.noDataFound; 158 158 } else { … … 161 161 } 162 162 } else { 163 if ( 0 === retainedCount) {163 if ( false === hasRetained ) { 164 164 summaryMessage = strings.foundAndRemoved; 165 165 } else { … … 193 193 } 194 194 var responseData = response.data; 195 if ( responseData. num_items_removed ) {196 removedCount += responseData.num_items_removed;197 } 198 if ( responseData. num_items_retained ) {199 retainedCount += responseData.num_items_removed;195 if ( responseData.items_removed ) { 196 hasRemoved = hasRemoved || responseData.items_removed; 197 } 198 if ( responseData.items_retained ) { 199 hasRetained = hasRetained || responseData.items_retained; 200 200 } 201 201 if ( responseData.messages ) { -
trunk/src/wp-includes/comment.php
r43058 r43061 3413 3413 if ( empty( $email_address ) ) { 3414 3414 return array( 3415 ' num_items_removed' => 0,3416 ' num_items_retained' => 0,3417 'messages' 3418 'done' 3415 'items_removed' => false, 3416 'items_retained' => false, 3417 'messages' => array(), 3418 'done' => true, 3419 3419 ); 3420 3420 } 3421 3421 3422 3422 // Limit us to 500 comments at a time to avoid timing out. 3423 $number = 500; 3424 $page = (int) $page; 3425 $num_items_removed = 0; 3423 $number = 500; 3424 $page = (int) $page; 3425 $items_removed = false; 3426 $items_retained = false; 3426 3427 3427 3428 $comments = get_comments( … … 3470 3471 } 3471 3472 3473 $items_retained = true; 3474 3472 3475 continue; 3473 3476 } … … 3480 3483 3481 3484 if ( $updated ) { 3482 $ num_items_removed++;3485 $items_removed = true; 3483 3486 clean_comment_cache( $comment_id ); 3487 } else { 3488 $items_retained = true; 3484 3489 } 3485 3490 } … … 3488 3493 3489 3494 return array( 3490 ' num_items_removed' => $num_items_removed,3491 ' num_items_retained' => count( $comments ) - $num_items_removed,3492 'messages' 3493 'done' 3495 'items_removed' => $items_removed, 3496 'items_retained' => $items_retained, 3497 'messages' => $messages, 3498 'done' => $done, 3494 3499 ); 3495 3500 } 3501 -
trunk/tests/phpunit/tests/comment.php
r43015 r43061 878 878 $actual = wp_comments_personal_data_eraser( 'nocommentsfound@local.host' ); 879 879 $expected = array( 880 ' num_items_removed' => 0,881 ' num_items_retained' => 0,882 'messages' 883 'done' 880 'items_removed' => false, 881 'items_retained' => false, 882 'messages' => array(), 883 'done' => true, 884 884 ); 885 885 … … 909 909 $actual = wp_comments_personal_data_eraser( $args['comment_author_email'] ); 910 910 $expected = array( 911 ' num_items_removed' => 1,912 ' num_items_retained' => 0,913 'messages' 914 'done' 911 'items_removed' => true, 912 'items_retained' => false, 913 'messages' => array(), 914 'done' => true, 915 915 ); 916 916 … … 940 940 $actual = wp_comments_personal_data_eraser( $args['comment_author_email'], 2 ); 941 941 $expected = array( 942 ' num_items_removed' => 0,943 ' num_items_retained' => 0,944 'messages' 945 'done' 942 'items_removed' => false, 943 'items_retained' => false, 944 'messages' => array(), 945 'done' => true, 946 946 ); 947 947 … … 976 976 977 977 $expected = array( 978 ' num_items_removed' => 0,979 ' num_items_retained' => 1,980 'messages' 981 'done' 978 'items_removed' => false, 979 'items_retained' => true, 980 'messages' => array( $message ), 981 'done' => true, 982 982 ); 983 983 … … 1012 1012 1013 1013 $expected = array( 1014 ' num_items_removed' => 0,1015 ' num_items_retained' => 1,1016 'messages' 1017 'done' 1014 'items_removed' => false, 1015 'items_retained' => true, 1016 'messages' => array( $message ), 1017 'done' => true, 1018 1018 ); 1019 1019
Note: See TracChangeset
for help on using the changeset viewer.