Support » Plugin: Advanced Search by My Solr Server » Trash Items Still In Solr Index

  • I’m testing this plugin on my existing site. It is indexing my content to the Solr Index. When I create a new post or edit the post those changes are reflected in the index. However, when I move the post to trash, the item still appears in my search results. Is it possible to prevent this from happening and remove this index entry if it’s been marked for trash?

    When I empty the trash, then it’s removed from the index.

    http://wordpress.org/plugins/advanced-search-by-my-solr-server/

Viewing 1 replies (of 1 total)
  • I had the same problem and after some digging I found out why this was happening.

    First of the plugin doesn’t have a hook for “transition_post_status”.

    And secondly the hook on “save_post” doesn’t contain a check for the trashed, private or protected status (only for draft and auto-draft) causing trashed, private and protected items to be put (back) in the index when saved.

    To solve this problem you can either overwrite the hooks in your own functions.php or change the following lines in the advanced-search-by-my-solr-server.php file from the plugin

    Line 598
    if ($post_info->post_status=='auto-draft' || $post_info->post_status=='draft') return;
    To
    if ($post_info->post_status=='auto-draft' || $post_info->post_status=='draft' || $post_info->post_status=='private' || $post_info->post_status=='protected' || $post_info->post_status=='trash' ) return;

    Line 638
    if ( ($_POST['prev_status'] == 'publish' || $_POST['original_post_status'] == 'publish') && ($post_info->post_status == 'draft' || $post_info->post_status == 'private') ) {
    To
    if ( ($_POST['prev_status'] == 'publish' || $_POST['original_post_status'] == 'publish') && ($post_info->post_status=='draft' || $post_info->post_status=='private' || $post_info->post_status=='protected' || $post_info->post_status=='trash' ) ) {

    And add this line to the bottom of the file
    add_action( 'transition_post_status', 'mss_handle_status_change');

    If you don’t want to change the plugin files you can also ‘overwrite’ the hooks for “transition_post_status” and “save_post” by copying the original functions
    You will need to add require_once(ABSPATH."wp-content/plugins/advanced-search-by-my-solr-server/advanced-search-by-my-solr-server.php"); in your function to make sure you can use the plugin functions.

Viewing 1 replies (of 1 total)
  • The topic ‘Trash Items Still In Solr Index’ is closed to new replies.