solr-power icon indicating copy to clipboard operation
solr-power copied to clipboard

Media Library search not working

Open bamadesigner opened this issue 3 years ago • 6 comments

Hi! When the Solr plugin is activated on our site, the Media Library search does not work in the "Grid" view. It does work for list view. This site is on a multisite network.

I don't have any more info at this time. I will be doing some digging on my end and will report back.

But am wondering if you are aware of this issue or have seen it on other environments.

Thanks!

bamadesigner avatar Jun 28 '22 20:06 bamadesigner

On the "grid" view for the Media Library in the admin (/wp-admin/upload.php?search=test), it is performating a JavaScript AJAX request to run the search.

The request goes to /wp-admin/admin-ajax.php. Here is the payload for a search of "test":

action: query-attachments post_id: 0 query[orderby]: date query[s]: test query[order]: DESC query[posts_per_page]: 80 query[paged]: 1

bamadesigner avatar Jun 28 '22 20:06 bamadesigner

The AJAX function being run is wp_ajax_query_attachments() which you can find here: https://github.com/WordPress/WordPress/blob/master/wp-admin/includes/ajax-actions.php#L2951

bamadesigner avatar Jun 28 '22 20:06 bamadesigner

When I dig into the WP Query, here are the vars:

s: test
orderby: date
order: DESC
posts_per_page: 80
paged: 1
post_type: attachment
post_status: inherit,private

bamadesigner avatar Jun 28 '22 20:06 bamadesigner

If I comment out the following filter, the search works. So I'm digging into this function.

https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-wp-query.php#L132

bamadesigner avatar Jun 28 '22 20:06 bamadesigner

Here is all the info being passed to $search = SolrPower_Api::get_instance()->query( $qry, $offset, $count, $fq, $sortby, $order, $fields, $extra ); at https://github.com/pantheon-systems/solr-power/blob/master/includes/class-solrpower-wp-query.php#L226

$qry: test AND(post_type:attachment)AND(post_status:inherit,private) $offset: 0 $count: 80 $fq: empty array $sortby: post_date $order: desc $fields: empty $extra: empty array

bamadesigner avatar Jun 29 '22 12:06 bamadesigner

I couldn't figure out the issue so for now I'm disabling Solr on the 'query-attachments' AJAX request.

bamadesigner avatar Jun 30 '22 01:06 bamadesigner