Opened 8 years ago
Closed 7 years ago
#37865 closed enhancement (fixed)
Allow using the `$network_id` parameter of `get_blog_count()` again
Reported by: | flixos90 | Owned by: | flixos90 |
---|---|---|---|
Milestone: | 4.8 | Priority: | normal |
Severity: | normal | Version: | 3.7 |
Component: | Networks and Sites | Keywords: | has-patch commit has-unit-tests |
Focuses: | multisite | Cc: |
Description
The $network_id
parameter of get_blog_count()
has not been used since 3.1, and was officially deprecated in 25113. When looking at the history, it appears that this was done to be able to fully rely on get_site_option()
which does not support passing a network ID.
However, now we have get_network_option()
which _does_ support a network ID, so I think we should un-deprecate this parameter and make use of it again (is that possible?).
Attachments (3)
Change History (10)
#2
@
8 years ago
- Keywords 2nd-opinion added
An alternative approach could be:
- introduce
get_network_site_count( $network = null )
(returns the value of the network optionblog_count
) - introduce
get_global_site_count()
(returns the sum ofget_network_site_count()
for all networks) - deprecate
get_blog_count()
and recommendget_network_site_count()
as replacement - replace Core usages of
get_blog_count()
with eitherget_network_site_count()
orget_global_site_count()
(depending on context)
Related to this ticket: #37866
#3
@
8 years ago
- Keywords 2nd-opinion removed
- Milestone changed from Awaiting Review to Future Release
Nice one. It's fun to see the history on the deprecation.
I think the approach in 37865.diff makes sense for the time being. Since we aren't actually adding any new functionality, we should stick with the same name (get_blog_count()
). In the future, if we think of something super interesting to do with a new version of the function, we may want to explore a get_site_count()
.
get_global_site_count()
could be interesting once we have a better idea of what global options look like.
This ticket was mentioned in Slack in #core-multisite by flixos90. View the logs.
8 years ago
#5
@
7 years ago
- Keywords commit added
- Milestone changed from Future Release to 4.8
- Owner set to flixos90
- Status changed from new to assigned
37865.2.diff adjusts the version number and the docblock to be more precise (see https://core.trac.wordpress.org/ticket/37866#comment:5 for a related comment).
#6
@
7 years ago
- Keywords has-unit-tests added
37865.3.diff adds a unit test for the new parameter. Another (rather unstable) unit test was adjusted in order to work with an additional network being registered in wpSetUpBeforeClass()
.
37865.diff makes use of the parameter again, by leveraging the power of
get_network_option()
. In the DocBlock, I also added notices for both the 3.7 change (previously missing) and the new change.