[wp-trac] [WordPress Trac] #34450: get_id_from_blogname returns false if the main domain starts with www.
WordPress Trac
noreply at wordpress.org
Thu Sep 15 22:52:35 UTC 2016
#34450: get_id_from_blogname returns false if the main domain starts with www.
--------------------------------------------------+------------------------
Reporter: igmoweb | Owner: flixos90
Type: defect (bug) | Status: assigned
Priority: normal | Milestone: 4.7
Component: Networks and Sites | Version: 4.3.1
Severity: normal | Resolution:
Keywords: has-patch has-unit-tests 2nd-opinion | Focuses: multisite
--------------------------------------------------+------------------------
Changes (by flixos90):
* keywords: needs-unit-tests has-patch needs-refresh => has-patch has-
unit-tests 2nd-opinion
Comment:
[attachment:34450.patch] is an updated patch that makes use of
`WP_Site_Query` (via `get_sites()`) in the function. This also allows us
to get rid of the `get_id_from_blogname_*` cache key, since site query
results are cached anyway. An additional benefit we get is that the
function now actually returns an integer, as stated in the docs (before
the return value would actually be a string, due to `wpdb::get_var()`).
The patch also adds unit tests, one for a www-prefixed network, another
one without www.
One thing that we should probably improve (but I didn't yet because I
wasn't sure): What do we do if the function fails to find an ID?
Previously it would have returned null (see `wpdb::get_var()`), although
this is undocumented. My proposal would be to check if the array returned
by `get_sites()` is empty, and if so return null. And of course we would
then document it as well.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34450#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list