|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2010-08-20 05:14 UTC] boyd at textinfo dot nl
Description:
------------
SolrResponse::getReponse() and SolrUtils::digestXmlResponse() are unable to parse a valid Solr xml reponse with an empty (array) value.
<str/> is not accepted
<str></str> is not accepted
<str> </str> is accepted
@see example
Reproduce code:
---------------
<?php
$s = '<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="responseHeader">
<int name="status">0</int>
<int name="QTime">0</int>
<lst name="params">
<str name="fl">author, value</str>
<str name="indent">on</str>
<str name="start">0</str>
<str name="q">myQuery</str>
<str name="wt">xml</str>
<str name="rows">10</str>
<str name="version">2.2</str>
</lst>
</lst>
<result name="response" numFound="1" start="0">
<doc>
<str name="author">Me</str>
<arr name="value">
<str>Some text</str>
<str/>
</arr>
</doc>
</result>
</response>';
$o = \SolrUtils::digestXmlResponse( $s, \SolrResponse::PARSE_SOLR_OBJ );
print_r( $o ); die;
?>
Expected result:
----------------
SolrObject Object
(
[responseHeader] => SolrObject Object
(
[status] => 0
[QTime] => 0
[params] => SolrObject Object
(
[fl] => author, value
[indent] => on
[start] => 0
[q] => myQuery
[wt] => xml
[rows] => 10
[version] => 2.2
)
)
[response] => SolrObject Object
(
[numFound] => 1
[start] => 0
[docs] => Array
(
[0] => SolrObject Object
(
[author] => Me
[value] => Array
(
[0] => Some text
[1] =>
)
)
)
)
)
Actual result:
--------------
500 internal server error
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 05:00:01 2025 UTC |
Q&D workaround : try { $response_array = $response->getResponse(); } catch(SolrException $e) { $raw_response = $response->getRawResponse(); $raw_response = str_replace('<doc></doc>', '', $raw_response); $response_array = SolrUtils::digestXmlResponse($raw_response, SolrResponse::PARSE_SOLR_DOC); } also note that this bug isn't windows specific