Changeset 13086
- Timestamp:
- 08/22/2021 03:16:06 AM (3 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-activity/classes/class-bp-activity-activity.php
r12604 r13086 384 384 385 385 // Backward compatibility with old method of passing arguments. 386 if ( ! is_array( $args ) || count( $function_args ) > 1 ) {386 if ( ! is_array( $args ) || count( $function_args ) > 1 ) { 387 387 _deprecated_argument( 388 388 __METHOD__, … … 390 390 sprintf( 391 391 /* translators: 1: the name of the method. 2: the name of the file. */ 392 __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ),392 esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), 393 393 __METHOD__, 394 394 __FILE__ … … 1156 1156 */ 1157 1157 public static function get_specific( $activity_ids, $max = false, $page = 1, $per_page = 25, $sort = 'DESC', $display_comments = false ) { 1158 _deprecated_function( __FUNCTION__, '1.5', 'Use BP_Activity_Activity::get() with the "in" parameter instead.' ); 1158 _deprecated_function( 1159 __FUNCTION__, 1160 '1.5', 1161 'Use BP_Activity_Activity::get() with the "in" parameter instead.' 1162 ); 1163 1159 1164 return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids ); 1160 1165 } -
trunk/src/bp-friends/bp-friends-functions.php
r12605 r13086 162 162 163 163 // Get the friendship data. 164 $friendship = new BP_Friends_Friendship( $friendship_id, true, false );164 $friendship = new BP_Friends_Friendship( $friendship_id, false, false ); 165 165 166 166 // Accepting friendship. … … 197 197 */ 198 198 function friends_reject_friendship( $friendship_id ) { 199 $friendship = new BP_Friends_Friendship( $friendship_id, true, false );199 $friendship = new BP_Friends_Friendship( $friendship_id, false, false ); 200 200 201 201 if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::reject( $friendship_id ) ) { … … 228 228 function friends_withdraw_friendship( $initiator_userid, $friend_userid ) { 229 229 $friendship_id = BP_Friends_Friendship::get_friendship_id( $initiator_userid, $friend_userid ); 230 $friendship = new BP_Friends_Friendship( $friendship_id, true, false );230 $friendship = new BP_Friends_Friendship( $friendship_id, false, false ); 231 231 232 232 if ( empty( $friendship->is_confirmed ) && BP_Friends_Friendship::withdraw( $friendship_id ) ) { -
trunk/src/bp-friends/classes/class-bp-friends-friendship.php
r12459 r13086 98 98 * 99 99 * @since 1.5.0 100 * @since 10.0.0 Updated to add deprecated notice for `$is_request`. 100 101 * 101 102 * @param int|null $id Optional. The ID of an existing friendship. 102 103 * @param bool $is_request Deprecated. 103 * @param bool $populate_friend_details True if friend details should be queried.104 * @param bool $populate_friend_details Optional. True if friend details should be queried. 104 105 */ 105 106 public function __construct( $id = null, $is_request = false, $populate_friend_details = true ) { 107 108 if ( false !== $is_request ) { 109 _deprecated_argument( 110 __METHOD__, 111 '1.5.0', 112 sprintf( 113 /* translators: 1: the name of the method. 2: the name of the file. */ 114 esc_html__( '%1$s no longer accepts $is_request. See the inline documentation at %2$s for more details.', 'buddypress' ), 115 __METHOD__, 116 __FILE__ 117 ) 118 ); 119 } 120 106 121 $this->is_request = $is_request; 107 122 108 if ( ! empty( $id ) ) {123 if ( ! empty( $id ) ) { 109 124 $this->id = (int) $id; 110 125 $this->populate_friend_details = $populate_friend_details; -
trunk/src/bp-groups/classes/class-bp-groups-group.php
r12731 r13086 180 180 * Raw arguments passed to the constructor. 181 181 * 182 * Not currently used by BuddyPress. 183 * 182 184 * @since 2.0.0 183 185 * @var array … … 198 200 */ 199 201 public function __construct( $id = null, $args = array() ) { 200 if ( !empty( $id ) ) { 202 203 // Deprecated notice about $args. 204 if ( ! empty( $args ) ) { 205 _deprecated_argument( 206 __METHOD__, 207 '1.6.0', 208 sprintf( 209 /* translators: 1: the name of the method. 2: the name of the file. */ 210 esc_html__( '%1$s no longer accepts arguments. See the inline documentation at %2$s for more details.', 'buddypress' ), 211 __METHOD__, 212 __FILE__ 213 ) 214 ); 215 } 216 217 if ( ! empty( $id ) ) { 201 218 $this->id = (int) $id; 202 219 $this->populate(); … … 672 689 * 673 690 * @since 1.6.0 691 * @since 10.0.0 Updated to add the deprecated notice. 674 692 * 675 693 * @param string $slug Slug to check. 676 694 * @param string|bool $table_name Deprecated. 677 * @return int|null Group ID if found; nullif not.695 * @return int|null|bool False if empty slug, group ID if found; `null` if not. 678 696 */ 679 697 public static function group_exists( $slug, $table_name = false ) { 680 global $wpdb; 698 699 if ( false !== $table_name ) { 700 _deprecated_argument( 701 __METHOD__, 702 '1.6.0', 703 sprintf( 704 /* translators: 1: the name of the method. 2: the name of the file. */ 705 esc_html__( '%1$s no longer accepts a table name argument. See the inline documentation at %2$s for more details.', 'buddypress' ), 706 __METHOD__, 707 __FILE__ 708 ) 709 ); 710 } 681 711 682 712 if ( empty( $slug ) ) { … … 684 714 } 685 715 686 $args = array( 687 'slug' => $slug, 688 'per_page' => 1, 689 'page' => 1, 690 'update_meta_cache' => false, 691 'show_hidden' => true, 716 $groups = self::get( 717 array( 718 'slug' => $slug, 719 'per_page' => 1, 720 'page' => 1, 721 'update_meta_cache' => false, 722 'show_hidden' => true, 723 ) 692 724 ); 693 694 $groups = BP_Groups_Group::get( $args );695 725 696 726 $group_id = null; … … 710 740 * 711 741 * @param string $slug See {@link BP_Groups_Group::group_exists()}. 712 * @return int|null See {@link BP_Groups_Group::group_exists()}.742 * @return int|null|bool See {@link BP_Groups_Group::group_exists()}. 713 743 */ 714 744 public static function get_id_from_slug( $slug ) { 715 return BP_Groups_Group::group_exists( $slug );745 return self::group_exists( $slug ); 716 746 } 717 747 … … 1056 1086 // Backward compatibility with old method of passing arguments. 1057 1087 if ( ! is_array( $args ) || count( $function_args ) > 1 ) { 1058 _deprecated_argument( __METHOD__, '1.7', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 1088 _deprecated_argument( 1089 __METHOD__, 1090 '1.7', 1091 sprintf( 1092 /* translators: 1: the name of the method. 2: the name of the file. */ 1093 esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), 1094 __METHOD__, 1095 __FILE__ 1096 ) 1097 ); 1059 1098 1060 1099 $old_args_keys = array( … … 1537 1576 */ 1538 1577 public static function get_by_letter( $letter, $limit = null, $page = null, $populate_extras = true, $exclude = false ) { 1539 global $wpdb; 1540 1541 $pag_sql = $hidden_sql = $exclude_sql = ''; 1578 1579 if ( true !== $populate_extras ) { 1580 _deprecated_argument( 1581 __METHOD__, 1582 '1.6.0', 1583 sprintf( 1584 /* translators: 1: the name of the method. 2: the name of the file. */ 1585 esc_html__( '%1$s no longer accepts setting $populate_extras. See the inline documentation at %2$s for more details.', 'buddypress' ), 1586 __METHOD__, 1587 __FILE__ 1588 ) 1589 ); 1590 } 1542 1591 1543 1592 // Multibyte compliance. … … 1552 1601 } 1553 1602 1554 $args = array( 1555 'per_page' => $limit, 1556 'page' => $page, 1557 'search_terms' => $letter . '*', 1558 'search_columns' => array( 'name' ), 1559 'exclude' => $exclude, 1603 return self::get( 1604 array( 1605 'per_page' => $limit, 1606 'page' => $page, 1607 'search_terms' => $letter . '*', 1608 'search_columns' => array( 'name' ), 1609 'exclude' => $exclude, 1610 ) 1560 1611 ); 1561 1562 return BP_Groups_Group::get( $args );1563 1612 } 1564 1613 … … 1569 1618 * 1570 1619 * @since 1.6.0 1620 * @since 10.0.0 Deprecate the `$populate_extras` arg. 1571 1621 * 1572 1622 * @param int|null $limit Optional. The max number of results to return. … … 1578 1628 * @param string|bool $search_terms Optional. Limit groups to those whose name 1579 1629 * or description field contain the search string. 1580 * @param bool $populate_extras Optional. Whether to fetch extra 1581 * information about the groups. Default: true. 1630 * @param bool $populate_extras Deprecated. 1582 1631 * @param string|array|bool $exclude Optional. Array or comma-separated list of group 1583 1632 * IDs to exclude from results. … … 1590 1639 */ 1591 1640 public static function get_random( $limit = null, $page = null, $user_id = 0, $search_terms = false, $populate_extras = true, $exclude = false ) { 1592 $args = array( 1593 'type' => 'random', 1594 'per_page' => $limit, 1595 'page' => $page, 1596 'user_id' => $user_id, 1597 'search_terms' => $search_terms, 1598 'exclude' => $exclude, 1641 1642 if ( true !== $populate_extras ) { 1643 _deprecated_argument( 1644 __METHOD__, 1645 '10.0.0', 1646 sprintf( 1647 /* translators: 1: the name of the method. 2: the name of the file. */ 1648 esc_html__( '%1$s no longer accepts setting $populate_extras. See the inline documentation at %2$s for more details.', 'buddypress' ), 1649 __METHOD__, 1650 __FILE__ 1651 ) 1652 ); 1653 } 1654 1655 return self::get( 1656 array( 1657 'type' => 'random', 1658 'per_page' => $limit, 1659 'page' => $page, 1660 'user_id' => $user_id, 1661 'search_terms' => $search_terms, 1662 'exclude' => $exclude, 1663 ) 1599 1664 ); 1600 1601 return BP_Groups_Group::get( $args );1602 1665 } 1603 1666 -
trunk/src/bp-messages/classes/class-bp-messages-thread.php
r12984 r13086 450 450 // Backward compatibility with old method of passing arguments. 451 451 if ( ! is_array( $args ) || count( $function_args ) > 1 ) { 452 _deprecated_argument( __METHOD__, '2.2.0', sprintf( __( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), __METHOD__, __FILE__ ) ); 452 _deprecated_argument( 453 __METHOD__, 454 '2.2.0', 455 sprintf( 456 /* translators: 1: the name of the method. 2: the name of the file. */ 457 esc_html__( 'Arguments passed to %1$s should be in an associative array. See the inline documentation at %2$s for more details.', 'buddypress' ), 458 __METHOD__, 459 __FILE__ 460 ) 461 ); 453 462 454 463 $old_args_keys = array( -
trunk/tests/phpunit/testcases/friends/class-bp-friends-friendship.php
r11737 r13086 5 5 */ 6 6 class BP_Tests_BP_Friends_Friendship_TestCases extends BP_UnitTestCase { 7 8 /** __construct() ***************************************************/ 9 10 /** 11 * @group __construct 12 */ 13 public function test_non_existent_friendship() { 14 $friendship = new BP_Friends_Friendship( 123456789 ); 15 $this->assertSame( 0, $friendship->id ); 16 } 17 18 /** 19 * @group __construct 20 * @expectedDeprecated BP_Friends_Friendship::__construct 21 */ 22 public function test_deprecated_arg() { 23 $friendship = new BP_Friends_Friendship( 123456789, true ); 24 $this->assertSame( 0, $friendship->id ); 25 } 26 7 27 public function test_search_friends() { 8 28 $u1 = self::factory()->user->create(); -
trunk/tests/phpunit/testcases/groups/class-bp-groups-group.php
r12430 r13086 16 16 } 17 17 18 /** 19 * @group __construct 20 * @expectedDeprecated BP_Groups_Group::__construct 21 */ 22 public function test_deprecated_arg() { 23 $group = new BP_Groups_Group( 123456789, array( 'populate_extras' => true ) ); 24 $this->assertSame( 0, $group->id ); 25 } 26 18 27 /** get() ************************************************************/ 28 29 /** 30 * @group get 31 */ 32 public function test_get_group_id_with_slug() { 33 $slug = 'group-test'; 34 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 35 $group_id = BP_Groups_Group::group_exists( $slug ); 36 37 $this->assertSame( $g1, $group_id ); 38 } 39 40 /** 41 * @group get 42 */ 43 public function test_get_group_id_with_empty_slug() { 44 $this->assertFalse( BP_Groups_Group::group_exists( '' ) ); 45 } 46 47 /** 48 * @group get 49 */ 50 public function test_get_group_id_from_slug_with_empty_slug() { 51 $this->assertFalse( BP_Groups_Group::get_id_from_slug( '' ) ); 52 } 53 54 /** 55 * @group get 56 */ 57 public function test_get_group_id_from_slug() { 58 $slug = 'group-test'; 59 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 60 $group_id = BP_Groups_Group::get_id_from_slug( $slug ); 61 62 $this->assertSame( $g1, $group_id ); 63 } 64 65 /** 66 * @group get 67 * @expectedDeprecated BP_Groups_Group::group_exists 68 */ 69 public function test_get_group_with_slug_with_deprecated_args() { 70 $slug = 'group-test'; 71 $g1 = self::factory()->group->create( array( 'slug' => $slug ) ); 72 $group_id = BP_Groups_Group::group_exists( $slug, 'random-name' ); 73 74 $this->assertSame( $g1, $group_id ); 75 } 19 76 20 77 /** … … 1144 1201 1145 1202 $groups = BP_Groups_Group::search_groups( "'tis " ); 1146 1147 $found = wp_list_pluck( $groups['groups'], 'group_id' ); 1203 $found = wp_list_pluck( $groups['groups'], 'group_id' ); 1148 1204 1149 1205 $this->assertEquals( array( $g1 ), $found ); 1206 $this->assertNotContains( $g2, $found ); 1207 } 1208 1209 /** 1210 * @expectedDeprecated BP_Groups_Group::get_by_letter 1211 */ 1212 public function test_get_by_letter_with_deprecated_arg() { 1213 $g1 = self::factory()->group->create( array( 1214 'name' => 'Awesome Cool Group', 1215 'description' => 'Neat', 1216 ) ); 1217 $g2 = self::factory()->group->create(); 1218 1219 $groups = BP_Groups_Group::get_by_letter( 'A', null, null, false ); 1220 $found = wp_list_pluck( $groups['groups'], 'id' ); 1221 1222 $this->assertEquals( array( $g1 ), $found ); 1223 $this->assertNotContains( $g2, $found ); 1150 1224 } 1151 1225 1152 1226 public function test_get_by_letter_typical_use() { 1227 $g1 = self::factory()->group->create( array( 1228 'name' => 'Awesome Cool Group', 1229 'description' => 'Neat', 1230 ) ); 1231 $g2 = self::factory()->group->create(); 1232 1233 $groups = BP_Groups_Group::get_by_letter( 'A' ); 1234 $found = wp_list_pluck( $groups['groups'], 'id' ); 1235 1236 $this->assertEquals( array( $g1 ), $found ); 1237 $this->assertNotContains( $g2, $found ); 1238 } 1239 1240 public function test_get_by_letter_with_exclude() { 1153 1241 $g1 = self::factory()->group->create( array( 1154 1242 'name' => 'Awesome Cool Group', … … 1156 1244 ) ); 1157 1245 $g2 = self::factory()->group->create( array( 1158 'name' => 'Babylon Kong',1159 'description' => 'Awesome',1160 ) );1161 1162 $groups = BP_Groups_Group::get_by_letter( 'A' );1163 1164 $found = wp_list_pluck( $groups['groups'], 'id' );1165 1166 $this->assertEquals( array( $g1 ), $found );1167 1168 }1169 1170 public function test_get_by_letter_with_exclude() {1171 $g1 = self::factory()->group->create( array(1172 'name' => 'Awesome Cool Group',1173 'description' => 'Neat',1174 ) );1175 $g2 = self::factory()->group->create( array(1176 1246 'name' => 'Another Cool Group', 1177 1247 'description' => 'Awesome', … … 1179 1249 1180 1250 $groups = BP_Groups_Group::get_by_letter( 'A', null, null, true, array( $g1, 'stringthatshouldberemoved' ) ); 1181 1182 $found = wp_list_pluck( $groups['groups'], 'id' ); 1251 $found = wp_list_pluck( $groups['groups'], 'id' ); 1183 1252 1184 1253 $this->assertEquals( array( $g2 ), $found ); … … 1210 1279 } 1211 1280 1281 /** 1282 * @expectedDeprecated BP_Groups_Group::get_random 1283 */ 1284 public function test_get_random_with_deprecated_arg() { 1285 $g1 = self::factory()->group->create(); 1286 $g2 = self::factory()->group->create(); 1287 1288 // There are only two groups, so excluding one should give us the other 1289 $groups = BP_Groups_Group::get_random( null, null, 0, false, false, array( $g1, 'ignore this' ) ); 1290 $found = wp_list_pluck( $groups['groups'], 'id' ); 1291 1292 $this->assertEquals( array( $g2 ), $found ); 1293 } 1294 1212 1295 public function test_get_random_with_exclude() { 1213 1296 $g1 = self::factory()->group->create(); … … 1232 1315 // Only one group will match, so the random part doesn't matter 1233 1316 $groups = BP_Groups_Group::get_random( null, null, 0, 'daci' ); 1234 1235 $found = wp_list_pluck( $groups['groups'], 'id' ); 1317 $found = wp_list_pluck( $groups['groups'], 'id' ); 1236 1318 1237 1319 $this->assertEquals( array( $g1 ), $found ); 1320 $this->assertNotContains( $g2, $found ); 1238 1321 } 1239 1322
Note: See TracChangeset
for help on using the changeset viewer.