For some reason the default behavior in the PHP library is to collapse arrays in the response with one value into a scalar. This seems wrong to me - if you know something is a multi-value you'd always want an array to iterate over even if a document just has one value for that field. I'm surprised we have not seen more problems - but I guess we are usually requesting single-value items in the response (e.g. uid, nid, path, etc).

I suggest we alter the factory function (or the overriding class?) to make this not collapse by default.

CommentFileSizeAuthor
#1 do-not-collapse-668662-1.patch1.05 KBpwolanin

Comments

pwolanin’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB
jpmckinney’s picture

Seems reasonable to me. Anyone expecting the field to collapse to a value (the old behaviour) must also be expecting the field to occasionally be an array. Fixed in 2.x http://drupal.org/cvs?commit=359244

pwolanin’s picture

Status: Needs review » Fixed

Did you commit to all branches?

jpmckinney’s picture

Status: Fixed » Patch (to be ported)
pwolanin’s picture

looks like this no longer applies to 1.x - apparently the branches are out of sync in that function?

jpmckinney’s picture

Yes, looking into it. #554690: Better exception handling strategy may be related.

jpmckinney’s picture

Here's the commit that introduced the try-catch. http://drupalcode.org/viewvc/drupal/contributions/modules/apachesolr/apa...

Commit message for 2.x was "#3361182 fix path, additional API cleanup". Issue number is actually #336118: overhaul of APIs, fix Luke. I see no mention of adding a try-catch in that issue, but that is nonetheless the issue to which the commit refers.

The commit that removed the try-catch in 1.x comes out of #742998: calling deleteByQuery causes error: "Call to a member function deleteByQuery() on a non-object".

jpmckinney’s picture

Version: 6.x-1.x-dev » 5.x-2.x-dev
jpmckinney’s picture

Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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