Changeset 6320 for trunk/src/includes/admin/tools/repair.php
- Timestamp:
- 02/26/2017 07:12:34 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools/repair.php
r6282 r6320 233 233 $result = __( 'Failed!', 'bbpress' ); 234 234 235 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_voice_count'";235 $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ('_bbp_voice_count', '_bbp_engagement')"; 236 236 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 237 237 return array( 1, sprintf( $statement, $result ) ); … … 244 244 $cps = bbp_get_closed_status_id(); 245 245 246 $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) ( 247 SELECT `postmeta`.`meta_value`, '_bbp_voice_count', COUNT(DISTINCT `post_author`) as `meta_value` 248 FROM `{$bbp_db->posts}` AS `posts` 249 LEFT JOIN `{$bbp_db->postmeta}` AS `postmeta` 250 ON `posts`.`ID` = `postmeta`.`post_id` 251 AND `postmeta`.`meta_key` = '_bbp_topic_id' 252 WHERE `posts`.`post_type` IN ( '{$tpt}', '{$rpt}' ) 253 AND `posts`.`post_status` IN ( '{$pps}', '{$cps}' ) 254 AND `posts`.`post_author` != '0' 255 GROUP BY `postmeta`.`meta_value`)"; 256 257 if ( is_wp_error( $bbp_db->query( $sql ) ) ) { 246 $voice_id_sql = $bbp_db->prepare( "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) ( 247 SELECT postmeta.meta_value, '_bbp_engagement', posts.post_author 248 FROM {$bbp_db->posts} AS posts 249 LEFT JOIN {$bbp_db->postmeta} AS postmeta 250 ON posts.ID = postmeta.post_id 251 AND postmeta.meta_key = '_bbp_topic_id' 252 WHERE posts.post_type IN (%s, %s) 253 AND posts.post_status IN (%s, %s))", $tpt, $rpt, $pps, $cps ); 254 255 if ( is_wp_error( $bbp_db->query( $voice_id_sql ) ) ) { 258 256 return array( 2, sprintf( $statement, $result ) ); 257 } 258 259 $voice_count_sql = "INSERT INTO {$bbp_db->postmeta} (post_id, meta_key, meta_value) ( 260 SELECT post_id, '_bbp_voice_count', COUNT(DISTINCT meta_value) 261 FROM {$bbp_db->postmeta} 262 WHERE meta_key = '_bbp_engagement' 263 GROUP BY post_id ORDER BY post_id)"; 264 265 if ( is_wp_error( $bbp_db->query( $voice_count_sql ) ) ) { 266 return array( 3, sprintf( $statement, $result ) ); 259 267 } 260 268 … … 695 703 696 704 // Query for users with favorites 705 $key = $bbp_db->prefix . '_bbp_favorites'; 697 706 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'" ); 698 707
Note: See TracChangeset
for help on using the changeset viewer.