Changeset 6114
- Timestamp:
- 11/02/2016 10:24:30 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/includes/users/functions.php
r6111 r6114 1817 1817 $where = get_posts_by_author_sql( bbp_get_topic_post_type(), true, $user_id ); 1818 1818 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) FROM {$bbp_db->posts} {$where}" ); 1819 // Manually add the user closed topic count, see #2978 and #WP12706 1820 $count = $count + bbp_get_user_closed_topic_count( $user_id ); 1819 1821 1820 1822 return (int) apply_filters( 'bbp_get_user_topic_count_raw', $count, $user_id ); … … 1846 1848 1847 1849 return (int) apply_filters( 'bbp_get_user_reply_count_raw', $count, $user_id ); 1850 } 1851 1852 /** 1853 * Return the raw database count of closed topics by a user 1854 * 1855 * @since 2.6.0 bbPress (r6113) 1856 * 1857 * @param int $user_id User ID to get count for 1858 * 1859 * @return int Raw DB count of user closed topics 1860 */ 1861 function bbp_get_user_closed_topic_count( $user_id = 0 ) { 1862 $user_id = bbp_get_user_id( $user_id ); 1863 if ( empty( $user_id ) ) { 1864 return false; 1865 } 1866 1867 $bbp_db = bbp_db(); 1868 $count = (int) $bbp_db->get_var( "SELECT COUNT(*) 1869 FROM {$bbp_db->posts} 1870 WHERE post_type = '" . bbp_get_topic_post_type() . "' 1871 AND post_status = '" . bbp_get_closed_status_id() . "' 1872 AND post_author = $user_id;" 1873 ); 1874 1875 return (int) apply_filters( 'bbp_get_user_closed_topic_count', $count, $user_id ); 1848 1876 } 1849 1877 -
trunk/tests/phpunit/testcases/users/functions/counts.php
r5919 r6114 183 183 $count = bbp_get_user_topic_count_raw( $u ); 184 184 $this->assertSame( 6, $count ); 185 186 $t = $this->factory->topic->create( array( 187 'post_author' => $u, 188 ) ); 189 190 bbp_close_topic( $t ); 191 192 $count = bbp_get_user_topic_count_raw( $u ); 193 $this->assertSame( 7, $count ); 185 194 } 186 195
Note: See TracChangeset
for help on using the changeset viewer.