Description
Describe the bug
The mechanism used by Distributor to assemble a list of internal connections (used on the 'Pull Content' dropdown and elsewhere) uses get_sites( [ 'number' => 1000 ] )
to pull a list of all sites on the network, then iterates through to see whether the current user has posting permissions on any of those sites. This strategy does not work well on the sorts of installations where there are thousands of sites, since any site beyond the initial 1000 will never appear in the list. (This came up in the context of a client site where the network has many thousands of sites, but the vast majority of users are members of only a few handful of them.)
By contrast, if one uses get_blogs_of_user()
or some other WP mechanism that only identifies the sites on which a user has a role, the list will contain all of a user's sites. (As a bonus, it performs far better.)
This change would mean, however, that a super admin would not see sites where the super admin does not have a role. This might not work well for some use cases of the plugin.
For the time being, I've effected the get_blogs_of_user()
change using the 'dt_pre_get_authorized_sites' filter. But I thought I'd open the ticket, because I suspect that the use case I described (large networks where users are members of many sites) is perhaps more common than the situation best served by the current strategy (a super admin who needs access to all sites). In any case, I would argue that a dropdown containing 1000 items is not particularly useful, and in the case where wp_is_large_network()
(or something similar) this interface ought to be an AJAX-powered type-ahead or something like that.
Thanks for the plugin :-D
Steps to Reproduce
- Have a large network
- Log in as a user who owns at least two sites. At least one of them (site A) should have ID > 1000
- Go to Site B > Dashboard > Distributor > Pull Content
- Site A will not be in the dropdown
Screenshots, screen recording, code snippet
No response
Environment information
No response
WordPress information
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
In Progress