WordPress.org

Ready to get started?Download WordPress

Forums

Solr for WordPress
Draft posts are in the index (1 post)

  1. sqroot
    Member
    Posted 1 year ago #

    This function seems faulty:

    function s4w_handle_modified( $post_id ) {
        global $current_blog;
        $post_info = get_post( $post_id );
        $plugin_s4w_settings = s4w_get_option();
        $index_pages = $plugin_s4w_settings['s4w_index_pages'];
        $index_posts = $plugin_s4w_settings['s4w_index_posts'];
    
    	s4w_handle_status_change( $post_id, $post_info );
    
        if (($index_pages && $post_info->post_type == 'page') || ($index_posts && $post_info->post_type == 'post')) {
    
            # make sure this blog is not private or a spam if indexing on a multisite install
            if (is_multisite() && ($current_blog->public != 1 || $current_blog->spam == 1 || $current_blog->archived == 1)) {
                return;
            }
    
            $docs = array();
            $doc = s4w_build_document( $post_info );
            if ( $doc ) {
                $docs[] = $doc;
                s4w_post( $docs );
            }
        }
    }

    It calls s4w_handle_status_change, which correctly deletes a post that has changed to Draft status, but it then always adds those documents back the index. The result is that draft posts are searchable.

    I fixed this by adding this code before $docs = array() :

    if ($post_info->post_status != 'publish') {
                return;
            }

    Hopefully if the author agrees, this will be included in the next update.

    http://wordpress.org/extend/plugins/solr-for-wordpress/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags