Opened 7 years ago
Closed 7 years ago
#42072 closed enhancement (fixed)
Add limit 1 to domain_exists
Reported by: | spacedmonkey | Owned by: | jeremyfelt |
---|---|---|---|
Milestone: | 4.9 | Priority: | normal |
Severity: | normal | Version: | 4.6 |
Component: | Networks and Sites | Keywords: | good-first-bug has-patch |
Focuses: | multisite | Cc: |
Description
domain_exists
uses to get_sites
to looks if site exists. But it only uses the first result. The param limit should be added to get_sites, limiting the query.
Attachments (4)
Change History (16)
#2
@
7 years ago
- Keywords has-patch added; needs-patch removed
Added a parameter to fetch only one results back by adding number
to arguments in 42072.diff
.
#3
@
7 years ago
We should consider simplifying the function further, by internally using the new get_site_by()
. See https://core.trac.wordpress.org/ticket/40180#comment:24
- The advantage would be less code to maintain.
- The disadvantage would be that
get_site_by()
returns a full object, while we only need an ID here. Not sure that's a real issue though, since it only queries for one result anyway, so it shouldn't have a significant impact on performance.
This ticket was mentioned in Slack in #core-multisite by jeremyfelt. View the logs.
7 years ago
#5
@
7 years ago
- Keywords needs-unit-tests removed
- Milestone changed from Awaiting Review to 4.9
I think we're okay to use get_site_by()
here. While a full object is returned, domain_exists()
is not widely used and because only one result is being returned, the performance difference is negligible. See 42072.2.diff. Tests exist for domain_exists()
and those continue to pass.
#6
@
7 years ago
42072.3.diff ensures we're passing an ID to the filter as expected.
#7
@
7 years ago
In 42072.4.diff:
- Ensure the URL passed to
get_site_by()
is formatted with expected slashes. - Remove the
www.wordpress.org
site from tests. Site creation was failing becausedomain_exists()
would returntrue
afterget_site_by( 'url', 'www.wordpress.org/' );
foundwordpress.org
. We don't support the co-existence ofwww
and non-www
domains, so it should be okay to apply this restriction todomain_exists()
now.
#9
@
7 years ago
I'm not feeling confident enough in domain_exists()
changing behavior and treating www/non-www the same. For 4.9, let's fix the bug by just adding the count of 1.
Adds number parameter to limit by 1