I noticed this code in the apachesolar.module file:

        // Chunk the adds by 20s
        $docs_chunk = array_chunk($documents, 20);
        foreach ($docs_chunk as $docs) {
          $solr->addDocuments($docs);
        }
        $solr->addDocuments($documents);

I think this adds all the documents twice as $documents does not get truncated after a call to array_chunk. At least, when I add a call to count the items in $documents it has the same number it did before. The description here (http://us.php.net/array_chunk) makes it seem like the last element should have up to the chunk size for arrays that have remainders.

CommentFileSizeAuthor
#4 apachesolr.module.patch375 byteshurleyit

Comments

pwolanin’s picture

possibly this is fixed in 5.x-dev? If not, hopefully Robert will get it. Looks fixed in 6.x:

      $docs_chunk = array_chunk($documents, 20);
      foreach ($docs_chunk as $docs) {
        $solr->addDocuments($docs);
      }
hurleyit’s picture

I just looked at the latest development snapshot and it seems to still be there. PHP is not my strength, I mostly program in Perl, but I am learning. This is definitely a problem though? I can try to create a patch if it is.

pwolanin’s picture

Yes, seems like a problem indeed

hurleyit’s picture

Status: Active » Needs review
StatusFileSize
new375 bytes

I think I did the patch correctly. Please let me know if there are any issues as this is my first patch.

pwolanin’s picture

Status: Needs review » Fixed

looks fine - committed to the 5.x branch. Thanks.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.