Opened 15 years ago
Closed 14 years ago
#12531 closed enhancement (duplicate)
Improve get_blog_count(), get_user_count() and get_sitestats()
Reported by: | ocean90 | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Multisite | Keywords: | has-patch |
Focuses: | Cc: |
Description
We can use *_site_transients().
More information in get_blog_count() and get_user_count()
(I use/need this information for #12460)
I also remove get_sitestats() because we have the two other functions.
Attachments (9)
Change History (25)
#1
@
15 years ago
- Summary changed from Improve get_sitestats() and get_user_count() to Improve get_blog_count() and get_user_count(), remove get_sitestats()
#3
follow-up:
↓ 4
@
15 years ago
We can't change the return type of get_user_count() or get_blog_count(), and get_sitestats() must still be functional. Those are all used in MU and back compat must be maintained. All of those would have to be deprecated and replaced with new functions. Also, see count_users().
#4
in reply to:
↑ 3
@
15 years ago
Ok, I declare get_blog_count(), get_user_count(), get_sitestats() as deprecated functions and create ms_count_blogs() and ms_count_users() (like wp_count_comments).
#5
@
15 years ago
Also: No need to pass hard-coded queries through prepare() before querying them, That should only be done if placeholders are used within the query (ie. %d and %s); - Not sure why the original function is doing that.
#6
@
15 years ago
Doing that may counts will kill performance on sites with lots of blogs and users. Is this for showing counts for the status filters on the ms-sites and users pages? I suggest leaving the counts off. Counting will make those pages unusably slow.
#8
@
15 years ago
ryan: Yep, it should be for that.
I reduce the queries to one and create 1,100 sites and make some tests and the counting doesn't make the site really 'unusably slow'. The results are also saved in the site transient.
So, I upload the new patch.
#9
@
15 years ago
If it were me, I would put the counting of site/user statuses in a plugin and use hooks to update the counts.
#12
@
15 years ago
- Summary changed from Improve get_blog_count() and get_user_count(), remove get_sitestats() to Improve get_blog_count(), get_user_count() and get_sitestats()
Ok, but we should improve the existing function for 3.0. See patch.
#13
@
15 years ago
- Milestone changed from 3.1 to 3.0
Moving back to 3.0 so we can update this to use the transients API.
We'll want to keep the timeout though.
#14
@
15 years ago
12531.6.patch is a new version with *_site_transients().
Replying to nacin:
We'll want to keep the timeout though.
I don't think that we need the timeout anymore, because we shouldn't need a new count, if nothing is changed.
Unless get_sitestats() was introduced in WP 3.0, you should move it to deprecated.php instead of removing it completely.