php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #59511 Unable to catch SolrClient::query
Submitted: 2010-11-15 18:23 UTC Modified: 2014-02-14 01:52 UTC
Votes:4
Avg. Score:4.5 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:2 (66.7%)
Same OS:2 (66.7%)
From: eric dot caron at gmail dot com Assigned: omars (profile)
Status: Closed Package: solr (PECL)
PHP Version: 5.3.2 OS: Windows
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: eric dot caron at gmail dot com
New email:
PHP Version: OS:

 

 [2010-11-15 18:23 UTC] eric dot caron at gmail dot com
Description:
------------
(Error is from 0.9.10, $Revision: 298824$, but 11 changes in SVN since then don't address anything like this).

PHP's documentation for SolrClient::query says "Returns a SolrQueryResponse object on success and throws a SolrClientException object on failure."

So when trying to catch the error if the server is unresponsive, a try/catch should prevent the timeout errors from being viewed by users. For testing, I've been pointing the Solr client to http://reallyslowsite.com/x, where x is larger than SOLR_TIMEOUT. The timeout does occur, but I can't catch it.

Reproduce code:
---------------
$solr_options = array(
'hostname' => SOLR_SERVER_HOSTNAME,
'login'    => SOLR_SERVER_USERNAME,
'password' => SOLR_SERVER_PASSWORD,
'port'     => SOLR_SERVER_PORT,
'path'     => SOLR_PATH,
'timeout' => SOLR_TIMEOUT,
); 
$sc = new SolrClient($solr_options);
try {
	$query_response = $sc->query("lucene");
} catch(SolrException $e){
	echo "An error occurred.";
}

Expected result:
----------------
An error occurred.

Actual result:
--------------
PHP Warning: SolrClient::query() [solrclient.query]: Solr HTTP Error : 'Timeout was reached'...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-28 15:25 UTC] dorgan at donaldorgan dot com
Thats because PHP is seeing it as a warning...The module 
should be changed to throw an error.  Then it will be 
catchable.
 [2011-06-04 04:20 UTC] iekpo@php.net
Working on this.

Will change to exception after testing is complete.
 [2014-02-14 01:52 UTC] omars@php.net
-Assigned To: iekpo +Assigned To: omars
 [2014-02-14 18:46 UTC] omars@php.net
Automatic comment on behalf of omars
Revision: http://git.php.net/?p=pecl/search_engine/solr.git;a=commit;h=66c5c73bbd824c876d0ebf6adb5e2deaa76365b3
Log: Fixed Bug #59511, SolrClient::query() were producing warning + SolrClientException on http error
 [2014-02-14 18:46 UTC] omars@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 11:01:30 2024 UTC