Changeset 6191 for trunk/src/includes/admin/tools.php
- Timestamp:
- 12/28/2016 04:24:52 AM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/includes/admin/tools.php (modified) (55 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/admin/tools.php
r6189 r6191 1090 1090 WHERE `topics`.`post_type` = '{$tpt}' 1091 1091 AND `topics`.`post_status` IN ( '{$pps}', '{$cps}' ) 1092 GROUP BY `topics`.`ID`) ;";1092 GROUP BY `topics`.`ID`)"; 1093 1093 1094 1094 if ( is_wp_error( $bbp_db->query( $sql ) ) ) { … … 1119 1119 $result = __( 'Failed!', 'bbpress' ); 1120 1120 1121 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_voice_count' ;";1121 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_voice_count'"; 1122 1122 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1123 1123 return array( 1, sprintf( $statement, $result ) ); … … 1139 1139 AND `posts`.`post_status` IN ( '{$pps}', '{$cps}' ) 1140 1140 AND `posts`.`post_author` != '0' 1141 GROUP BY `postmeta`.`meta_value`) ;";1141 GROUP BY `postmeta`.`meta_value`)"; 1142 1142 1143 1143 if ( is_wp_error( $bbp_db->query( $sql ) ) ) { … … 1168 1168 $result = __( 'Failed!', 'bbpress' ); 1169 1169 1170 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_reply_count_hidden' ;";1170 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_reply_count_hidden'"; 1171 1171 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1172 1172 return array( 1, sprintf( $statement, $result ) ); … … 1179 1179 $pps = bbp_get_pending_status_id(); 1180 1180 1181 $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$rpt}' AND `post_status` IN ( '{$tps}', '{$sps}', '{$pps}' ) GROUP BY `post_parent`) ;";1181 $sql = "INSERT INTO `{$bbp_db->postmeta}` (`post_id`, `meta_key`, `meta_value`) (SELECT `post_parent`, '_bbp_reply_count_hidden', COUNT(`post_status`) as `meta_value` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$rpt}' AND `post_status` IN ( '{$tps}', '{$sps}', '{$pps}' ) GROUP BY `post_parent`)"; 1182 1182 if ( is_wp_error( $bbp_db->query( $sql ) ) ) { 1183 1183 return array( 2, sprintf( $statement, $result ) ); … … 1216 1216 AND `forummeta`.`meta_key` = '_bbp_old_forum_id' 1217 1217 WHERE `forum`.`post_type` = '" . bbp_get_forum_post_type() . "' 1218 GROUP BY `forum`.`ID` ;" );1218 GROUP BY `forum`.`ID`" ); 1219 1219 1220 1220 // Bail if forum IDs returned an error … … 1235 1235 1236 1236 // Attempt to update group meta 1237 $updated = $bbp_db->query( "UPDATE `{$groups_meta_table}` SET `meta_value` = '{$group_forums->ID}' WHERE `meta_key` = 'forum_id' AND `meta_value` = '{$group_forums->meta_value}' ;" );1237 $updated = $bbp_db->query( "UPDATE `{$groups_meta_table}` SET `meta_value` = '{$group_forums->ID}' WHERE `meta_key` = 'forum_id' AND `meta_value` = '{$group_forums->meta_value}'" ); 1238 1238 1239 1239 // Bump the count … … 1243 1243 1244 1244 // Update group to forum relationship data 1245 $group_id = (int) $bbp_db->get_var( "SELECT `group_id` FROM `{$groups_meta_table}` WHERE `meta_key` = 'forum_id' AND `meta_value` = '{$group_forums->ID}' ;" );1245 $group_id = (int) $bbp_db->get_var( "SELECT `group_id` FROM `{$groups_meta_table}` WHERE `meta_key` = 'forum_id' AND `meta_value` = '{$group_forums->ID}'" ); 1246 1246 if ( ! empty( $group_id ) ) { 1247 1247 … … 1250 1250 1251 1251 // Get the group status 1252 $group_status = $bbp_db->get_var( "SELECT `status` FROM `{$groups_table}` WHERE `id` = '{$group_id}' ;" );1252 $group_status = $bbp_db->get_var( "SELECT `status` FROM `{$groups_table}` WHERE `id` = '{$group_id}'" ); 1253 1253 1254 1254 // Sync up forum visibility based on group status … … 1343 1343 $result = __( 'Failed!', 'bbpress' ); 1344 1344 1345 $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ( '_bbp_topic_count', '_bbp_total_topic_count', '_bbp_topic_count_hidden' ) ;";1345 $sql_delete = "DELETE FROM {$bbp_db->postmeta} WHERE meta_key IN ( '_bbp_topic_count', '_bbp_total_topic_count', '_bbp_topic_count_hidden' )"; 1346 1346 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1347 1347 return array( 1, sprintf( $statement, $result ) ); … … 1425 1425 $result = __( 'Failed!', 'bbpress' ); 1426 1426 1427 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author` ;";1427 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; 1428 1428 $insert_rows = $bbp_db->get_results( $sql_select ); 1429 1429 … … 1442 1442 } 1443 1443 1444 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;";1444 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'"; 1445 1445 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1446 1446 return array( 3, sprintf( $statement, $result ) ); … … 1449 1449 foreach ( array_chunk( $insert_values, 10000 ) as $chunk ) { 1450 1450 $chunk = "\n" . implode( ",\n", $chunk ); 1451 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk} ;";1451 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk}"; 1452 1452 1453 1453 if ( is_wp_error( $bbp_db->query( $sql_insert ) ) ) { … … 1477 1477 $result = __( 'Failed!', 'bbpress' ); 1478 1478 1479 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author` ;";1479 $sql_select = "SELECT `post_author`, COUNT(DISTINCT `ID`) as `_count` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_reply_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' GROUP BY `post_author`"; 1480 1480 $insert_rows = $bbp_db->get_results( $sql_select ); 1481 1481 … … 1494 1494 } 1495 1495 1496 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;";1496 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'"; 1497 1497 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1498 1498 return array( 3, sprintf( $statement, $result ) ); … … 1501 1501 foreach ( array_chunk( $insert_values, 10000 ) as $chunk ) { 1502 1502 $chunk = "\n" . implode( ",\n", $chunk ); 1503 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk} ;";1503 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk}"; 1504 1504 1505 1505 if ( is_wp_error( $bbp_db->query( $sql_insert ) ) ) { … … 1530 1530 1531 1531 $key = $bbp_db->prefix . '_bbp_favorites'; 1532 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;" );1532 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `favorites` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'" ); 1533 1533 1534 1534 if ( is_wp_error( $users ) ) { … … 1536 1536 } 1537 1537 1538 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' ;" );1538 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 1539 1539 1540 1540 if ( is_wp_error( $topics ) ) { … … 1565 1565 } 1566 1566 1567 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;";1567 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'"; 1568 1568 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1569 1569 return array( 4, sprintf( $statement, $result ) ); … … 1572 1572 foreach ( array_chunk( $values, 10000 ) as $chunk ) { 1573 1573 $chunk = "\n" . implode( ",\n", $chunk ); 1574 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk} ;";1574 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk}"; 1575 1575 if ( is_wp_error( $bbp_db->query( $sql_insert ) ) ) { 1576 1576 return array( 5, sprintf( $statement, $result ) ); … … 1600 1600 1601 1601 $key = $bbp_db->prefix . '_bbp_subscriptions'; 1602 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;" );1602 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'" ); 1603 1603 1604 1604 if ( is_wp_error( $users ) ) { … … 1606 1606 } 1607 1607 1608 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' ;" );1608 $topics = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 1609 1609 if ( is_wp_error( $topics ) ) { 1610 1610 return array( 2, sprintf( $statement, $result ) ); … … 1634 1634 } 1635 1635 1636 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;";1636 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'"; 1637 1637 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1638 1638 return array( 4, sprintf( $statement, $result ) ); … … 1641 1641 foreach ( array_chunk( $values, 10000 ) as $chunk ) { 1642 1642 $chunk = "\n" . implode( ",\n", $chunk ); 1643 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk} ;";1643 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk}"; 1644 1644 if ( is_wp_error( $bbp_db->query( $sql_insert ) ) ) { 1645 1645 return array( 5, sprintf( $statement, $result ) ); … … 1669 1669 1670 1670 $key = $bbp_db->prefix . '_bbp_forum_subscriptions'; 1671 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;" );1671 $users = $bbp_db->get_results( "SELECT `user_id`, `meta_value` AS `subscriptions` FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'" ); 1672 1672 1673 1673 if ( is_wp_error( $users ) ) { … … 1675 1675 } 1676 1676 1677 $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "' ;" );1677 $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "' AND `post_status` = '" . bbp_get_public_status_id() . "'" ); 1678 1678 if ( is_wp_error( $forums ) ) { 1679 1679 return array( 2, sprintf( $statement, $result ) ); … … 1703 1703 } 1704 1704 1705 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}' ;";1705 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` = '{$key}'"; 1706 1706 if ( is_wp_error( $bbp_db->query( $sql_delete ) ) ) { 1707 1707 return array( 4, sprintf( $statement, $result ) ); … … 1710 1710 foreach ( array_chunk( $values, 10000 ) as $chunk ) { 1711 1711 $chunk = "\n" . implode( ",\n", $chunk ); 1712 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk} ;";1712 $sql_insert = "INSERT INTO `{$bbp_db->usermeta}` (`user_id`, `meta_key`, `meta_value`) VALUES {$chunk}"; 1713 1713 if ( is_wp_error( $bbp_db->query( $sql_insert ) ) ) { 1714 1714 return array( 5, sprintf( $statement, $result ) ); … … 1801 1801 1802 1802 // First, delete everything. 1803 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id', '_bbp_last_active_time' ) ;" ) ) ) {1803 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` IN ( '_bbp_last_reply_id', '_bbp_last_topic_id', '_bbp_last_active_id', '_bbp_last_active_time' )" ) ) ) { 1804 1804 return array( 1, sprintf( $statement, $result ) ); 1805 1805 } … … 1816 1816 FROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` 1817 1817 WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' 1818 GROUP BY `topic`.`ID` ) ;" ) ) ) {1818 GROUP BY `topic`.`ID` )" ) ) ) { 1819 1819 return array( 2, sprintf( $statement, $result ) ); 1820 1820 } … … 1825 1825 FROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply` 1826 1826 ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_reply_id' 1827 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' ) ;" ) ) ) {1827 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' )" ) ) ) { 1828 1828 return array( 3, sprintf( $statement, $result ) ); 1829 1829 } … … 1834 1834 FROM `{$bbp_db->posts}` AS `forum` INNER JOIN `{$bbp_db->posts}` AS `topic` ON `forum`.`ID` = `topic`.`post_parent` 1835 1835 WHERE `topic`.`post_status` = '{$pps}' AND `forum`.`post_type` = '{$fpt}' AND `topic`.`post_type` = '{$tpt}' 1836 GROUP BY `forum`.`ID` ) ;" ) ) ) {1836 GROUP BY `forum`.`ID` )" ) ) ) { 1837 1837 return array( 4, sprintf( $statement, $result ) ); 1838 1838 } … … 1843 1843 FROM `{$bbp_db->posts}` AS `forum` LEFT JOIN `{$bbp_db->postmeta}` AS `topic` 1844 1844 ON `forum`.`ID` = `topic`.`post_id` AND `topic`.`meta_key` = '_bbp_last_topic_id' 1845 WHERE `topic`.`meta_id` IS NULL AND `forum`.`post_type` = '{$fpt}' ) ;" ) ) ) {1845 WHERE `topic`.`meta_id` IS NULL AND `forum`.`post_type` = '{$fpt}' )" ) ) ) { 1846 1846 return array( 5, sprintf( $statement, $result ) ); 1847 1847 } … … 1852 1852 FROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` 1853 1853 WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' 1854 GROUP BY `topic`.`ID` ) ;" ) ) ) {1854 GROUP BY `topic`.`ID` )" ) ) ) { 1855 1855 return array( 6, sprintf( $statement, $result ) ); 1856 1856 } … … 1861 1861 FROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply` 1862 1862 ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_id' 1863 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' ) ;" ) ) ) {1863 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' )" ) ) ) { 1864 1864 return array( 7, sprintf( $statement, $result ) ); 1865 1865 } … … 1870 1870 FROM `{$bbp_db->posts}` AS `topic` INNER JOIN `{$bbp_db->posts}` AS `reply` ON `topic`.`ID` = `reply`.`post_parent` 1871 1871 WHERE `reply`.`post_status` = '{$pps}' AND `topic`.`post_type` = '{$tpt}' AND `reply`.`post_type` = '{$rpt}' 1872 GROUP BY `topic`.`ID` ) ;" ) ) ) {1872 GROUP BY `topic`.`ID` )" ) ) ) { 1873 1873 return array( 8, sprintf( $statement, $result ) ); 1874 1874 } … … 1879 1879 FROM `{$bbp_db->posts}` AS `topic` LEFT JOIN `{$bbp_db->postmeta}` AS `reply` 1880 1880 ON `topic`.`ID` = `reply`.`post_id` AND `reply`.`meta_key` = '_bbp_last_active_time' 1881 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' ) ;" ) ) ) {1881 WHERE `reply`.`meta_id` IS NULL AND `topic`.`post_type` = '{$tpt}' )" ) ) ) { 1882 1882 return array( 9, sprintf( $statement, $result ) ); 1883 1883 } 1884 1884 1885 1885 // Forums need to know what their last active item is as well. Now it gets a bit more complex to do in the database. 1886 $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$fpt}' and `post_status` != 'auto-draft' ;" );1886 $forums = $bbp_db->get_col( "SELECT `ID` FROM `{$bbp_db->posts}` WHERE `post_type` = '{$fpt}' and `post_status` != 'auto-draft'" ); 1887 1887 if ( is_wp_error( $forums ) ) { 1888 1888 return array( 10, sprintf( $statement, $result ) ); … … 1928 1928 $result = __( 'Failed!', 'bbpress' ); 1929 1929 1930 $forums = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "' ;" );1930 $forums = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_forum_post_type() . "'" ); 1931 1931 1932 1932 // Bail if no forums found … … 1997 1997 $changed = 0; 1998 1998 1999 $closed_topics = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'closed' ;" );1999 $closed_topics = $bbp_db->get_col( "SELECT ID FROM `{$bbp_db->posts}` WHERE `post_type` = '" . bbp_get_topic_post_type() . "' AND `post_status` = 'closed'" ); 2000 2000 2001 2001 // Bail if no closed topics found … … 2066 2066 2067 2067 // First, delete everything. 2068 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_forum_id' ;" ) ) ) {2068 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_forum_id'" ) ) ) { 2069 2069 return array( 1, sprintf( $statement, $result ) ); 2070 2070 } … … 2080 2080 AS `topic` 2081 2081 WHERE `topic`.`post_type` = '{$tpt}' 2082 GROUP BY `topic`.`ID` ) ;" ) ) ) {2082 GROUP BY `topic`.`ID` )" ) ) ) { 2083 2083 return array( 2, sprintf( $statement, $result ) ); 2084 2084 } … … 2094 2094 WHERE `topic`.`post_type` = '{$tpt}' 2095 2095 AND `reply`.`post_type` = '{$rpt}' 2096 GROUP BY `reply`.`ID` ) ;" ) ) ) {2096 GROUP BY `reply`.`ID` )" ) ) ) { 2097 2097 return array( 3, sprintf( $statement, $result ) ); 2098 2098 } … … 2121 2121 2122 2122 // First, delete everything. 2123 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_topic_id' ;" ) ) ) {2123 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_topic_id'" ) ) ) { 2124 2124 return array( 1, sprintf( $statement, $result ) ); 2125 2125 } … … 2135 2135 AS `topic` 2136 2136 WHERE `topic`.`post_type` = '{$tpt}' 2137 GROUP BY `topic`.`ID` ) ;" ) ) ) {2137 GROUP BY `topic`.`ID` )" ) ) ) { 2138 2138 return array( 3, sprintf( $statement, $result ) ); 2139 2139 } … … 2149 2149 WHERE `topic`.`post_type` = '{$tpt}' 2150 2150 AND `reply`.`post_type` = '{$rpt}' 2151 GROUP BY `reply`.`ID` ) ;" ) ) ) {2151 GROUP BY `reply`.`ID` )" ) ) ) { 2152 2152 return array( 4, sprintf( $statement, $result ) ); 2153 2153 } … … 2176 2176 2177 2177 // Delete cases where `_bbp_reply_to` was accidentally set to itself 2178 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_reply_to' AND `post_id` = `meta_value` ;" ) ) ) {2178 if ( is_wp_error( $bbp_db->query( "DELETE FROM `{$bbp_db->postmeta}` WHERE `meta_key` = '_bbp_reply_to' AND `post_id` = `meta_value`" ) ) ) { 2179 2179 return array( 1, sprintf( $statement, $result ) ); 2180 2180 } … … 2193 2193 ON `a`.`menu_order` = `b`.`menu_order` 2194 2194 AND `a`.`post_parent` = `b`.`post_parent` 2195 WHERE `post_type` = '{$rpt}' ;", OBJECT_K );2195 WHERE `post_type` = '{$rpt}'", OBJECT_K ); 2196 2196 2197 2197 // Bail if no replies returned … … 2229 2229 $changed = $total = 0; 2230 2230 $key = $bbp_db->prefix . '_bbp_favorites'; 2231 $favorites = $bbp_db->get_results( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'");2231 $favorites = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s", $key ) ); 2232 2232 2233 2233 // Bail if no closed topics found … … 2292 2292 $changed = $total = 0; 2293 2293 $key = $bbp_db->prefix . '_bbp_subscriptions'; 2294 $subscriptions = $bbp_db->get_results( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = '{$key}'");2294 $subscriptions = $bbp_db->get_results( $bbp_db->prepare( "SELECT * FROM {$bbp_db->usermeta} WHERE meta_key = %s", $key ) ); 2295 2295 2296 2296 // Bail if no closed topics found … … 2468 2468 $statement = __( 'Deleting Post Meta… %s', 'bbpress' ); 2469 2469 $sql_meta = implode( "', '", $sql_meta ); 2470 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}') ;";2470 $sql_delete = "DELETE FROM `{$bbp_db->postmeta}` WHERE `post_id` IN ('{$sql_meta}')"; 2471 2471 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2472 2472 $messages[] = sprintf( $statement, $result ); … … 2482 2482 $statement = __( 'Deleting Post Revisions… %s', 'bbpress' ); 2483 2483 $sql_meta = implode( "', '", $sql_meta ); 2484 $sql_delete = "DELETE FROM `{$bbp_db->posts}` WHERE `post_parent` IN ('{$sql_meta}') AND `post_type` = 'revision' ;";2484 $sql_delete = "DELETE FROM `{$bbp_db->posts}` WHERE `post_parent` IN ('{$sql_meta}') AND `post_type` = 'revision'"; 2485 2485 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2486 2486 $messages[] = sprintf( $statement, $result ); … … 2490 2490 2491 2491 $statement = __( 'Deleting Forum Moderators… %s', 'bbpress' ); 2492 $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'forum-mod' ;";2492 $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'forum-mod'"; 2493 2493 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2494 2494 $messages[] = sprintf( $statement, $result ); … … 2497 2497 2498 2498 $statement = __( 'Deleting Topic Tags… %s', 'bbpress' ); 2499 $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag' ;";2499 $sql_delete = "DELETE a,b,c FROM `{$bbp_db->terms}` AS a LEFT JOIN `{$bbp_db->term_taxonomy}` AS c ON a.term_id = c.term_id LEFT JOIN `{$bbp_db->term_relationships}` AS b ON b.term_taxonomy_id = c.term_taxonomy_id WHERE c.taxonomy = 'topic-tag'"; 2500 2500 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2501 2501 $messages[] = sprintf( $statement, $result ); … … 2513 2513 $statement = __( 'Deleting Imported Users… %s', 'bbpress' ); 2514 2514 $sql_meta = implode( "', '", $sql_meta ); 2515 $sql_delete = "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}') ;";2515 $sql_delete = "DELETE FROM `{$bbp_db->users}` WHERE `ID` IN ('{$sql_meta}')"; 2516 2516 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2517 2517 $messages[] = sprintf( $statement, $result ); 2518 2518 $statement = __( 'Deleting Imported User Meta… %s', 'bbpress' ); 2519 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}') ;";2519 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `user_id` IN ('{$sql_meta}')"; 2520 2520 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2521 2521 $messages[] = sprintf( $statement, $result ); … … 2525 2525 // Next, if we still have users that were not imported delete that meta data 2526 2526 $statement = __( 'Deleting User Meta… %s', 'bbpress' ); 2527 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%' ;";2527 $sql_delete = "DELETE FROM `{$bbp_db->usermeta}` WHERE `meta_key` LIKE '%%_bbp_%%'"; 2528 2528 $result = is_wp_error( $bbp_db->query( $sql_delete ) ) ? $failed : $success; 2529 2529 $messages[] = sprintf( $statement, $result );
Note: See TracChangeset
for help on using the changeset viewer.