Search Everything & WP 3.7 update issues

I have been personally maintaining the Search Everything plugin for WordPress since the authors stopped. I upgraded one of my sites to wp 3.7 today but i get this error when i search:

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 '))) AND ncca_wp_posts.post_type IN ('post', 'page',
'attachment', 'archive', 'r'
at line 1]

Read More
SELECT DISTINCT SQL_CALC_FOUND_ROWS 
    ncca_wp_posts.* 
FROM ncca_wp_posts 
LEFT JOIN ncca_wp_term_relationships AS trel 
    ON ( ncca_wp_posts.ID = trel.object_id ) 
LEFT JOIN ncca_wp_term_taxonomy AS ttax 
    ON ( 
        ( ttax.taxonomy = 'category' 
            OR ttax.taxonomy = 'post_tag' 
            OR ttax.taxonomy = 'years' 
            OR ttax.taxonomy = 'archive-tags' 
            OR ttax.taxonomy = 'course'
        ) 
        AND trel.term_taxonomy_id = ttax.term_taxonomy_id
    ) 
LEFT JOIN ncca_wp_terms AS tter 
    ON (ttax.term_id = tter.term_id) 
LEFT JOIN ncca_wp_postmeta AS m 
    ON (ncca_wp_posts.ID = m.post_id) 
WHERE 1=1 
    AND ( 
        ( 
            ((())) 
            AND ncca_wp_posts.post_type IN ('post', 'page', 'attachment', 'archive', 'research-project') 
            AND (
                ncca_wp_posts.post_status = 'publish' 
                OR ncca_wp_posts.post_status = 'private'
            )
        ) 
        AND post_type != 'revision'
    )
    AND post_status != 'future' 
    ORDER BY ncca_wp_posts.post_title LIKE '% %' DESC, ncca_wp_posts.post_date DESC LIMIT 0, 24

Edit: Thank you kaiser. Taken on board for next time. I can see the error is being caused by an SQL syntax error, as stated above, but I cannot figure out how to fix it. Can anybody suggest how to alter this line of code to make it work correctly?

Related posts

1 comment

  1. Thanks to @Pat J i removed the syntax that was causing me problems. For those who are interested, inside the Search Everything plugin, on line 198 – 221 there is the following function:

        function se_search_default() {
    
        global $wpdb;
    
        $n = ( isset( $this->query_instance->query_vars['exact'] ) && $this->query_instance->query_vars['exact'] ) ? '' : '%';
        $search = '';
        $seperator = '';
        $terms = $this->se_get_search_terms();
    
        // if it's not a sentance add other terms
    
         //COMMENT OUT/REMOVE
        //$search .= '(';
        foreach ( $terms as $term ) {
            $search .= $seperator;
    
    
            $search .= sprintf( "((%s.post_title LIKE '%s%s%s') OR (%s.post_content LIKE '%s%s%s'))", $wpdb->posts, $n, $term, $n, $wpdb->posts, $n, $term, $n );
    
            $seperator = ' AND ';
        }
         //COMMENT OUT/REMOVE
        //$search .= ')';
        return $search;
    }
    

    If you are using the Search Everything plugin on WP 3.7, you will need to edit this function accordingly, or differently if you know better. ( I am merely a beginner ). Many thanks!!

Comments are closed.