Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Forum Actions:

* Remove bbp_has_topics() from forum trash and topic delete functions.
* Use WP_Query's instead.
* Remove phpdoc references to bbp_has_topics() where it's no longer used.
* Fixes #1914.
* For 2.2 branch.

git-svn-id: http://bbpress.svn.wordpress.org/branches/plugin@4117 9866e705-20ec-0310-96e7-cbb4277adcfb
  • Loading branch information...
commit 0eb6915158cc90e737f62828ad54e5b260fed811 1 parent 903f955
johnjamesjacoby authored
3  bbp-includes/bbp-core-shortcodes.php
@@ -243,7 +243,6 @@ public function display_forum_index() {
243 243 *
244 244 * @param array $attr
245 245 * @param string $content
246   - * @uses bbp_has_topics()
247 246 * @uses get_template_part()
248 247 * @uses bbp_single_forum_description()
249 248 * @return string
@@ -308,7 +307,6 @@ public function display_forum_form() {
308 307 * @param array $attr
309 308 * @param string $content
310 309 * @uses bbp_get_hidden_forum_ids()
311   - * @uses bbp_has_topics()
312 310 * @uses get_template_part()
313 311 * @return string
314 312 */
@@ -598,7 +596,6 @@ public function display_topic_tag_form() {
598 596 *
599 597 * @param array $attr
600 598 * @param string $content
601   - * @uses bbp_has_topics()
602 599 * @uses get_template_part()
603 600 * @uses bbp_single_forum_description()
604 601 * @return string
56 bbp-includes/bbp-forum-functions.php
@@ -1951,7 +1951,6 @@ function bbp_check_forum_edit() {
1951 1951 * @uses bbp_get_forum_id() To validate the forum ID
1952 1952 * @uses bbp_is_forum() To make sure it's a forum
1953 1953 * @uses bbp_get_topic_post_type() To get the topic post type
1954   - * @uses bbp_has_topics() To get the topics
1955 1954 * @uses bbp_topics() To make sure there are topics to loop through
1956 1955 * @uses wp_trash_post() To trash the post
1957 1956 * @uses update_post_meta() To update the forum meta of trashed topics
@@ -1965,15 +1964,17 @@ function bbp_delete_forum_topics( $forum_id = 0 ) {
1965 1964 return;
1966 1965
1967 1966 // Forum is being permanently deleted, so its topics gotta go too
1968   - if ( bbp_has_topics( array(
1969   - 'post_type' => bbp_get_topic_post_type(),
1970   - 'post_parent' => $forum_id,
1971   - 'post_status' => 'any',
1972   - 'posts_per_page' => -1
  1967 + if ( $topics = new WP_Query( array(
  1968 + 'suppress_filters' => true,
  1969 + 'post_type' => bbp_get_topic_post_type(),
  1970 + 'post_parent' => $forum_id,
  1971 + 'post_status' => 'any',
  1972 + 'posts_per_page' => -1,
  1973 + 'nopaging' => true,
  1974 + 'fields' => 'id=>parent'
1973 1975 ) ) ) {
1974   - while ( bbp_topics() ) {
1975   - bbp_the_topic();
1976   - wp_delete_post( bbpress()->topic_query->post->ID, true );
  1976 + foreach ( $topics->posts as $topic ) {
  1977 + wp_delete_post( $topic->ID, true );
1977 1978 }
1978 1979 }
1979 1980 }
@@ -1990,8 +1991,6 @@ function bbp_delete_forum_topics( $forum_id = 0 ) {
1990 1991 * @uses bbp_get_closed_status_id() To return closed post status
1991 1992 * @uses bbp_get_pending_status_id() To return pending post status
1992 1993 * @uses bbp_get_topic_post_type() To get the topic post type
1993   - * @uses bbp_has_topics() To get the topics
1994   - * @uses bbp_topics() To make sure there are topics to loop through
1995 1994 * @uses wp_trash_post() To trash the post
1996 1995 * @uses update_post_meta() To update the forum meta of trashed topics
1997 1996 * @return If forum is not valid
@@ -2011,22 +2010,23 @@ function bbp_trash_forum_topics( $forum_id = 0 ) {
2011 2010 ) );
2012 2011
2013 2012 // Forum is being trashed, so its topics are trashed too
2014   - if ( bbp_has_topics( array(
2015   - 'post_type' => bbp_get_topic_post_type(),
2016   - 'post_parent' => $forum_id,
2017   - 'post_status' => $post_stati,
2018   - 'posts_per_page' => -1
  2013 + if ( $topics = new WP_Query( array(
  2014 + 'suppress_filters' => true,
  2015 + 'post_type' => bbp_get_topic_post_type(),
  2016 + 'post_parent' => $forum_id,
  2017 + 'post_status' => $post_stati,
  2018 + 'posts_per_page' => -1,
  2019 + 'nopaging' => true,
  2020 + 'fields' => 'id=>parent'
2019 2021 ) ) ) {
2020 2022
2021 2023 // Prevent debug notices
2022 2024 $pre_trashed_topics = array();
2023   - $bbp = bbpress();
2024 2025
2025 2026 // Loop through topics, trash them, and add them to array
2026   - while ( bbp_topics() ) {
2027   - bbp_the_topic();
2028   - wp_trash_post( $bbp->topic_query->post->ID );
2029   - $pre_trashed_topics[] = $bbp->topic_query->post->ID;
  2027 + foreach ( $topics->posts as $topic ) {
  2028 + wp_trash_post( $topic->ID, true );
  2029 + $pre_trashed_topics[] = $topic->ID;
2030 2030 }
2031 2031
2032 2032 // Set a post_meta entry of the topics that were trashed by this action.
@@ -2086,11 +2086,6 @@ function bbp_untrash_forum_topics( $forum_id = 0 ) {
2086 2086 * @uses bbp_get_forum_id() To get the forum id
2087 2087 * @uses bbp_is_forum() To check if the passed id is a forum
2088 2088 * @uses do_action() Calls 'bbp_delete_forum' with the forum id
2089   - * @uses bbp_has_topics() To check if the forum has topics
2090   - * @uses bbp_topics() To loop through the topics
2091   - * @uses bbp_the_topic() To set a topic as the current topic in the loop
2092   - * @uses bbp_get_topic_id() To get the topic id
2093   - * @uses wp_delete_post() To delete the topic
2094 2089 */
2095 2090 function bbp_delete_forum( $forum_id = 0 ) {
2096 2091 $forum_id = bbp_get_forum_id( $forum_id );
@@ -2112,12 +2107,6 @@ function bbp_delete_forum( $forum_id = 0 ) {
2112 2107 * @uses bbp_get_forum_id() To get the forum id
2113 2108 * @uses bbp_is_forum() To check if the passed id is a forum
2114 2109 * @uses do_action() Calls 'bbp_trash_forum' with the forum id
2115   - * @uses bbp_has_topics() To check if the forum has topics
2116   - * @uses bbp_topics() To loop through the topics
2117   - * @uses bbp_the_topic() To set a topic as the current topic in the loop
2118   - * @uses bbp_get_topic_id() To get the topic id
2119   - * @uses wp_trash_post() To trash the topic
2120   - * @uses update_post_meta() To save a list of just trashed topics for future use
2121 2110 */
2122 2111 function bbp_trash_forum( $forum_id = 0 ) {
2123 2112 $forum_id = bbp_get_forum_id( $forum_id );
@@ -2135,9 +2124,6 @@ function bbp_trash_forum( $forum_id = 0 ) {
2135 2124 * @uses bbp_get_forum_id() To get the forum id
2136 2125 * @uses bbp_is_forum() To check if the passed id is a forum
2137 2126 * @uses do_action() Calls 'bbp_untrash_forum' with the forum id
2138   - * @uses get_post_meta() To get the list of topics which were trashed with the
2139   - * forum
2140   - * @uses wp_untrash_post() To untrash the topic
2141 2127 */
2142 2128 function bbp_untrash_forum( $forum_id = 0 ) {
2143 2129 $forum_id = bbp_get_forum_id( $forum_id );

0 comments on commit 0eb6915

Please sign in to comment.
Something went wrong with that request. Please try again.