Ticket #9131: 9131.patch
File 9131.patch, 18.8 KB (added by , 6 months ago) |
---|
-
class-bp-activity-activity.php
349 349 * @since 10.0.0 Introduced the `$count_total_only` parameter. 350 350 * @since 11.0.0 Introduced the `$user_id__in` and `$user_id__not_in` parameters. 351 351 * 352 * @see BP_Activity_Activity::get_filter_sql() for a description of the352 * @see self::get_filter_sql() for a description of the 353 353 * 'filter' parameter. 354 354 * @see WP_Meta_Query::queries for a description of the 'meta_query' 355 355 * parameter format. … … 373 373 * WP_Date_Query::__construct(). 374 374 * @type array $filter_query Array of advanced query conditions. See BP_Activity_Query::__construct(). 375 375 * @type string|array $scope Pre-determined set of activity arguments. 376 * @type array $filter See BP_Activity_Activity::get_filter_sql().376 * @type array $filter See self::get_filter_sql(). 377 377 * @type array $user_id__in An array of user ids to include. Activity posted by users matching one of these 378 378 * user ids will be included in results. Default empty array. 379 379 * @type array $user_id__not_in An array of user ids to exclude. Activity posted by users matching one of these … … 493 493 } 494 494 495 495 // Regular filtering. 496 if ( $r['filter'] && $filter_sql = BP_Activity_Activity::get_filter_sql( $r['filter'] ) ) {496 if ( $r['filter'] && $filter_sql = self::get_filter_sql( $r['filter'] ) ) { 497 497 $where_conditions['filter_sql'] = $filter_sql; 498 498 } 499 499 … … 682 682 $join_sql = apply_filters( 'bp_activity_get_join_sql', $join_sql, $r, $select_sql, $from_sql, $where_sql ); 683 683 684 684 // Sanitize page and per_page parameters. 685 $page = absint( $r['page'] 685 $page = absint( $r['page'] ); 686 686 $per_page = absint( $r['per_page'] ); 687 687 688 688 $retval = array( … … 826 826 } 827 827 828 828 if ( $activities && $r['display_comments'] ) { 829 $activities = BP_Activity_Activity::append_comments( $activities, $r['spam'] );829 $activities = self::append_comments( $activities, $r['spam'] ); 830 830 } 831 831 832 832 // Pre-fetch data associated with activity users and other objects. 833 BP_Activity_Activity::prefetch_object_data( $activities );833 self::prefetch_object_data( $activities ); 834 834 835 835 // Generate action strings. 836 $activities = BP_Activity_Activity::generate_action_strings( $activities );836 $activities = self::generate_action_strings( $activities ); 837 837 } 838 838 839 839 $retval['activities'] = $activities; … … 999 999 * 1000 1000 * The only object data required for activity component activity types 1001 1001 * (activity_update and activity_comment) is related to users, and that 1002 * info is fetched separately in BP_Activity_Activity::get_activity_data().1002 * info is fetched separately in self::get_activity_data(). 1003 1003 * So this method contains nothing but a filter that allows other 1004 1004 * components, such as bp-friends and bp-groups, to hook in and prime 1005 1005 * their own caches at the beginning of an activity loop. … … 1022 1022 } 1023 1023 1024 1024 /** 1025 * Generate action strings for the activities located in BP_Activity_Activity::get().1025 * Generate action strings for the activities located in self::get(). 1026 1026 * 1027 1027 * If no string can be dynamically generated for a given item 1028 1028 * (typically because the activity type has not been properly … … 1048 1048 } 1049 1049 1050 1050 /** 1051 * Get the SQL for the 'meta_query' param in BP_Activity_Activity::get().1051 * Get the SQL for the 'meta_query' param in self::get(). 1052 1052 * 1053 1053 * We use WP_Meta_Query to do the heavy lifting of parsing the 1054 1054 * meta_query array and creating the necessary SQL clauses. However, 1055 * since BP_Activity_Activity::get() builds its SQL differently than1055 * since self::get() builds its SQL differently than 1056 1056 * WP_Query, we have to alter the return value (stripping the leading 1057 1057 * AND keyword from the 'where' clause). 1058 1058 * … … 1094 1094 } 1095 1095 1096 1096 /** 1097 * Get the SQL for the 'date_query' param in BP_Activity_Activity::get().1097 * Get the SQL for the 'date_query' param in self::get(). 1098 1098 * 1099 1099 * We use BP_Date_Query, which extends WP_Date_Query, to do the heavy lifting 1100 1100 * of parsing the date_query array and creating the necessary SQL clauses. … … 1110 1110 } 1111 1111 1112 1112 /** 1113 * Get the SQL for the 'scope' param in BP_Activity_Activity::get().1113 * Get the SQL for the 'scope' param in self::get(). 1114 1114 * 1115 1115 * A scope is a predetermined set of activity arguments. This method is used 1116 1116 * to grab these activity arguments and override any existing args if needed. … … 1120 1120 * @since 2.2.0 1121 1121 * 1122 1122 * @param mixed $scope The activity scope. Accepts string or array of scopes. 1123 * @param array $r Current activity arguments. Same as those of BP_Activity_Activity::get(),1123 * @param array $r Current activity arguments. Same as those of self::get(), 1124 1124 * but merged with defaults. 1125 1125 * @return false|array 'sql' WHERE SQL string and 'override' activity args. 1126 1126 */ … … 1176 1176 * @type array $override Optional. Override existing activity arguments passed by $r. 1177 1177 * } 1178 1178 * } 1179 * @param array $r Current activity arguments passed in BP_Activity_Activity::get().1179 * @param array $r Current activity arguments passed in self::get(). 1180 1180 */ 1181 1181 $scope_args = apply_filters( "bp_activity_set_{$scope}_scope_args", array(), $r ); 1182 1182 … … 1216 1216 /** 1217 1217 * In BuddyPress 1.2.x, this was used to retrieve specific activity stream items (for example, on an activity's permalink page). 1218 1218 * 1219 * As of 1.5.x, use BP_Activity_Activity::get() with an 'in' parameter instead.1219 * As of 1.5.x, use self::get() with an 'in' parameter instead. 1220 1220 * 1221 1221 * @since 1.2.0 1222 1222 * 1223 1223 * @deprecated 1.5 1224 * @deprecated Use BP_Activity_Activity::get() with an 'in' parameter instead.1224 * @deprecated Use self::get() with an 'in' parameter instead. 1225 1225 * 1226 1226 * @param mixed $activity_ids Array or comma-separated string of activity IDs to retrieve. 1227 1227 * @param int|bool $max Maximum number of results to return. (Optional; default is no maximum). … … 1235 1235 _deprecated_function( 1236 1236 __FUNCTION__, 1237 1237 '1.5', 1238 'Use BP_Activity_Activity::get() with the "in" parameter instead.'1238 'Use self::get() with the "in" parameter instead.' 1239 1239 ); 1240 1240 1241 return BP_Activity_Activity::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids );1241 return self::get( $max, $page, $per_page, $sort, false, false, $display_comments, false, false, $activity_ids ); 1242 1242 } 1243 1243 1244 1244 /** … … 1503 1503 if ( ! empty( $activity_ids ) ) { 1504 1504 1505 1505 // Delete all activity meta entries for activity items. 1506 BP_Activity_Activity::delete_activity_meta_entries( $activity_ids );1506 self::delete_activity_meta_entries( $activity_ids ); 1507 1507 1508 1508 // Setup empty array for comments. 1509 1509 $comment_ids = array(); … … 1512 1512 foreach ( $activity_ids as $activity_id ) { 1513 1513 1514 1514 // Attempt to delete comments. 1515 $comments = BP_Activity_Activity::delete( array(1515 $comments = self::delete( array( 1516 1516 'type' => 'activity_comment', 1517 1517 'item_id' => $activity_id 1518 1518 ) ); … … 1536 1536 * Delete the comments associated with a set of activity items. 1537 1537 * 1538 1538 * This method is no longer used by BuddyPress, and it is recommended not to 1539 * use it going forward, and use BP_Activity_Activity::delete() instead.1539 * use it going forward, and use self::delete() instead. 1540 1540 * 1541 1541 * @since 1.2.0 1542 1542 * … … 1603 1603 // Now fetch the activity comments and parse them into the correct position in the activities array. 1604 1604 foreach ( (array) $activities as $activity ) { 1605 1605 $top_level_parent_id = 'activity_comment' == $activity->type ? $activity->item_id : 0; 1606 $activity_comments[$activity->id] = BP_Activity_Activity::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id );1606 $activity_comments[$activity->id] = self::get_activity_comments( $activity->id, $activity->mptt_left, $activity->mptt_right, $spam, $top_level_parent_id ); 1607 1607 } 1608 1608 1609 1609 // Merge the comments with the activity items. … … 1800 1800 $right = intval( $left + 1 ); 1801 1801 1802 1802 // Get all descendants of this node. 1803 $comments = BP_Activity_Activity::get_child_comments( $parent_id );1803 $comments = self::get_child_comments( $parent_id ); 1804 1804 $descendants = wp_list_pluck( $comments, 'id' ); 1805 1805 1806 1806 // Loop the descendants and recalculate the left and right values. 1807 1807 foreach ( (array) $descendants as $descendant_id ) { 1808 $right = BP_Activity_Activity::rebuild_activity_comment_tree( $descendant_id, $right );1808 $right = self::rebuild_activity_comment_tree( $descendant_id, $right ); 1809 1809 } 1810 1810 1811 1811 // We've got the left value, and now that we've processed the children … … 1894 1894 * 1895 1895 * @since 1.5.0 1896 1896 * 1897 * @see BP_Activity_Activity::get_filter_sql()1897 * @see self::get_filter_sql() 1898 1898 * 1899 * @global wpdb $wpdb WordPress database object. 1899 * @global wpdb $wpdb WordPress database object. 1900 1900 * 1901 1901 * @param string $field The database field. 1902 1902 * @param array|bool $items The values for the IN clause, or false when none are found. … … 1960 1960 $filter_sql = array(); 1961 1961 1962 1962 if ( !empty( $filter_array['user_id'] ) ) { 1963 $user_sql = BP_Activity_Activity::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] );1963 $user_sql = self::get_in_operator_sql( 'a.user_id', $filter_array['user_id'] ); 1964 1964 if ( !empty( $user_sql ) ) 1965 1965 $filter_sql[] = $user_sql; 1966 1966 } 1967 1967 1968 1968 if ( !empty( $filter_array['object'] ) ) { 1969 $object_sql = BP_Activity_Activity::get_in_operator_sql( 'a.component', $filter_array['object'] );1969 $object_sql = self::get_in_operator_sql( 'a.component', $filter_array['object'] ); 1970 1970 if ( !empty( $object_sql ) ) 1971 1971 $filter_sql[] = $object_sql; 1972 1972 } 1973 1973 1974 1974 if ( !empty( $filter_array['action'] ) ) { 1975 $action_sql = BP_Activity_Activity::get_in_operator_sql( 'a.type', $filter_array['action'] );1975 $action_sql = self::get_in_operator_sql( 'a.type', $filter_array['action'] ); 1976 1976 if ( ! empty( $action_sql ) ) 1977 1977 $filter_sql[] = $action_sql; 1978 1978 } 1979 1979 1980 1980 if ( !empty( $filter_array['primary_id'] ) ) { 1981 $pid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] );1981 $pid_sql = self::get_in_operator_sql( 'a.item_id', $filter_array['primary_id'] ); 1982 1982 if ( !empty( $pid_sql ) ) 1983 1983 $filter_sql[] = $pid_sql; 1984 1984 } 1985 1985 1986 1986 if ( !empty( $filter_array['secondary_id'] ) ) { 1987 $sid_sql = BP_Activity_Activity::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] );1987 $sid_sql = self::get_in_operator_sql( 'a.secondary_item_id', $filter_array['secondary_id'] ); 1988 1988 if ( !empty( $sid_sql ) ) 1989 1989 $filter_sql[] = $sid_sql; 1990 1990 } … … 2019 2019 * 2020 2020 * @since 1.2.0 2021 2021 * 2022 * @global wpdb $wpdb WordPress database object. 2022 * @global wpdb $wpdb WordPress database object. 2023 2023 * 2024 2024 * @return string ISO timestamp. 2025 2025 */ -
class-bp-activity-feed.php
55 55 * @since 1.8.0 56 56 * 57 57 * @param string $key Property to check. 58 * @return bool Whether or notdata variable exists.58 * @return bool Whether data variable exists. 59 59 */ 60 60 public function __isset( $key ) { 61 61 return isset( $this->data[ $key ] ); -
class-bp-activity-query.php
134 134 if ( isset( $clause['compare'] ) ) { 135 135 $clause['compare'] = strtoupper( $clause['compare'] ); 136 136 } else { 137 $clause['compare'] = is set( $clause['value'] ) && is_array( $clause['value'] ) ? 'IN' : '=';137 $clause['compare'] = is_array( $clause['value'] ) ? 'IN' : '='; 138 138 } 139 139 140 140 // Default 'compare' to '=' if no valid operator is found. … … 156 156 $where = ''; 157 157 158 158 // Value. 159 if ( isset( $clause['value'] ) ) { 160 if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { 161 if ( ! is_array( $value ) ) { 162 $value = preg_split( '/[,\s]+/', $value ); 163 } 159 160 if ( in_array( $compare, array( 'IN', 'NOT IN', 'BETWEEN', 'NOT BETWEEN' ) ) ) { 161 if ( ! is_array( $value ) ) { 162 $value = preg_split( '/[,\s]+/', $value ); 164 163 } 164 } 165 165 166 167 if ( ! empty( $column ) &&true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) && is_int( $value ) ) {168 166 // Tinyint. 167 if ( true === in_array( $column, array( 'hide_sitewide', 'is_spam' ) ) && is_int( $value ) ) { 168 $sql_chunks['where'][] = $wpdb->prepare( "{$alias}{$column} = %d", $value ); 169 169 170 171 172 173 174 175 170 } else { 171 switch ( $compare ) { 172 // IN uses different syntax. 173 case 'IN' : 174 case 'NOT IN' : 175 $in_sql = BP_Activity_Activity::get_in_operator_sql( "{$alias}{$column}", $value ); 176 176 177 178 179 180 177 // 'NOT IN' operator is as easy as a string replace! 178 if ( 'NOT IN' === $compare ) { 179 $in_sql = str_replace( 'IN', 'NOT IN', $in_sql ); 180 } 181 181 182 183 182 $sql_chunks['where'][] = $in_sql; 183 break; 184 184 185 186 187 188 189 185 case 'BETWEEN' : 186 case 'NOT BETWEEN' : 187 $value = array_slice( $value, 0, 2 ); 188 $where = $wpdb->prepare( '%s AND %s', $value ); 189 break; 190 190 191 192 193 194 195 191 case 'LIKE' : 192 case 'NOT LIKE' : 193 $value = '%' . bp_esc_like( $value ) . '%'; 194 $where = $wpdb->prepare( '%s', $value ); 195 break; 196 196 197 198 199 197 default : 198 $where = $wpdb->prepare( '%s', $value ); 199 break; 200 200 201 }202 201 } 202 } 203 203 204 if ( $where ) { 205 $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}"; 206 } 204 if ( $where ) { 205 $sql_chunks['where'][] = "{$alias}{$column} {$compare} {$where}"; 207 206 } 208 207 208 209 209 /* 210 210 * Multiple WHERE clauses should be joined in parentheses. 211 211 */ -
class-bp-akismet.php
159 159 * usermeta, ensuring that it won't appear in the member header and 160 160 * elsewhere in the theme. 161 161 * 162 * This can't be done in BP_Akismet::check_activity() due to the162 * This can't be done in self::check_activity() due to the 163 163 * default AJAX implementation; see bp_dtheme_post_update(). 164 164 * 165 165 * @since 1.6.0 … … 172 172 */ 173 173 public function check_member_activity_update( $content, $user_id, $activity_id ) { 174 174 // By default, only handle activity updates and activity comments. 175 if ( empty( $this->last_activity ) || !in_array( $this->last_activity->type, BP_Akismet::get_activity_types() ) )175 if ( empty( $this->last_activity ) || !in_array( $this->last_activity->type, self::get_activity_types() ) ) 176 176 return; 177 177 178 178 // Was this $activity_id just marked as spam? If not, bail out. … … 196 196 } 197 197 198 198 // By default, only handle activity updates and activity comments. 199 if ( ! in_array( bp_get_activity_type(), BP_Akismet::get_activity_types(), true ) ) {199 if ( ! in_array( bp_get_activity_type(), self::get_activity_types(), true ) ) { 200 200 return; 201 201 } 202 202 … … 235 235 236 236 // By default, only handle activity updates and activity comments. 237 237 $current_comment = bp_activity_current_comment(); 238 if ( empty( $current_comment ) || ! in_array( $current_comment->type, BP_Akismet::get_activity_types(), true ) ) {238 if ( empty( $current_comment ) || ! in_array( $current_comment->type, self::get_activity_types(), true ) ) { 239 239 return; 240 240 } 241 241 … … 296 296 * "by_akismet" (automatically spammed). 297 297 */ 298 298 public function mark_as_spam( $activity, $source ) { 299 // Record this item so we can do some tidyup in BP_Akismet::check_member_activity_update().299 // Record this item so we can do some tidyup in self::check_member_activity_update(). 300 300 $this->last_activity = $activity; 301 301 302 302 /** … … 405 405 */ 406 406 public function check_activity( $activity ) { 407 407 // By default, only handle activity updates and activity comments. 408 if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )408 if ( !in_array( $activity->type, self::get_activity_types() ) ) 409 409 return; 410 410 411 411 // Make sure last_activity is clear to avoid any confusion. … … 412 412 $this->last_activity = null; 413 413 414 414 // Build data package for Akismet. 415 $activity_data = BP_Akismet::build_akismet_data_package( $activity );415 $activity_data = self::build_akismet_data_package( $activity ); 416 416 417 417 // Check with Akismet to see if this is spam. 418 418 $activity_data = $this->send_akismet_request( $activity_data, 'check', 'spam' ); … … 466 466 */ 467 467 public function update_activity_spam_meta( $activity ) { 468 468 // By default, only handle activity updates and activity comments. 469 if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )469 if ( !in_array( $activity->type, self::get_activity_types() ) ) 470 470 return; 471 471 472 472 $this->update_activity_history( … … 492 492 */ 493 493 public function update_activity_ham_meta( $activity ) { 494 494 // By default, only handle activity updates and activity comments. 495 if ( !in_array( $activity->type, BP_Akismet::get_activity_types() ) )495 if ( !in_array( $activity->type, self::get_activity_types() ) ) 496 496 return; 497 497 498 498 $this->update_activity_history( … … 522 522 return; 523 523 524 524 // By default, only handle activity updates and activity comments. 525 if ( !in_array( $this->last_activity->type, BP_Akismet::get_activity_types() ) )525 if ( !in_array( $this->last_activity->type, self::get_activity_types() ) ) 526 526 return; 527 527 528 528 // Spam. … … 665 665 * @param object $item Activity item. 666 666 */ 667 667 function history_metabox( $item ) { 668 $history = BP_Akismet::get_activity_history( $item->id );668 $history = self::get_activity_history( $item->id ); 669 669 670 670 if ( empty( $history ) ) { 671 671 $message = '—';