Support » Plugin: Solr for WordPress » [Plugin: Solr for WordPress] Load All Posts not indexing

  • Hi there,

    First of all, many thanks to Matt Weber for contributing such a great plugin to the community.

    I have set up a fresh installation of WP 3.3.1, created a network of three subsites, installed the 0.5.1 version of the S4W plugin and inserted some posts. I configured the S4W plugin correctly and it is connected with my local Solr environment.

    Then I run a search query and nothing is found. So then I head over to the S4W configuration page and click on the ‘Load all Pages’ and ‘Load all Posts’ buttons. Still nothing found. Then I pick one of my posts, edit and save it and rerun the query. Then the post if found!

    Newly added posts are found instantly (without first having to edit and then save the post).

    Is there anything I possibly do wrong? Is this behaviour by design or is it a known bug?

    Thanks in advance for your reply.

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


    I have done some research that I’d like to share with you. It is possible that my conclusions are incorrect; that’s probably because I’m still a bit of WP newbee.

    First of all, I had already discovered that there was something funny with the ‘Load All Posts’ option on the settings page. So I started doing some research on that one.
    The moment you hit the ‘Load All Posts’ (Execute) button, a form gets posted. The form posts to the URL options-general.php?page=solr-for-wordpress/solr-for-wordpress.php. The S4W module has implemented a hook called ‘admin_init’ that runs the s4w_options_init() function when entering the adminpage. So I looked in the aforementioned function.
    This function holds the following code (among other code):

    $method = $_POST['method'];
        if ($method === "load") {
            $type = $_POST['type'];
            $prev = $_POST['prev'];
            if ($type === 'post' ) {
            } else if ($type === 'page') {
            } else {

    The strange thing is, that the POST values ‘method’, ‘type’ and ‘prev’ don’t exist in the POST value. Some of this logic relies on the name of the submit button being sent through the POST value. But because the name attribute of the submit button contains an underscore, this value doesn’t exist in the POST value. So I have re-arranged this HTML form and PHP code a bit.

    Then I went to the s4w_load_all_posts() function. I’m working on a multisite installation. So this function first collects a list of all blogs ID’s and then loops this list. In this loops it collects a list of blog posts. This query generates an error.
    It constructs the following query:

    $postids = $wpdb->get_results("SELECT ID FROM {$wpdb->base_prefix}{$bloginfo}_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY ID;");

    Queries like the following are being fired:

    SELECT ID FROM wp_2_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY ID;

    That seems okay. But it runs the following query for blog number ONE:

    SELECT ID FROM wp_1_posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY ID;

    While table ‘wp_1_posts’ doesn’t exist. The first blog has no such table names. So I have rewritten the creation of this query a bit.

    Like I said, it’s possible that I’m making wrong assumptions and conclusions or maybe these are in fact bugs. In both cases I’d like to hear from you.

    Thread Starter ribakker


    I’ve just found out why the ‘Execute’ button was not working. There was a JavaScript error on this page. Shoot, I should have noticed this a while earlier… In solr-for-wordpress.php starting at line 1266 there is this pieca code:

    $j('[name=s4w_postload]').click(function() {
                doLoad("post", null);

    The preventDefault() call somehow doesn’t work. So I have temporarily replaced this with ‘return false;’. This works! So now the indexing is triggered correctly.

    All this, including what was discussed in my previous posts, counts for the indexing of pages aswell.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Solr for WordPress] Load All Posts not indexing’ is closed to new replies.