Automattic / Automattic/co-authors-plus
Ajax suggest metabox shows 0 results frequent
- Dominant language
- PHP
- Stars
- 322
- Forks
- 218
- Avg merge
- 7h 50m
- Merged PRs (30d)
- 65
Description
In search_authors() function:
```
$args = array(
'search' => $search,
'get' => 'all',
'number' => 10,
);
$args = apply_filters( 'coauthors_search_authors_get_terms_args', $args );
add_filter( 'terms_clauses', array( $this, 'filter_terms_clauses' ) );
$found_terms = get_terms( $this->coauthor_taxonomy, $args );
remove_filter( 'terms_clauses', array( $this, 'filter_terms_clauses' ) );
if ( empty( $found_terms ) )
return array();
// Get the co-author objects
$found_users = array();
foreach( $found_terms as $found_term ) {
$found_user = $this->get_coauthor_by( 'user_nicename', $found_term->slug );
if ( !empty( $found_user ) )
$found_users[$found_user->user_login] = $found_user;
}
```
This searches for only 10 terms. The array is then filtered using get_coauthor_by function. Sometimes this leaves the resultset to be empty, when it shouldn't be (because we only looked for 10 terms in the first place).
We should increase the 'number' to more sensible value, or find a better way (using SQL?) to get coauthors from the terms. Another solution would be to loop it until we have atleast X number of results.
Contributor guide
Research direction
Start in search_authors() and trace the get_terms() call, its number argument, and the subsequent get_coauthor_by() filtering. Reproduce an Ajax suggest search where the first 10 terms produce no valid coauthors, then compare a larger or repeated lookup approach. Done means valid coauthors are returned consistently instead of an empty result when matching terms exist.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100