Skip to content

Commit c1a6861

Browse files
Witali Rottirnnr
authored andcommitted
[BUGFIX] Potential exception due to timing issues in Solr ping
Fixes: #64551 Change-Id: Ic64001340bfbac37ba586d05415cd674aeee2130
1 parent 8678b9a commit c1a6861

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

Classes/SolrService.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -242,27 +242,20 @@ public function search($query, $offset = 0, $limit = 10, $params = array()) {
242242

243243
/**
244244
* Call the /admin/ping servlet, can be used to quickly tell if a connection to the
245-
* server is able to be made.
245+
* server is available.
246246
*
247247
* Simply overrides the SolrPhpClient implementation, changing ping from a
248248
* HEAD to a GET request, see http://forge.typo3.org/issues/44167
249249
*
250+
* Also does not report the time, see https://forge.typo3.org/issues/64551
251+
*
250252
* @param float|integer $timeout maximum time to wait for ping in seconds, -1 for unlimited (default is 2)
251-
* @return float Actual time taken to ping the server, FALSE if timeout or HTTP error status occurs
253+
* @return bool TRUE if Solr can be reached, FALSE if not
252254
*/
253255
public function ping($timeout = 2) {
254-
$start = microtime(TRUE);
255-
256-
$httpTransport = $this->getHttpTransport();
256+
$httpResponse = $this->getHttpTransport()->performGetRequest($this->_pingUrl, $timeout);
257257

258-
$httpResponse = $httpTransport->performGetRequest($this->_pingUrl, $timeout);
259-
$solrResponse = new Apache_Solr_Response($httpResponse, $this->_createDocuments, $this->_collapseSingleValueArrays);
260-
261-
if ($solrResponse->getHttpStatus() == 200) {
262-
return microtime(TRUE) - $start;
263-
} else {
264-
return FALSE;
265-
}
258+
return ($httpResponse->getStatusCode() === 200);
266259
}
267260

268261
/**

0 commit comments

Comments
 (0)