Ticket #44215: 44215.2.diff
File 44215.2.diff, 5.7 KB (added by , 6 years ago) |
---|
-
src/wp-includes/comment.php
diff --git src/wp-includes/comment.php src/wp-includes/comment.php index bc72b6e..0d8a5a1 100644
function wp_comments_personal_data_exporter( $email_address, $page = 1 ) { 3370 3370 break; 3371 3371 } 3372 3372 3373 if ( ! empty( $value ) ) { 3374 $comment_data_to_export[] = array( 3375 'name' => $name, 3376 'value' => $value, 3377 ); 3378 } 3373 $comment_data_to_export[] = array( 3374 'name' => $name, 3375 'value' => $value, 3376 ); 3379 3377 } 3380 3378 3381 3379 $data_to_export[] = array( -
src/wp-includes/user.php
diff --git src/wp-includes/user.php src/wp-includes/user.php index 40f227c..cd33f82 100644
function wp_user_personal_data_exporter( $email_address ) { 2885 2885 $user_data_to_export = array(); 2886 2886 2887 2887 foreach ( $user_prop_to_export as $key => $name ) { 2888 $value = '';2888 $value = false; 2889 2889 2890 2890 switch ( $key ) { 2891 2891 case 'ID': … … function wp_user_personal_data_exporter( $email_address ) { 2901 2901 case 'first_name': 2902 2902 case 'last_name': 2903 2903 case 'description': 2904 $value = $user_meta[ $key ][0]; 2904 if ( isset( $user_meta[ $key ] ) ) { 2905 $value = $user_meta[ $key ][0]; 2906 } 2905 2907 break; 2906 2908 } 2907 2909 2908 if ( ! empty( $value )) {2910 if ( false !== $value ) { 2909 2911 $user_data_to_export[] = array( 2910 2912 'name' => $name, 2911 2913 'value' => $value, -
tests/phpunit/tests/comment.php
diff --git tests/phpunit/tests/comment.php tests/phpunit/tests/comment.php index fdfb48b..1bb5238 100644
class Tests_Comment extends WP_UnitTestCase { 1145 1145 $this->assertTrue( $actual['done'] ); 1146 1146 1147 1147 // Number of exported comments. 1148 $this->assert Same( 1, count( $actual['data'] ));1148 $this->assertCount( 1, $actual['data'] ); 1149 1149 1150 1150 // Number of exported comment properties. 1151 $this->assert Same( 8, count( $actual['data'][0]['data'] ));1151 $this->assertCount( 8, $actual['data'][0]['data'] ); 1152 1152 1153 1153 // Exported group. 1154 1154 $this->assertSame( 'comments', $actual['data'][0]['group_id'] ); … … class Tests_Comment extends WP_UnitTestCase { 1201 1201 'comment_content' => 'Comment', 1202 1202 ); 1203 1203 1204 $c =self::factory()->comment->create( $args );1204 self::factory()->comment->create( $args ); 1205 1205 1206 1206 $actual = wp_comments_personal_data_exporter( $args['comment_author_email'] ); 1207 1207 1208 1208 $this->assertTrue( $actual['done'] ); 1209 1209 1210 1210 // Number of exported comments. 1211 $this->assert Same( 1, count( $actual['data'] ));1211 $this->assertCount( 1, $actual['data'] ); 1212 1212 1213 // Number of exported comment properties. 1214 $this->assert Same( 7, count( $actual['data'][0]['data'] ));1213 // Number of exported comment properties. Empty properties should be included. 1214 $this->assertCount( 8, $actual['data'][0]['data'] ); 1215 1215 } 1216 1216 1217 1217 /** … … class Tests_Comment extends WP_UnitTestCase { 1232 1232 'comment_content' => 'Comment', 1233 1233 ); 1234 1234 1235 $c =self::factory()->comment->create( $args );1235 self::factory()->comment->create( $args ); 1236 1236 1237 1237 $actual = wp_comments_personal_data_exporter( $args['comment_author_email'], 2 ); 1238 1238 1239 1239 $this->assertTrue( $actual['done'] ); 1240 1240 1241 1241 // Number of exported comments. 1242 $this->assert Same( 0, count( $actual['data'] ));1242 $this->assertCount( 0, $actual['data'] ); 1243 1243 } 1244 1244 } -
tests/phpunit/tests/user.php
diff --git tests/phpunit/tests/user.php tests/phpunit/tests/user.php index 4f9fa2b..a113bf1 100644
class Tests_User extends WP_UnitTestCase { 1581 1581 /** 1582 1582 * Testing the `wp_user_personal_data_exporter_no_user` function when no user exists. 1583 1583 * 1584 * @group privacy 1584 1585 * @ticket 43547 1585 1586 */ 1586 1587 function test_wp_user_personal_data_exporter_no_user() { … … class Tests_User extends WP_UnitTestCase { 1595 1596 } 1596 1597 1597 1598 /** 1598 * Testing the `wp_user_personal_data_exporter_no_user` function when the requested 1599 * user exists. 1599 * Testing the `wp_user_personal_data_exporter` function when the requested user exists. 1600 1600 * 1601 * @group privacy 1601 1602 * @ticket 43547 1602 1603 */ 1603 1604 function test_wp_user_personal_data_exporter() { … … class Tests_User extends WP_UnitTestCase { 1608 1609 $this->assertTrue( $actual['done'] ); 1609 1610 1610 1611 // Number of exported users. 1611 $this->assert Same( 1, count( $actual['data'] ));1612 $this->assertCount( 1, $actual['data'] ); 1612 1613 1613 1614 // Number of exported user properties. 1614 $this->assertSame( 11, count( $actual['data'][0]['data'] ) ); 1615 $this->assertCount( 11, $actual['data'][0]['data'] ); 1616 } 1617 1618 /** 1619 * User fields should be included in a data export when empty and excluded when they do not exist. 1620 * 1621 * @group privacy 1622 * @ticket 44215 1623 */ 1624 function test_wp_user_personal_data_exporter_removed_meta_fields() { 1625 $test_user = new WP_User( self::$contrib_id ); 1626 1627 $original_data = array( 1628 'description' => get_user_meta( $test_user->ID, 'description', true ), 1629 'first_name' => get_user_meta( $test_user->ID, 'first_name', true ), 1630 'last_name' => get_user_meta( $test_user->ID, 'last_name', true ), 1631 ); 1632 1633 delete_user_meta( $test_user->ID, 'first_name' ); 1634 delete_user_meta( $test_user->ID, 'last_name' ); 1635 update_user_meta( $test_user->ID, 'description', '' ); 1636 1637 $actual = wp_user_personal_data_exporter( $test_user->user_email ); 1638 1639 update_user_meta( $test_user->ID, 'description', $original_data['description'] ); 1640 update_user_meta( $test_user->ID, 'first_name', $original_data['first_name'] ); 1641 update_user_meta( $test_user->ID, 'last_name', $original_data['last_name'] ); 1642 1643 $this->assertTrue( $actual['done'] ); 1644 1645 // Number of exported users. 1646 $this->assertCount( 1, $actual['data'] ); 1647 1648 // Number of exported user properties. Empty fields remain, deleted fields do not. 1649 $this->assertCount( 9, $actual['data'][0]['data'] ); 1615 1650 } 1616 1651 }