[wp-trac] [WordPress Trac] #20835: Multisite subdirectory autocompletes are broken

WordPress Trac wp-trac at lists.automattic.com
Mon Jun 4 20:13:25 UTC 2012


#20835: Multisite subdirectory autocompletes are broken
--------------------------+------------------
 Reporter:  nacin         |       Owner:
     Type:  defect (bug)  |      Status:  new
 Priority:  high          |   Milestone:  3.4
Component:  Multisite     |     Version:
 Severity:  major         |  Resolution:
 Keywords:  has-patch     |
--------------------------+------------------

Old description:

> I have the following sites set up:
>
> * localhost/beta/ ("WordPress")
> * localhost/test/ ("Test")
> * localhost/testsite/ ("Test Site")
> * localhost/author-blog/ ("Author's Blog")
> * localhost/author-second-blog/ ("Author's Second Blog")
>
> == 1. Search term is not broken up based on domain and path ==
>
> You can search for the domain "localhost" or the path "author", but not
> "localhost/author". We need to be smart enough inside
> wp_ajax_autocomplete_site() to split based on domain and path and search
> both fields, at which point we need to do an AND rather than an OR.
>
> It should be noted that I am not sure if the wp-ms-sites list table
> performs this same check. It looks like it does not, and simply allows
> for searching domains for subdomain installs, and paths for subdirectory
> installs. So we may just need to strip off the domain for subdirectory
> searches (and vice versa with the path for subdomain searches). This, of
> course, is not very nice for installs with custom URLs that handle
> mapping via sunrise (with or without the domain mapping plugin).
>
> But it is important to at least stick to a subset of the logic in wp-ms-
> sites to ensure that results in one place are results in where you end
> up, rather than logic that can return sites in the autocomplete that
> would not show up in the search.
>
> == 2. The domain is autocompleted, rather than the path ==
>
> The return value in wp_ajax_autocomplete_site() is always the domain.
> This is not helpful for subdirectories. Typing in "author" and selecting
> /localhost/author-blog/ autocompletes to "localhost".
>
> == 3. Display of domains should use the same logic as sites.php ==
>
> On sites.php, we only show /beta/, /test/, /author-blog/, etc. Depending
> on whether we are on a subdirectory or a subdomain install, we trim off
> domains and paths where possible. (This is nicely compatible with mapped
> domain setups, as the code then doesn't trim off anything, and you see
> the full URL.) But in the autocomplete, we show /localhost/beta. If this
> autocompletes to /localhost/beta '''(see point 2)''', sites.php won't
> return anything. If it autocompletes to just /beta, then it is confusing.
>
> We should try to adhere to the searching and displaying logic of
> sites.php as much as possible. '''We should probably just wrap up the
> searching code into a method in the list table, then just use that method
> in wp_ajax_autocomplete_site().'''
>
> == 4. The name of the blog should not be shown ==
>
> In a user autocomplete, we show user_login and user_email. The only other
> field we search is user_nicename. But in site autocomplete, we only
> search domain and/or path, but we also show the site's blogname. This
> *could* be a nice feature, but it actually gets in the way, as A) they
> can't search for names, B) it shows names first, even though paths are
> the important, unique, identifiable part, C) sites.php doesn't even show
> names, D) it's unnecessary extra queries, and E) apostrophes are not
> properly converted ("Author's Blog").

New description:

 I have the following sites set up:

 * localhost/beta/ ("WordPress")
 * localhost/beta/test/ ("Test")
 * localhost/beta/testsite/ ("Test Site")
 * localhost/beta/author-blog/ ("Author's Blog")
 * localhost/beta/author-second-blog/ ("Author's Second Blog")

 == 1. Search term is not broken up based on domain and path ==

 You can search for the domain "localhost" or the path "author", but not
 "localhost/author". We need to be smart enough inside
 wp_ajax_autocomplete_site() to split based on domain and path and search
 both fields, at which point we need to do an AND rather than an OR.

 It should be noted that I am not sure if the wp-ms-sites list table
 performs this same check. It looks like it does not, and simply allows for
 searching domains for subdomain installs, and paths for subdirectory
 installs. So we may just need to strip off the domain for subdirectory
 searches (and vice versa with the path for subdomain searches). This, of
 course, is not very nice for installs with custom URLs that handle mapping
 via sunrise (with or without the domain mapping plugin).

 But it is important to at least stick to a subset of the logic in wp-ms-
 sites to ensure that results in one place are results in where you end up,
 rather than logic that can return sites in the autocomplete that would not
 show up in the search.

 == 2. The domain is autocompleted, rather than the path ==

 The return value in wp_ajax_autocomplete_site() is always the domain. This
 is not helpful for subdirectories. Typing in "author" and selecting
 /localhost/author-blog/ autocompletes to "localhost".

 == 3. Display of domains should use the same logic as sites.php ==

 On sites.php, we only show /beta/, /test/, /author-blog/, etc. Depending
 on whether we are on a subdirectory or a subdomain install, we trim off
 domains and paths where possible. (This is nicely compatible with mapped
 domain setups, as the code then doesn't trim off anything, and you see the
 full URL.) But in the autocomplete, we show /localhost/beta. If this
 autocompletes to /localhost/beta '''(see point 2)''', sites.php won't
 return anything. If it autocompletes to just /beta, then it is confusing.

 We should try to adhere to the searching and displaying logic of sites.php
 as much as possible. '''We should probably just wrap up the searching code
 into a method in the list table, then just use that method in
 wp_ajax_autocomplete_site().'''

 == 4. The name of the blog should not be shown ==

 In a user autocomplete, we show user_login and user_email. The only other
 field we search is user_nicename. But in site autocomplete, we only search
 domain and/or path, but we also show the site's blogname. This *could* be
 a nice feature, but it actually gets in the way, as A) they can't search
 for names, B) it shows names first, even though paths are the important,
 unique, identifiable part, C) sites.php doesn't even show names, D) it's
 unnecessary extra queries, and E) apostrophes are not properly converted
 ("Author's Blog").

--

Comment (by nacin):

 I messed up my example URLs above. My main install is not /localhost/, it
 is /localhost/beta/. The /beta/ is therefore $current_site->path,
 something that needs to be accounted for.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/20835#comment:4>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list