Opened 7 years ago
Last modified 3 years ago
#40736 new defect (bug)
Ensure that `get_blog_count()` and `get_user_count()` return an integer
Reported by: | flixos90 | Owned by: | |
---|---|---|---|
Milestone: | Future Release | Priority: | normal |
Severity: | normal | Version: | |
Component: | Networks and Sites | Keywords: | 2nd-opinion |
Focuses: | multisite | Cc: |
Description
The documentation for the functions get_blog_count()
and get_user_count()
states that the return type is an integer, however the functions only call get_network_option()
without any typecast.
The functions should be adjusted to actually reflect their documentation. While this might theoretically be problematic in terms of backward-compatibility, in #40724 some initial thoughts of this being a viable change were expressed, so let's think about it on this ticket.
Attachments (11)
Change History (21)
#2
follow-up:
↓ 3
@
7 years ago
Since we're striving towards an API with site/network terminology in favor of blog/site long-term, we should consider deprecating get_blog_count()
in favor of a get_site_count()
. The change of the return type, whether it was specified in the docs or not, is a breaking change anyway, so I suggest to deprecate the function at the same time and replace their usage in core with calls to get_site_count()
.
#3
in reply to:
↑ 2
@
7 years ago
I have done all chanmges. I am not able to login with my current internetc connection. It gives me erroe like:
Your IP (103.217.85.2) has been flagged for potential security violations. Find out more...
I am trying to upload patch by proxy, but it changesname. I will try to give patch again tommorow morning again
Replying to flixos90:
Since we're striving towards an API with site/network terminology in favor of blog/site long-term, we should consider deprecating
get_blog_count()
in favor of aget_site_count()
. The change of the return type, whether it was specified in the docs or not, is a breaking change anyway, so I suggest to deprecate the function at the same time and replace their usage in core with calls toget_site_count()
.
@
7 years ago
Deprecated get_blog_count() function and developed get_site_count function. This is final.
This ticket was mentioned in Slack in #core by pmbaldha. View the logs.
7 years ago
#5
@
7 years ago
Thanks for the patch @pmbaldha!
Looks good except for a few minor issues:
- Let's cast the values to integers with
(int)
instead of using the oldintval()
. - For version numbers, the
4.8
and4.8.0
should be replaced with4.9.0
, as this change won't make it into 4.8. MU
should not be used in the@since
annotation for new functions.- The function
get_blog_count()
should be moved to thems-deprecated.php
file.
@
7 years ago
int typecating for get_user_count(). Deprecated get_blog_count() function.Developed get_site_count() function.
@
7 years ago
int typecating for get_user_count(). Deprecated get_blog_count() function.Developed get_site_count() function. All changes done.
@
7 years ago
int typecating for get_user_count(). Deprecated get_blog_count() function.Developed get_site_count() function.Final patch
#7
@
7 years ago
Highlighting https://core.trac.wordpress.org/ticket/40736#comment:2 again: Is it reasonable to change the name from get_blog_count()
to the more appropriate get_site_count()
? In my opinion it's fine since we're practically breaking back-compatibility anyway, so we might as well deprecate the function in favor of the new one (and of course also adjust its old calls in core).
#8
@
7 years ago
wp_update_network_site_counts() function is used or called by internal wordpress code. Generally, Normal Wordpress developer doesn't know about wp_update_network_site_counts() function. He/she are are familiar wth get_blog_count() function. There is no worth to change get_site_count() to get_network_site_count().
This is my personal opinion.
If community like get_network_site_count() (would also need a get_network_user_count()) function name, Please tell me. I will create new patch.
May i know what is opinion of other contributors?
Type cast return values as integers.