Changeset 6848
- Timestamp:
- 08/09/2018 07:53:28 PM (6 years ago)
- Location:
- trunk
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/common/functions.php
r6838 r6848 1729 1729 1730 1730 // Bail if nothing passed 1731 if ( empty( $p arent_id ) || empty( $post_type ) ) {1731 if ( empty( $post_type ) ) { 1732 1732 return false; 1733 1733 } -
trunk/src/includes/forums/functions.php
r6814 r6848 75 75 // Update the forum and hierarchy 76 76 bbp_update_forum( array( 77 'forum_id' => $forum_id 77 'forum_id' => $forum_id, 78 'post_parent' => $forum_data['post_parent'] 78 79 ) ); 79 80 … … 99 100 */ 100 101 do_action( 'bbp_insert_forum', (int) $forum_id ); 102 103 // Bump the last changed cache 104 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' ); 101 105 102 106 // Return forum_id … … 1367 1371 1368 1372 // Get the topic's replies. 1369 $replies = bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type() ); 1370 $count = count( $replies ); 1373 $count = bbp_get_public_child_count( $topic_id, bbp_get_reply_post_type() ); 1371 1374 1372 1375 // If we're unapproving, set count to negative. … … 1593 1596 $forum_id = bbp_get_forum_id( $forum_id ); 1594 1597 1598 // Maybe query for counts 1595 1599 if ( empty( $subforums ) ) { 1596 $subforums = count( bbp_forum_query_subforum_ids( $forum_id) );1600 $subforums = bbp_get_public_child_count( $forum_id, bbp_get_forum_post_type() ); 1597 1601 } 1598 1602 … … 1629 1633 1630 1634 // Get total topics for this forum 1631 $topics = (int) count( bbp_forum_query_topic_ids( $forum_id) );1635 $topics = bbp_get_public_child_count( $forum_id, bbp_get_topic_post_type() ); 1632 1636 1633 1637 // Calculate total topics in this forum … … 1729 1733 $topic_ids = bbp_forum_query_topic_ids( $forum_id ); 1730 1734 if ( ! empty( $topic_ids ) ) { 1731 $query = new WP_Query( array( 1732 'fields' => 'ids', 1733 'post_parent__in' => $topic_ids, 1734 'post_status' => bbp_get_public_status_id(), 1735 'post_type' => bbp_get_reply_post_type(), 1736 'posts_per_page' => -1, 1737 1738 // Performance 1739 'nopaging' => true, 1740 'suppress_filters' => true, 1741 'update_post_term_cache' => false, 1742 'update_post_meta_cache' => false, 1743 'ignore_sticky_posts' => true, 1744 'no_found_rows' => true 1745 ) ); 1746 $reply_count = ! empty( $query->posts ) ? count( $query->posts ) : 0; 1747 unset( $query ); 1735 $reply_count = bbp_get_public_child_count( $forum_id, bbp_get_reply_post_type() ); 1748 1736 } 1749 1737 … … 1788 1776 ), 'update_forum' ); 1789 1777 1778 // Update the forum parent 1779 bbp_update_forum_id( $r['forum_id'], $r['post_parent'] ); 1780 1790 1781 // Last topic and reply ID's 1791 1782 bbp_update_forum_last_topic_id( $r['forum_id'], $r['last_topic_id'] ); … … 1821 1812 ) ); 1822 1813 } 1814 1815 // Bump the custom query cache 1816 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' ); 1823 1817 } 1824 1818 -
trunk/src/includes/replies/functions.php
r6826 r6848 99 99 if ( bbp_is_reply_published( $reply_id ) ) { 100 100 bbp_increase_topic_reply_count( $topic_id ); 101 bbp_increase_forum_reply_count( $ reply_id );101 bbp_increase_forum_reply_count( $forum_id ); 102 102 103 103 // If the reply isn't public only update the topic reply hidden count. … … 856 856 bbp_update_reply_walker( $reply_id, $last_active_time, $forum_id, $topic_id, false ); 857 857 } 858 859 // Bump the custom query cache 860 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' ); 858 861 } 859 862 … … 1002 1005 1003 1006 // Update the forum ID 1004 $ forum_id= bbp_update_forum_id( $reply_id, $forum_id );1007 $retval = bbp_update_forum_id( $reply_id, $forum_id ); 1005 1008 1006 1009 // Filter & return 1007 return (int) apply_filters( 'bbp_update_reply_forum_id', $ forum_id, $reply_id );1010 return (int) apply_filters( 'bbp_update_reply_forum_id', $retval, $reply_id, $forum_id ); 1008 1011 } 1009 1012 … … 1045 1048 1046 1049 // Update the topic ID 1047 $ topic_id= bbp_update_topic_id( $reply_id, $topic_id );1050 $retval = bbp_update_topic_id( $reply_id, $topic_id ); 1048 1051 1049 1052 // Filter & return 1050 return (int) apply_filters( 'bbp_update_reply_topic_id', $ topic_id, $reply_id );1053 return (int) apply_filters( 'bbp_update_reply_topic_id', $retval, $reply_id, $topic_id ); 1051 1054 } 1052 1055 -
trunk/src/includes/topics/functions.php
r6827 r6848 833 833 bbp_update_topic_walker( $topic_id, $last_active, $forum_id, 0, false ); 834 834 } 835 836 // Bump the custom query cache 837 wp_cache_set( 'last_changed', microtime(), 'bbpress_posts' ); 835 838 } 836 839 … … 888 891 if ( bbp_is_forum( $ancestor ) ) { 889 892 893 // Get the forum 894 $forum = bbp_get_forum( $ancestor ); 895 890 896 // Update the forum 891 897 bbp_update_forum( array( 892 'forum_id' => $ancestor, 898 'forum_id' => $forum->ID, 899 'post_parent' => $forum->post_parent, 893 900 'last_topic_id' => $topic_id, 894 901 'last_reply_id' => $reply_id, … … 984 991 985 992 // Get reply count. 986 $public_reply_count = count( bbp_get_public_child_ids( $topic_id, bbp_get_reply_post_type()) );993 $public_reply_count = bbp_get_public_child_count( $topic_id, bbp_get_reply_post_type() ); 987 994 988 995 // Topic status. -
trunk/tests/phpunit/testcases/admin/tools.php
r6585 r6848 642 642 ) ); 643 643 644 // Forums should NOT have a_bbp_forum_id meta key645 $this->assertEquals( array( ), get_post_meta( $f, '_bbp_forum_id', false ) );644 // Forums should have an empty _bbp_forum_id meta key 645 $this->assertEquals( array( 0 => '0' ), get_post_meta( $f, '_bbp_forum_id', false ) ); 646 646 647 647 // Topics should have a _bbp_forum_id meta key -
trunk/tests/phpunit/testcases/common/query.php
r5954 r6848 50 50 51 51 /** 52 * @group counts52 * @group jjj 53 53 * @covers ::bbp_get_public_child_count 54 54 */ 55 55 public function test_bbp_get_public_child_count() { 56 57 /* Empty Forum ********************************************************/ 58 56 59 $f = $this->factory->forum->create(); 57 60 58 // Test initial forum public child counts61 // Test initial zero forum public child counts 59 62 $count = bbp_get_public_child_count( $f, bbp_get_forum_post_type() ); 60 63 $this->assertSame( 0, $count ); … … 65 68 /* Sub-Forums *********************************************************/ 66 69 70 // 3 public sub-forums 67 71 $this->factory->forum->create_many( 3, array( 68 72 'post_parent' => $f, 69 73 ) ); 70 74 75 // 1 private sub-forum 71 76 $this->factory->forum->create( array( 72 77 'post_parent' => $f, -
trunk/tests/phpunit/testcases/forums/functions/counts.php
r6036 r6848 415 415 $f1 = $this->factory->forum->create(); 416 416 417 $count = bbp_get_forum_subforum_count( $f1, true ); 418 $this->assertSame( 0, $count ); 419 417 420 $f2 = $this->factory->forum->create_many( 3, array( 418 421 'post_parent' => $f1, … … 420 423 421 424 $count = bbp_get_forum_subforum_count( $f1, true ); 422 $this->assertSame( 0, $count ); 425 $this->assertSame( 3, $count ); 426 427 bbp_update_forum_subforum_count( $f1, 10 ); 428 429 $count = bbp_get_forum_subforum_count( $f1, true ); 430 $this->assertSame( 10, $count ); 423 431 424 432 bbp_update_forum_subforum_count( $f1 );
Note: See TracChangeset
for help on using the changeset viewer.