Closed (fixed)
Project:
Apache Solr Search
Version:
7.x-1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
30 Mar 2013 at 17:15 UTC
Updated:
4 Mar 2021 at 19:19 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Routh commentedAdditional information:
This error appears in the dblog at the moment of the index break -
Recoverable fatal error: Argument 2 passed to apachesolr_index_send_to_solr() must be of the type array, null given, called in /home/aw_dev/public_html/sites/all/modules/apachesolr/apachesolr.index.inc on line 47 and defined in apachesolr_index_send_to_solr() (line 303 of /home/aw_dev/public_html/sites/all/modules/apachesolr/apachesolr.index.inc).
Comment #2
istankevych commentedHello, Routh
I have same problem.
How did you fix it?
Comment #3
cimo75 commentedHi
you can try to run this module
https://drupal.org/project/delete_orphaned_terms
Comment #4
DrCord commentedI don't want to delete terms with no entries, those are still valid. Any other fixes or is this module broken? If you cannot index with it, then what good is it?
Comment #5
rudolfbykerSame problem.
Drupal 7.34
apachesolr 7.x-1.7+2-dev
apachesolr_term 7.x-1.x-dev
Here are the error messages (sorry for the combination of Franch and English; this is from a half-translated dev site):
Warning : array_merge(): Argument #2 is not an array dans apachesolr_index_entities_document() (ligne 127 dans .../apachesolr/apachesolr.index.inc).Warning : array_merge(): Argument #2 is not an array dans apachesolr_index_entities() (ligne 64 dans .../apachesolr/apachesolr.index.inc).Notice : Undefined property: stdClass::$language dans apachesolr_multilingual_fields_default_indexing_callback_implementation() (ligne 20 dans .../apachesolr_multilingual/apachesolr_multilingual.index.inc).Warning : array_merge(): Argument #1 is not an array dans apachesolr_index_entities() (ligne 64 dans .../apachesolr/apachesolr.index.inc).Recoverable fatal error : Argument 2 passed to apachesolr_index_send_to_solr() must be an array, null given, called in .../apachesolr/apachesolr.index.inc on line 67 and defined dans apachesolr_index_send_to_solr() (ligne 340 dans .../apachesolr/apachesolr.index.inc).There are TODO messages about this in apachesolr.index.inc:
In
apachesolr_index_entities(lines 60 through 67):In
apachesolr_index_entities_document(lines 125 through 128)In
apachesolr_index_entity_to_documents, lines 239 through 242, false is returned for empty entities:So two things need to happen:
So in
apachesolr_index_entities_document:apachesolr_index_entity_to_documents.Comment #6
rudolfbykerComment #7
stone_d commentedSame here:
Any suggestions?
Comment #8
aghawkins commentedAny word on this?
Comment #9
rudolfbykerThe fix that I proposed above only supresses half of the errors... On line 20 in apachesolr_multilingual.index.inc, it is assumed that the $entity stdClass will have a language property. However, taxonomy terms do not have that property. We could change line 20 to:
if (isset($entity->language) && ... && ... ) {I'm not sure what this will do, but it does get rid of the errors. Marking this as active, because somebody that knows the apachesolr code better should propose a proper fix. Unfortunately I don't have time to study the ins and outs of apachesolr_term and apachesolr_multilingual modules.
Comment #10
botrisYou can't pass
array_mergea null value, but you can pass an empty array.So you can change the code from:
to
This solves the problem for me.
Comment #11
botrisNo still not working with taxonomy terms. Although #5 also doesn't work with taxonomy (at least for me) it's the better way to go.
Comment #12
AndyThornton commentedas fmr says in #5, it seems like a fix will involve handling the return of false from apachesolr_index_entity_to_documents. worryingly, in that function if false is returned the restoring of the user from anonymous and the saving of the session doesnt happen ... that doesnt smell right ... although, that is a different bug, i guess.
i have a very good way of reproducing this error, if anyone finds it useful. i am using apachesolr_term and termstatus (to provide a published/unpublished option for terms). if you unpublish a term and then index your content it will break (becasue apachesolr_term doesnt know about the unpublished flag introduced by termstatus).
Comment #13
nebel54I packed the changes from #5 into this patch and added some logging to find out which entities cause the null value.
Comment #14
nikus85 commentedVersion 1.10, the problem persists.
I have an additional module which denies access to particular taxonomy terms from viewing by anonymous user. This one is called 'Taxonomy Term Status' (termstatus) which allows a term not to be published while its content (nodes attached) is being maintained by editors. As shown in #5, function apachesolr_index_entity_to_documents occasionally returns FALSE in such a case, while it should return an empty array: array(), thus not breaking array_merge and other caller's code.
After publishing of the hidden term, it is re-indexed on the next cron rum (within a minute), so its content os available to the public as by a link provided, so by a searching for keywords. If the term is unpublished again, it is also re-indexed and empty array() make the search to return no results to the term as designed.
This can happen with any other module or custom code which denies access to any taxonomy term from the public.
So bugfix is simple: just replace FALSE with array() in apachesolr_index_entity_to_documents.
Comment #15
Sara.Ali commentedCreated a patch for the suggestion in #14. It fixes the issue for me when using version 1.10.
Comment #16
Sara.Ali commentedCreated a patch for the suggestion in #14. It fixes the issue for me when using version 1.10.
https://www.drupal.org/files/issues/2018-07-25/argument_is_not_an_array-...
Comment #17
hitfactory commentedConfirming the patch in #15 resolves the issue. Thanks @Sara.Ali.
Attaching re-roll of #15 patch so it applies to latest version.
Comment #18
rudolfbykerIn response to #12 @AndyThornton: See https://www.drupal.org/project/apachesolr/issues/2333213
Comment #19
rudolfbykerIMHO these two issues ( https://www.drupal.org/project/apachesolr/issues/2333213 and https://www.drupal.org/project/apachesolr/issues/1957072 ) cannot be separated, since the patch in #17, although it solves the problem in some circumstances, still leaves an annoying bug where admin users get logged out when trying to index content manually.
Here is a patch that solves this issue WITHOUT logging out the user. :)
Comment #20
rudolfbykerOops, ignore my previous patch. Use this one. I had the ternary operator swapped around.
Comment #21
rudolfbykerApparently PHPLint doesn't like new-style arrays
[](a shame, in my opinion), so here is a patch with old-style arraysarray().Comment #22
rudolfbykerI've been using the last patch for over 2 years on three different production sites, without problem. I think that's enough review :)
Comment #24
japerry