Skip to content

Commit add7f77

Browse files
committed
Merge branch 'master' into 2.0
2 parents b28aa60 + 407d135 commit add7f77

File tree

4 files changed

+27
-10
lines changed

4 files changed

+27
-10
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ matrix:
2626
env: ES_VERSION="1.5" TEST_BUILD_REF="origin/1.5"
2727
allow_failures:
2828
- php: hhvm
29-
- php: 7.0
3029

3130
env:
3231
global:

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## Release 2.1.4
2+
- Fix the host path handling [[15b5be3]](http://github.com/elasticsearch/elasticsearch-php/commit/15b5be3)
3+
- fix body setter in bulk endpoint [[fa283ea]](http://github.com/elasticsearch/elasticsearch-php/commit/fa283ea)
4+
- add support for generators and iterators in bulk endpoint [[b3d951e]](http://github.com/elasticsearch/elasticsearch-php/commit/b3d951e)
5+
6+
### Testing
7+
- travis: drop PHP 7.0 from allowed failures, it passes well [[be5e710]](http://github.com/elasticsearch/elasticsearch-php/commit/be5e710)
8+
9+
110
## Release 2.1.3
211
- Fix bug where ping() and sniff() encounter NPE [[61ba0c5]](http://github.com/elasticsearch/elasticsearch-php/commit/61ba0c5)
312
- Add Indices/ForceMerge endpoint [[4934583]](http://github.com/elasticsearch/elasticsearch-php/commit/4934583) [[6d61880]](http://github.com/elasticsearch/elasticsearch-php/commit/6d61880) [[58e63d7]](http://github.com/elasticsearch/elasticsearch-php/commit/58e63d7) [[dcd8833]](http://github.com/elasticsearch/elasticsearch-php/commit/dcd8833)

src/Elasticsearch/Connections/Connection.php

+12-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ class Connection implements ConnectionInterface
5252
*/
5353
protected $host;
5454

55+
/**
56+
* @var string || null
57+
*/
58+
protected $path;
59+
5560
/**
5661
* @var LoggerInterface
5762
*/
@@ -108,10 +113,12 @@ public function __construct($handler, $hostDetails, $connectionParams,
108113
}
109114

110115
$host = $hostDetails['host'].':'.$hostDetails['port'];
116+
$path = null;
111117
if (isset($hostDetails['path']) === true) {
112-
$host .= $hostDetails['path'];
118+
$path = $hostDetails['path'];
113119
}
114120
$this->host = $host;
121+
$this->path = $path;
115122
$this->log = $log;
116123
$this->trace = $trace;
117124
$this->connectionParams = $connectionParams;
@@ -291,6 +298,10 @@ private function getURI($uri, $params)
291298
$uri .= '?' . http_build_query($params);
292299
}
293300

301+
if ($this->path !== null) {
302+
$uri = $this->path . $uri;
303+
}
304+
294305
return $uri;
295306
}
296307

src/Elasticsearch/Endpoints/Bulk.php

+6-8
Original file line numberDiff line numberDiff line change
@@ -27,26 +27,24 @@ public function __construct(Transport $transport, SerializerInterface $serialize
2727
}
2828

2929
/**
30-
* @param string|array $body
30+
* @param string|array|\Traversable $body
3131
*
3232
* @return $this
3333
*/
3434
public function setBody($body)
3535
{
36-
if (isset($body) !== true) {
36+
if (empty($body)) {
3737
return $this;
3838
}
3939

40-
if (is_array($body) === true) {
41-
$bulkBody = "";
40+
if (is_array($body) === true || $body instanceof \Traversable) {
4241
foreach ($body as $item) {
43-
$bulkBody .= $this->serializer->serialize($item)."\n";
42+
$this->body .= $this->serializer->serialize($item) . "\n";
4443
}
45-
$body = $bulkBody;
44+
} else {
45+
$this->body = $body;
4646
}
4747

48-
$this->body = $body;
49-
5048
return $this;
5149
}
5250

0 commit comments

Comments
 (0)