Ticket #8175: 8175.3.diff
File 8175.3.diff, 29.1 KB (added by , 5 years ago) |
---|
-
src/bp-activity/bp-activity-functions.php
diff --git src/bp-activity/bp-activity-functions.php src/bp-activity/bp-activity-functions.php index 1f0f85591..6a4400bf4 100644
function bp_activity_remove_all_user_data( $user_id = 0 ) { 1277 1277 do_action( 'bp_activity_remove_all_user_data', $user_id ); 1278 1278 } 1279 1279 add_action( 'wpmu_delete_user', 'bp_activity_remove_all_user_data' ); 1280 add_action( 'delete_user', 'bp_activity_remove_all_user_data' ); 1280 1281 /** 1282 * Deletes user activity data on the 'delete_user' hook. 1283 * 1284 * @since 6.0.0 1285 * 1286 * @param int $user_id The ID of the deleted user. 1287 */ 1288 function bp_activity_remove_all_user_data_on_delete_user( $user_id ) { 1289 if ( ! bp_remove_user_data_on_delete_user_hook( 'activity', $user_id ) ) { 1290 return; 1291 } 1292 1293 bp_activity_remove_all_user_data( $user_id ); 1294 } 1295 add_action( 'delete_user', 'bp_activity_remove_all_user_data_on_delete_user' ); 1281 1296 1282 1297 /** 1283 1298 * Mark all of the user's activity as spam. -
src/bp-blogs/bp-blogs-functions.php
diff --git src/bp-blogs/bp-blogs-functions.php src/bp-blogs/bp-blogs-functions.php index d9384741a..139b2f953 100644
function bp_blogs_remove_data( $user_id ) { 1433 1433 do_action( 'bp_blogs_remove_data', $user_id ); 1434 1434 } 1435 1435 add_action( 'wpmu_delete_user', 'bp_blogs_remove_data' ); 1436 add_action( 'delete_user', 'bp_blogs_remove_data' );1437 1436 add_action( 'bp_make_spam_user', 'bp_blogs_remove_data' ); 1438 1437 1438 /** 1439 * Deletes user XProfile data on the 'delete_user' hook. 1440 * 1441 * @since 6.0.0 1442 * 1443 * @param int $user_id The ID of the deleted user. 1444 */ 1445 function bp_blogs_remove_data_on_delete_user( $user_id ) { 1446 if ( ! bp_remove_user_data_on_delete_user_hook( 'blogs', $user_id ) ) { 1447 return; 1448 } 1449 1450 bp_blogs_remove_data( $user_id ); 1451 } 1452 add_action( 'delete_user', 'bp_blogs_remove_data_on_delete_user' ); 1453 1439 1454 /** 1440 1455 * Restore all blog associations for a given user. 1441 1456 * -
src/bp-blogs/classes/class-bp-blogs-blog.php
diff --git src/bp-blogs/classes/class-bp-blogs-blog.php src/bp-blogs/classes/class-bp-blogs-blog.php index af38b7863..9ba333213 100644
class BP_Blogs_Blog { 356 356 else 357 357 $blogs = $wpdb->get_results( $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ) ); 358 358 359 $query = $wpdb->prepare( "SELECT DISTINCT b.blog_id, b.id, bm1.meta_value as name, wb.domain, wb.path FROM {$bp->blogs->table_name} b, {$wpdb->base_prefix}blogs wb, {$bp->blogs->table_name_blogmeta} bm1 WHERE b.blog_id = wb.blog_id AND b.blog_id = bm1.blog_id AND bm1.meta_key = 'name' AND wb.public = 1 AND wb.deleted = 0 AND wb.spam = 0 AND wb.mature = 0 AND wb.archived = '0' AND b.user_id = %d ORDER BY b.blog_id", $user_id ); 360 359 361 $total_blog_count = BP_Blogs_Blog::total_blog_count_for_user( $user_id ); 360 362 361 363 $user_blogs = array(); -
src/bp-friends/bp-friends-functions.php
diff --git src/bp-friends/bp-friends-functions.php src/bp-friends/bp-friends-functions.php index 051c65018..a2a906b5a 100644
function friends_remove_data( $user_id ) { 757 757 do_action( 'friends_remove_data', $user_id ); 758 758 } 759 759 add_action( 'wpmu_delete_user', 'friends_remove_data' ); 760 add_action( 'delete_user', 'friends_remove_data' );761 760 add_action( 'bp_make_spam_user', 'friends_remove_data' ); 762 761 762 /** 763 * Deletes user Friends data on the 'delete_user' hook. 764 * 765 * @since 6.0.0 766 * 767 * @param int $user_id The ID of the deleted user. 768 */ 769 function bp_friends_remove_data_on_delete_user( $user_id ) { 770 if ( ! bp_remove_user_data_on_delete_user_hook( 'friends', $user_id ) ) { 771 return; 772 } 773 774 friends_remove_data( $user_id ); 775 } 776 add_action( 'delete_user', 'bp_friends_remove_data_on_delete_user' ); 777 763 778 /** 764 779 * Used by the Activity component's @mentions to print a JSON list of the current user's friends. 765 780 * -
src/bp-groups/bp-groups-functions.php
diff --git src/bp-groups/bp-groups-functions.php src/bp-groups/bp-groups-functions.php index 1435edbbb..028534153 100644
function groups_remove_data_for_user( $user_id ) { 2417 2417 do_action( 'groups_remove_data_for_user', $user_id ); 2418 2418 } 2419 2419 add_action( 'wpmu_delete_user', 'groups_remove_data_for_user' ); 2420 add_action( 'delete_user', 'groups_remove_data_for_user' );2421 2420 add_action( 'bp_make_spam_user', 'groups_remove_data_for_user' ); 2422 2421 2422 /** 2423 * Deletes user group data on the 'delete_user' hook. 2424 * 2425 * @since 6.0.0 2426 * 2427 * @param int $user_id The ID of the deleted user. 2428 */ 2429 function bp_groups_remove_data_for_user_on_delete_user( $user_id ) { 2430 if ( ! bp_remove_user_data_on_delete_user_hook( 'groups', $user_id ) ) { 2431 return; 2432 } 2433 2434 groups_remove_data_for_user( $user_id ); 2435 } 2436 add_action( 'delete_user', 'bp_groups_remove_data_for_user_on_delete_user' ); 2437 2423 2438 /** 2424 2439 * Update orphaned child groups when the parent is deleted. 2425 2440 * -
src/bp-members/bp-members-functions.php
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php index 6b009a1b9..48dacb891 100644
function bp_core_delete_account( $user_id = 0 ) { 1261 1261 return $retval; 1262 1262 } 1263 1263 1264 /** 1265 * Determines whether user data should be removed on the 'delete_user' hook. 1266 * 1267 * WordPress's 'delete_user' hook is ambiguous: on a standard installation, it means that a user 1268 * account is being removed from the system, while on Multisite it simply means the user is 1269 * being removed from a specific site (ie its roles are being revoked). As a rule, this means 1270 * that BuddyPress should remove user data on the delete_user hook only on non-Multisite 1271 * installations - only when the user account is being removed altogether. However, this behavior 1272 * can be filtered in a global, per-user, or per-component fashion. 1273 * 1274 * @since 6.0.0 1275 * 1276 * @param string $data_type Type of data to be removed. 1277 * @param int $user_id ID of the user, as passed to 'delete_user'. 1278 * @return bool 1279 */ 1280 function bp_remove_user_data_on_delete_user_hook( $component, $user_id ) { 1281 $remove = ! is_multisite(); 1282 1283 /** 1284 * Filters whether to remove user data on the 'delete_user' hook. 1285 * 1286 * @param bool $remove Whether data should be removed. 1287 * @param string $data_type Type of data to be removed. 1288 * @param int $user_id ID of the user, as passed to 'delete_user'. 1289 */ 1290 return apply_filters( 'bp_remove_user_data_on_delete_user_hook', $remove, $component, $user_id ); 1291 } 1292 1264 1293 /** 1265 1294 * Delete a user's avatar when the user is deleted. 1266 1295 * … … function bp_core_delete_avatar_on_user_delete( $user_id ) { 1276 1305 ) ); 1277 1306 } 1278 1307 add_action( 'wpmu_delete_user', 'bp_core_delete_avatar_on_user_delete' ); 1279 add_action( 'delete_user', 'bp_core_delete_avatar_on_user_delete' ); 1308 1309 /** 1310 * Deletes last_activity data on the 'delete_user' hook. 1311 * 1312 * @since 6.0.0 1313 * 1314 * @param int $user_id The ID of the deleted user. 1315 */ 1316 function bp_core_delete_avatar_on_delete_user( $user_id ) { 1317 if ( ! bp_remove_user_data_on_delete_user_hook( 'avatar', $user_id ) ) { 1318 return; 1319 } 1320 1321 bp_core_delete_avatar_on_user_delete( $user_id ); 1322 } 1323 add_action( 'delete_user', 'bp_core_delete_avatar_on_delete_user' ); 1280 1324 1281 1325 /** 1282 1326 * Multibyte-safe ucfirst() support. … … function bp_core_remove_data( $user_id ) { 1344 1388 wp_cache_flush(); 1345 1389 } 1346 1390 add_action( 'wpmu_delete_user', 'bp_core_remove_data' ); 1347 add_action( 'delete_user', 'bp_core_remove_data' );1348 1391 add_action( 'bp_make_spam_user', 'bp_core_remove_data' ); 1349 1392 1393 /** 1394 * Deletes last_activity data on the 'delete_user' hook. 1395 * 1396 * @since 6.0.0 1397 * 1398 * @param int $user_id The ID of the deleted user. 1399 */ 1400 function bp_core_remove_data_on_delete_user( $user_id ) { 1401 if ( ! bp_remove_user_data_on_delete_user_hook( 'last_activity', $user_id ) ) { 1402 return; 1403 } 1404 1405 bp_core_remove_data( $user_id ); 1406 } 1407 add_action( 'delete_user', 'bp_core_remove_data_on_delete_user' ); 1408 1350 1409 /** 1351 1410 * Check whether the logged-in user can edit settings for the displayed user. 1352 1411 * … … function bp_remove_member_type_on_user_delete( $user_id ) { 2831 2890 return bp_set_member_type( $user_id, '' ); 2832 2891 } 2833 2892 add_action( 'wpmu_delete_user', 'bp_remove_member_type_on_user_delete' ); 2834 add_action( 'delete_user', 'bp_remove_member_type_on_user_delete' ); 2893 2894 /** 2895 * Deletes user member type on the 'delete_user' hook. 2896 * 2897 * @since 6.0.0 2898 * 2899 * @param int $user_id The ID of the deleted user. 2900 */ 2901 function bp_remove_member_type_on_delete_user( $user_id ) { 2902 if ( ! bp_remove_user_data_on_delete_user_hook( 'member_type', $user_id ) ) { 2903 return; 2904 } 2905 2906 bp_remove_member_type_on_user_delete( $user_id ); 2907 } 2908 add_action( 'delete_user', 'bp_remove_member_type_on_delete_user' ); 2835 2909 2836 2910 /** 2837 2911 * Get the "current" member type, if one is provided, in member directories. -
src/bp-notifications/bp-notifications-functions.php
diff --git src/bp-notifications/bp-notifications-functions.php src/bp-notifications/bp-notifications-functions.php index 65e4a24d0..cc2618fd2 100644
function bp_notifications_delete_notifications_on_user_delete( $user_id ) { 445 445 ) ); 446 446 } 447 447 add_action( 'wpmu_delete_user', 'bp_notifications_delete_notifications_on_user_delete' ); 448 add_action( 'delete_user', 'bp_notifications_delete_notifications_on_user_delete' ); 448 449 /** 450 * Deletes user notifications data on the 'delete_user' hook. 451 * 452 * @since 6.0.0 453 * 454 * @param int $user_id The ID of the deleted user. 455 */ 456 function bp_notifications_delete_notifications_on_delete_user( $user_id ) { 457 if ( ! bp_remove_user_data_on_delete_user_hook( 'notifications', $user_id ) ) { 458 return; 459 } 460 461 bp_notifications_delete_notifications_on_user_delete( $user_id ); 462 } 463 464 add_action( 'delete_user', 'bp_notifications_delete_notifications_on_delete_user' ); 449 465 450 466 /** Mark **********************************************************************/ 451 467 -
src/bp-xprofile/bp-xprofile-functions.php
diff --git src/bp-xprofile/bp-xprofile-functions.php src/bp-xprofile/bp-xprofile-functions.php index 25d6d5fc0..3698f5fa3 100644
function xprofile_remove_data( $user_id ) { 847 847 BP_XProfile_ProfileData::delete_data_for_user( $user_id ); 848 848 } 849 849 add_action( 'wpmu_delete_user', 'xprofile_remove_data' ); 850 add_action( 'delete_user', 'xprofile_remove_data' );851 850 add_action( 'bp_make_spam_user', 'xprofile_remove_data' ); 852 851 852 /** 853 * Deletes user XProfile data on the 'delete_user' hook. 854 * 855 * @since 6.0.0 856 * 857 * @param int $user_id The ID of the deleted user. 858 */ 859 function xprofile_remove_data_on_delete_user( $user_id ) { 860 if ( ! bp_remove_user_data_on_delete_user_hook( 'xprofile', $user_id ) ) { 861 return; 862 } 863 864 xprofile_remove_data( $user_id ); 865 } 866 add_action( 'delete_user', 'xprofile_remove_data_on_delete_user' ); 867 853 868 /*** XProfile Meta ****************************************************/ 854 869 855 870 /** -
tests/phpunit/testcases/activity/functions.php
diff --git tests/phpunit/testcases/activity/functions.php tests/phpunit/testcases/activity/functions.php index e4974ea2c..9737ebbe7 100644
Bar!'; 1803 1803 // Number of exported activity items. 1804 1804 $this->assertSame( 3, count( $actual['data'] ) ); 1805 1805 } 1806 1807 /** 1808 * @ticket BP8175 1809 */ 1810 public function test_activity_data_should_be_deleted_on_user_delete_non_multisite() { 1811 if ( is_multisite() ) { 1812 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 1813 } 1814 1815 $u1 = self::factory()->user->create(); 1816 $a1 = self::factory()->activity->create( 1817 array( 1818 'user_id' => $u1, 1819 'component' => 'activity', 1820 'type' => 'activity_update', 1821 ) 1822 ); 1823 1824 $latest_update = array( 1825 'id' => $a1, 1826 'content' => 'Foo', 1827 ); 1828 bp_update_user_meta( $u1, 'bp_latest_update', $latest_update ); 1829 1830 bp_activity_add_user_favorite( $a1, $u1 ); 1831 1832 $found = bp_activity_get( 1833 array( 1834 'filter' => array( 1835 'user_id' => $u1, 1836 ) 1837 ) 1838 ); 1839 1840 $this->assertEqualSets( [ $a1 ], wp_list_pluck( $found['activities'], 'id' ) ); 1841 $this->assertEqualSets( [ $a1 ], bp_activity_get_user_favorites( $u1 ) ); 1842 $this->assertSame( $latest_update, bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1843 1844 wp_delete_user( $u1 ); 1845 1846 $found = bp_activity_get( 1847 array( 1848 'filter' => array( 1849 'user_id' => $u1, 1850 ) 1851 ) 1852 ); 1853 1854 $this->assertEmpty( $found['activities'] ); 1855 $this->assertEmpty( bp_activity_get_user_favorites( $u1 ) ); 1856 $this->assertSame( '', bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1857 } 1858 1859 /** 1860 * @ticket BP8175 1861 */ 1862 public function test_activity_data_should_be_deleted_on_user_delete_multisite() { 1863 if ( ! is_multisite() ) { 1864 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1865 } 1866 1867 $u1 = self::factory()->user->create(); 1868 $a1 = self::factory()->activity->create( 1869 array( 1870 'user_id' => $u1, 1871 'component' => 'activity', 1872 'type' => 'activity_update', 1873 ) 1874 ); 1875 1876 $latest_update = array( 1877 'id' => $a1, 1878 'content' => 'Foo', 1879 ); 1880 bp_update_user_meta( $u1, 'bp_latest_update', $latest_update ); 1881 1882 bp_activity_add_user_favorite( $a1, $u1 ); 1883 1884 $found = bp_activity_get( 1885 array( 1886 'filter' => array( 1887 'user_id' => $u1, 1888 ) 1889 ) 1890 ); 1891 1892 $this->assertEqualSets( [ $a1 ], wp_list_pluck( $found['activities'], 'id' ) ); 1893 $this->assertEqualSets( [ $a1 ], bp_activity_get_user_favorites( $u1 ) ); 1894 $this->assertSame( $latest_update, bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1895 1896 wpmu_delete_user( $u1 ); 1897 1898 $found = bp_activity_get( 1899 array( 1900 'filter' => array( 1901 'user_id' => $u1, 1902 ) 1903 ) 1904 ); 1905 1906 $this->assertEmpty( $found['activities'] ); 1907 $this->assertEmpty( bp_activity_get_user_favorites( $u1 ) ); 1908 $this->assertSame( '', bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1909 } 1910 1911 /** 1912 * @ticket BP8175 1913 */ 1914 public function test_activity_data_should_not_be_deleted_on_wp_delete_user_multisite() { 1915 if ( ! is_multisite() ) { 1916 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1917 } 1918 1919 $u1 = self::factory()->user->create(); 1920 $a1 = self::factory()->activity->create( 1921 array( 1922 'user_id' => $u1, 1923 'component' => 'activity', 1924 'type' => 'activity_update', 1925 ) 1926 ); 1927 1928 $latest_update = array( 1929 'id' => $a1, 1930 'content' => 'Foo', 1931 ); 1932 bp_update_user_meta( $u1, 'bp_latest_update', $latest_update ); 1933 1934 bp_activity_add_user_favorite( $a1, $u1 ); 1935 1936 $found = bp_activity_get( 1937 array( 1938 'filter' => array( 1939 'user_id' => $u1, 1940 ) 1941 ) 1942 ); 1943 1944 $this->assertEqualSets( [ $a1 ], wp_list_pluck( $found['activities'], 'id' ) ); 1945 $this->assertEqualSets( [ $a1 ], bp_activity_get_user_favorites( $u1 ) ); 1946 $this->assertSame( $latest_update, bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1947 1948 wp_delete_user( $u1 ); 1949 1950 $found = bp_activity_get( 1951 array( 1952 'filter' => array( 1953 'user_id' => $u1, 1954 ) 1955 ) 1956 ); 1957 1958 $this->assertEqualSets( [ $a1 ], wp_list_pluck( $found['activities'], 'id' ) ); 1959 $this->assertEqualSets( [ $a1 ], bp_activity_get_user_favorites( $u1 ) ); 1960 $this->assertSame( $latest_update, bp_get_user_meta( $u1, 'bp_latest_update', true ) ); 1961 } 1806 1962 } -
tests/phpunit/testcases/blogs/functions.php
diff --git tests/phpunit/testcases/blogs/functions.php tests/phpunit/testcases/blogs/functions.php index 92804a647..58b228ad8 100644
class BP_Tests_Blogs_Functions extends BP_UnitTestCase { 1141 1141 1142 1142 return ! empty( $a['activities'] ); 1143 1143 } 1144 1145 /** 1146 * @ticket BP8175 1147 */ 1148 public function test_blogs_data_should_be_deleted_on_user_delete_multisite() { 1149 if ( ! is_multisite() ) { 1150 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1151 } 1152 1153 if ( function_exists( 'wp_initialize_site' ) ) { 1154 $this->setExpectedDeprecated( 'wpmu_new_blog' ); 1155 } 1156 1157 $u1 = self::factory()->user->create(); 1158 $b1 = get_current_blog_id(); 1159 $b2 = self::factory()->blog->create(); 1160 1161 bp_blogs_record_blog( $b1, $u1, true ); 1162 bp_blogs_record_blog( $b2, $u1, true ); 1163 1164 $blogs = bp_blogs_get_blogs_for_user( $u1 ); 1165 1166 $this->assertEqualSets( [ $b1, $b2 ], wp_list_pluck( $blogs['blogs'], 'blog_id' ) ); 1167 1168 wpmu_delete_user( $u1 ); 1169 1170 $blogs = bp_blogs_get_blogs_for_user( $u1 ); 1171 1172 $this->assertEmpty( $blogs['blogs'] ); 1173 } 1174 1175 /** 1176 * @ticket BP8175 1177 */ 1178 public function test_blogs_data_should_not_be_deleted_on_wp_delete_user_multisite() { 1179 if ( ! is_multisite() ) { 1180 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1181 } 1182 1183 if ( function_exists( 'wp_initialize_site' ) ) { 1184 $this->setExpectedDeprecated( 'wpmu_new_blog' ); 1185 } 1186 1187 $u1 = self::factory()->user->create(); 1188 $b1 = get_current_blog_id(); 1189 $b2 = self::factory()->blog->create(); 1190 1191 bp_blogs_record_blog( $b1, $u1, true ); 1192 bp_blogs_record_blog( $b2, $u1, true ); 1193 1194 $blogs = bp_blogs_get_blogs_for_user( $u1 ); 1195 1196 $this->assertEqualSets( [ $b1, $b2 ], wp_list_pluck( $blogs['blogs'], 'blog_id' ) ); 1197 1198 wp_delete_user( $u1 ); 1199 1200 $blogs = bp_blogs_get_blogs_for_user( $u1 ); 1201 1202 $this->assertEqualSets( [ $b2 ], wp_list_pluck( $blogs['blogs'], 'blog_id' ) ); 1203 } 1144 1204 } -
tests/phpunit/testcases/friends/activity.php
diff --git tests/phpunit/testcases/friends/activity.php tests/phpunit/testcases/friends/activity.php index 8e59a31ca..d10119b23 100644
class BP_Tests_Friends_Activity extends BP_UnitTestCase { 205 205 $this->set_current_user( $old_user ); 206 206 207 207 // Delete $u1. 208 wp_delete_user( $u1 );208 $this->delete_user( $u1 ); 209 209 210 210 // 'friendship_created' activity item should not exist. 211 211 $friendship_activity = bp_activity_get( array( -
tests/phpunit/testcases/friends/functions.php
diff --git tests/phpunit/testcases/friends/functions.php tests/phpunit/testcases/friends/functions.php index d5ba39f68..804a31fa9 100644
class BP_Tests_Friends_Functions extends BP_UnitTestCase { 483 483 ); 484 484 $this->assertEqualSets( $expected_ids, wp_list_pluck( $actual['data'], 'item_id' ) ); 485 485 } 486 487 /** 488 * @ticket BP8175 489 */ 490 public function test_friends_data_should_be_deleted_on_user_delete_non_multisite() { 491 if ( is_multisite() ) { 492 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 493 } 494 495 $u1 = self::factory()->user->create(); 496 $u2 = self::factory()->user->create(); 497 498 friends_add_friend( $u1, $u2, true ); 499 500 $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 501 502 wp_delete_user( $u1 ); 503 504 $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 505 } 506 507 /** 508 * @ticket BP8175 509 */ 510 public function test_xprofile_data_should_be_deleted_on_user_delete_multisite() { 511 if ( ! is_multisite() ) { 512 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 513 } 514 515 $u1 = self::factory()->user->create(); 516 $u2 = self::factory()->user->create(); 517 518 friends_add_friend( $u1, $u2, true ); 519 520 $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 521 522 wpmu_delete_user( $u1 ); 523 524 $this->assertEquals( 'not_friends', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 525 } 526 527 /** 528 * @ticket BP8175 529 */ 530 public function test_xprofile_data_should_not_be_deleted_on_wp_delete_user_multisite() { 531 if ( ! is_multisite() ) { 532 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 533 } 534 535 $u1 = self::factory()->user->create(); 536 $u2 = self::factory()->user->create(); 537 538 friends_add_friend( $u1, $u2, true ); 539 540 $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 541 542 wp_delete_user( $u1 ); 543 544 $this->assertEquals( 'is_friend', BP_Friends_Friendship::check_is_friend( $u1, $u2 ) ); 545 } 486 546 } -
tests/phpunit/testcases/groups/functions.php
diff --git tests/phpunit/testcases/groups/functions.php tests/phpunit/testcases/groups/functions.php index 5021d6401..4b7533f55 100644
Bar!'; 949 949 $this->assertCount( 1, $actual['data'] ); 950 950 $this->assertSame( 'bp-group-pending-received-invitation-' . self::$group_ids[0], $actual['data'][0]['item_id'] ); 951 951 } 952 953 /** 954 * @ticket BP8175 955 */ 956 public function test_groups_data_should_be_deleted_on_user_delete_non_multisite() { 957 if ( is_multisite() ) { 958 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 959 } 960 961 $u = self::factory()->user->create(); 962 963 groups_join_group( self::$group_ids[0], $u ); 964 965 $this->assertNotEmpty( groups_is_user_member( $u, self::$group_ids[0] ) ); 966 967 wp_delete_user( $u ); 968 969 $this->assertFalse( groups_is_user_member( $u, self::$group_ids[0] ) ); 970 } 971 972 /** 973 * @ticket BP8175 974 */ 975 public function test_groups_data_should_be_deleted_on_user_delete_multisite() { 976 if ( ! is_multisite() ) { 977 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 978 } 979 980 $u = self::factory()->user->create(); 981 982 groups_join_group( self::$group_ids[0], $u ); 983 984 $this->assertNotEmpty( groups_is_user_member( $u, self::$group_ids[0] ) ); 985 986 wpmu_delete_user( $u ); 987 988 $this->assertFalse( groups_is_user_member( $u, self::$group_ids[0] ) ); 989 } 990 991 /** 992 * @ticket BP8175 993 */ 994 public function test_groups_data_should_not_be_deleted_on_wp_delete_user_multisite() { 995 if ( ! is_multisite() ) { 996 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 997 } 998 999 $u = self::factory()->user->create(); 1000 1001 groups_join_group( self::$group_ids[0], $u ); 1002 1003 $this->assertNotEmpty( groups_is_user_member( $u, self::$group_ids[0] ) ); 1004 1005 wp_delete_user( $u ); 1006 1007 $this->assertNotEmpty( groups_is_user_member( $u, self::$group_ids[0] ) ); 1008 } 952 1009 } -
tests/phpunit/testcases/members/functions.php
diff --git tests/phpunit/testcases/members/functions.php tests/phpunit/testcases/members/functions.php index e2492116c..1ed038f3d 100644
class BP_Tests_Members_Functions extends BP_UnitTestCase { 48 48 bp_update_option( 'bp-disable-account-deletion', $deletion_disabled ); 49 49 } 50 50 51 /** 52 * @ticket BP8175 53 */ 54 public function test_last_activity_data_should_be_deleted_on_user_delete_non_multisite() { 55 if ( is_multisite() ) { 56 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 57 } 58 59 $u1 = self::factory()->user->create(); 60 61 $now = time(); 62 bp_update_user_last_activity( $u1, $now ); 63 64 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 65 66 wp_delete_user( $u1 ); 67 68 $this->assertEquals( '', bp_get_user_last_activity( $u1 ) ); 69 } 70 71 /** 72 * @ticket BP8175 73 */ 74 public function test_last_activity_data_should_be_deleted_on_user_delete_multisite() { 75 if ( ! is_multisite() ) { 76 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 77 } 78 79 $u1 = self::factory()->user->create(); 80 81 $now = time(); 82 bp_update_user_last_activity( $u1, $now ); 83 84 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 85 86 wpmu_delete_user( $u1 ); 87 88 $this->assertEquals( '', bp_get_user_last_activity( $u1 ) ); 89 } 90 91 /** 92 * @ticket BP8175 93 */ 94 public function test_last_activity_data_should_not_be_deleted_on_wp_delete_user_multisite() { 95 if ( ! is_multisite() ) { 96 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 97 } 98 99 $u1 = self::factory()->user->create(); 100 101 $now = time(); 102 bp_update_user_last_activity( $u1, $now ); 103 104 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 105 106 wp_delete_user( $u1 ); 107 108 $this->assertEquals( $now, bp_get_user_last_activity( $u1 ) ); 109 } 110 51 111 /** 52 112 * @group object_cache 53 113 * @group bp_core_get_directory_pages -
tests/phpunit/testcases/notifications/functions.php
diff --git tests/phpunit/testcases/notifications/functions.php tests/phpunit/testcases/notifications/functions.php index 106c1598c..f47556048 100644
class BP_Tests_Notifications_Functions extends BP_UnitTestCase { 346 346 $found1 = $wpdb->get_col( $query ); 347 347 $this->assertEqualSets( array( $n1, $n2, $n3, $n4, $n5 ), $found1 ); 348 348 349 wp_delete_user( $u );349 $this->delete_user( $u ); 350 350 351 351 // Check if notifications are deleted. 352 352 $found2 = $wpdb->get_col( $query ); … … class BP_Tests_Notifications_Functions extends BP_UnitTestCase { 463 463 // Number of exported notification items. 464 464 $this->assertSame( 2, count( $actual['data'] ) ); 465 465 } 466 467 /** 468 * @ticket BP8175 469 */ 470 public function test_notifications_data_should_be_deleted_on_user_delete_non_multisite() { 471 if ( is_multisite() ) { 472 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 473 } 474 475 $u = self::factory()->user->create(); 476 477 $n1 = self::factory()->notification->create( array( 478 'component_name' => 'messages', 479 'component_action' => 'new_message', 480 'item_id' => 99, 481 'user_id' => $u, 482 ) ); 483 484 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 485 $this->assertEqualSets( [ $n1 ], wp_list_pluck( $found, 'id' ) ); 486 487 wp_delete_user( $u ); 488 489 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 490 $this->assertEmpty( '', $found ); 491 } 492 493 /** 494 * @ticket BP8175 495 */ 496 public function test_notifications_data_should_be_deleted_on_user_delete_multisite() { 497 if ( ! is_multisite() ) { 498 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 499 } 500 501 $u = self::factory()->user->create(); 502 503 $n1 = self::factory()->notification->create( array( 504 'component_name' => 'messages', 505 'component_action' => 'new_message', 506 'item_id' => 99, 507 'user_id' => $u, 508 ) ); 509 510 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 511 $this->assertEqualSets( [ $n1 ], wp_list_pluck( $found, 'id' ) ); 512 513 wpmu_delete_user( $u ); 514 515 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 516 $this->assertEmpty( '', $found ); 517 } 518 519 /** 520 * @ticket BP8175 521 */ 522 public function test_notifications_data_should_not_be_deleted_on_wp_delete_user_multisite() { 523 if ( ! is_multisite() ) { 524 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 525 } 526 527 $u = self::factory()->user->create(); 528 529 $n1 = self::factory()->notification->create( array( 530 'component_name' => 'messages', 531 'component_action' => 'new_message', 532 'item_id' => 99, 533 'user_id' => $u, 534 ) ); 535 536 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 537 $this->assertEqualSets( [ $n1 ], wp_list_pluck( $found, 'id' ) ); 538 539 wp_delete_user( $u ); 540 541 $found = bp_notifications_get_notifications_for_user( $u, 'object' ); 542 $this->assertEqualSets( [ $n1 ], wp_list_pluck( $found, 'id' ) ); 543 } 466 544 } -
tests/phpunit/testcases/xprofile/functions.php
diff --git tests/phpunit/testcases/xprofile/functions.php tests/phpunit/testcases/xprofile/functions.php index bc36002e4..10dd64e1d 100644
Bar!'; 1131 1131 // Number of exported user properties. 1132 1132 $this->assertSame( 3, count( $actual['data'][0]['data'] ) ); 1133 1133 } 1134 1135 /** 1136 * @ticket BP8175 1137 */ 1138 public function test_xprofile_data_should_be_deleted_on_user_delete_non_multisite() { 1139 if ( is_multisite() ) { 1140 $this->markTestSkipped( __METHOD__ . ' requires non-multisite.' ); 1141 } 1142 1143 $u = self::factory()->user->create(); 1144 1145 $fg = self::factory()->xprofile_group->create(); 1146 $f1 = self::factory()->xprofile_field->create( 1147 array( 1148 'field_group_id' => $fg, 1149 ) 1150 ); 1151 1152 xprofile_set_field_data( $f1, $u, 'foo' ); 1153 $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) ); 1154 1155 wp_delete_user( $u ); 1156 1157 $this->assertSame( '', xprofile_get_field_data( $f1, $u ) ); 1158 } 1159 1160 /** 1161 * @ticket BP8175 1162 */ 1163 public function test_xprofile_data_should_be_deleted_on_user_delete_multisite() { 1164 if ( ! is_multisite() ) { 1165 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1166 } 1167 1168 $u = self::factory()->user->create(); 1169 1170 $fg = self::factory()->xprofile_group->create(); 1171 $f1 = self::factory()->xprofile_field->create( 1172 array( 1173 'field_group_id' => $fg, 1174 ) 1175 ); 1176 1177 xprofile_set_field_data( $f1, $u, 'foo' ); 1178 $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) ); 1179 1180 wpmu_delete_user( $u ); 1181 1182 $this->assertSame( '', xprofile_get_field_data( $f1, $u ) ); 1183 } 1184 1185 /** 1186 * @ticket BP8175 1187 */ 1188 public function test_xprofile_data_should_not_be_deleted_on_wp_delete_user_multisite() { 1189 if ( ! is_multisite() ) { 1190 $this->markTestSkipped( __METHOD__ . ' requires multisite.' ); 1191 } 1192 1193 $u = self::factory()->user->create(); 1194 1195 $fg = self::factory()->xprofile_group->create(); 1196 $f1 = self::factory()->xprofile_field->create( 1197 array( 1198 'field_group_id' => $fg, 1199 ) 1200 ); 1201 1202 xprofile_set_field_data( $f1, $u, 'foo' ); 1203 $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) ); 1204 1205 wp_delete_user( $u ); 1206 1207 $this->assertSame( 'foo', xprofile_get_field_data( $f1, $u ) ); 1208 } 1134 1209 }