• This code works fine:

    function myfunc_relevanssi_do_not_index($index, $post_id) {
    	return false;
    }
    add_filter('relevanssi_do_not_index', 'myfunc_relevanssi_do_not_index', 10, 2);

    This code:

    function myfunc_relevanssi_do_not_index($index, $post_id) {
    	return true;
    }
    add_filter('relevanssi_do_not_index', 'myfunc_relevanssi_do_not_index', 10, 2);

    Produces this:

    WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ” at line 1 for query DELETE FROM wp_relevanssi WHERE doc= made by media_handle_upload, wp_insert_attachment, wp_insert_post, do_action(‘add_attachment’), call_user_func_array, relevanssi_publish, relevanssi_index_doc, relevanssi_remove_doc

    https://www.ads-software.com/plugins/relevanssi/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Matt

    (@syntax53)

    I think I identified the problem. In ‘relevanssi_index_doc’ you have the following:

    if (true == apply_filters('relevanssi_do_not_index', false, $post->ID)) {
    	// filter says no
    	if ($post_was_null) $post = null;
    	if ($previous_post) $post = $previous_post;
    	$index_this_post = false;
    }
    
    if ($remove_first) {
    	// we are updating a post, so remove the old stuff first
    	relevanssi_remove_doc($post->ID, true);
    	if (function_exists('relevanssi_remove_item')) {
    		relevanssi_remove_item($post->ID, 'post');
    	}
    }

    Since I’m dealing with an attachment here, and I’m uploading the attachment via the media library section on the dashboard (not from a post or page), the global $post would be null and therefor gets set back to null with “if ($post_was_null) $post = null;”.

    Then during second part you aren’t checking the status of $post. Nor do you do so within the relevanssi_remove_doc function. So $post->ID gets passed through as null.

    I modified the code to this for now on my end–

    if ($remove_first && !empty($post->ID)) {
    	// we are updating a post, so remove the old stuff first
    	relevanssi_remove_doc($post->ID, true);
    	if (function_exists('relevanssi_remove_item')) {
    		relevanssi_remove_item($post->ID, 'post');
    	}
    }
    Plugin Author Mikko Saari

    (@msaari)

    Thanks… I’ll have to investigate this. It may be that the setting $post to null should actually be done after removing the post. I’ll have to see, thanks anyway for bringing this up.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Problem with relevanssi_do_not_index filter’ is closed to new replies.