Skip to content

Instantly share code, notes, and snippets.

@dkuebric
Last active December 19, 2015 01:48
Show Gist options
  • Save dkuebric/5877999 to your computer and use it in GitHub Desktop.
Save dkuebric/5877999 to your computer and use it in GitHub Desktop.
quick patch to provide tracing coverage to Solarium
<?php
public function execute($request, $endpoint)
{
if (is_callable('oboe_log')) {
oboe_log('Solarium', 'entry', array('IsService'=>'1'));
}
$client = $this->getZendHttp();
$client->resetParameters();
switch ($request->getMethod()) {
case Request::METHOD_GET:
$client->setMethod(\Zend_Http_Client::GET);
$client->setParameterGet($request->getParams());
break;
case Request::METHOD_POST:
$client->setMethod(\Zend_Http_Client::POST);
if ($request->getFileUpload()) {
$this->prepareFileUpload($client, $request);
} else {
$client->setParameterGet($request->getParams());
$client->setRawData($request->getRawData());
$request->addHeader('Content-Type: text/xml; charset=UTF-8');
}
break;
case Request::METHOD_HEAD:
$client->setMethod(\Zend_Http_Client::HEAD);
$client->setParameterGet($request->getParams());
break;
default:
throw new OutOfBoundsException('Unsupported method: ' . $request->getMethod());
break;
}
$client->setUri($endpoint->getBaseUri() . $request->getHandler());
$client->setHeaders($request->getHeaders());
$this->timeout = $endpoint->getTimeout();
$response = $client->request();
$ret = $this->prepareResponse(
$request,
$response
);
if (is_callable('oboe_log')) {
oboe_log('Solarium', 'exit', array('RemoteURL'=>$client->getUri(true)));
}
return $ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment