From 0bd18985d5c6a2aaabfe23fda0b4839538b6f6d5 Mon Sep 17 00:00:00 2001 From: Nicolas Ruflin Date: Mon, 19 Feb 2018 08:12:53 +1100 Subject: [PATCH] Prepare 6.0.1 release (#1465) --- CHANGELOG.md | 15 +++++++++++---- lib/Elastica/Aggregation/AvgBucket.php | 2 +- lib/Elastica/Aggregation/SumBucket.php | 2 +- lib/Elastica/Bulk/Action.php | 2 +- lib/Elastica/Index.php | 4 ++-- lib/Elastica/QueryBuilder/DSL/Aggregation.php | 10 +++++----- lib/Elastica/Type.php | 8 +++++--- lib/Elastica/Util.php | 4 ++-- test/Elastica/Aggregation/AvgBucketTest.php | 3 +-- test/Elastica/Aggregation/SumBucketTest.php | 3 +-- test/Elastica/Bulk/Action/UpdateDocumentTest.php | 9 ++++----- test/Elastica/BulkTest.php | 4 +++- test/Elastica/Query/TermsTest.php | 9 ++++----- test/Elastica/Transport/AwsAuthV4Test.php | 3 +-- 14 files changed, 42 insertions(+), 36 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e8db0c600..1091dea6cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,17 @@ All notable changes to this project will be documented in this file based on the ### Backward Compatibility Breaks +### Bugfixes + +### Added + +### Improvements + +### Deprecated + + +## [6.0.1](https://github.com/ruflin/Elastica/compare/6.0.0...6.0.1) + ### Bugfixes - Characters "<" and ">" will be removed when a query term is passed to [`Util::escapeTerm`](https://github.com/ruflin/Elastica/pull/1415/files). Since v5.1 the [documentation](https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_reserved_characters) states that these symbols cannot be escaped ever. - Remove [`each()`](http://www.php.net/each) usage to fix PHP 7.2 compatibility @@ -19,10 +30,6 @@ All notable changes to this project will be documented in this file based on the * Added avg_bucket() and sum_bucket() in aggregations [PR#1443](https://github.com/ruflin/Elastica/pull/1443) - (https://github.com/ruflin/Elastica/issues/1279) * Added support for [terms lookup mechanism](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-terms-query.html#query-dsl-terms-lookup) on terms query [#1452](https://github.com/ruflin/Elastica/pull/1452) -### Improvements - -### Deprecated - ## [6.0.0](https://github.com/ruflin/Elastica/compare/6.0.0-beta1...6.0.0) diff --git a/lib/Elastica/Aggregation/AvgBucket.php b/lib/Elastica/Aggregation/AvgBucket.php index 16d8b1fde1..32c4886f65 100644 --- a/lib/Elastica/Aggregation/AvgBucket.php +++ b/lib/Elastica/Aggregation/AvgBucket.php @@ -12,7 +12,7 @@ class AvgBucket extends AbstractAggregation { /** * @param string $name - * @param string|null $bucketsPath + * @param string|null $bucketsPath */ public function __construct($name, $bucketsPath = null) { diff --git a/lib/Elastica/Aggregation/SumBucket.php b/lib/Elastica/Aggregation/SumBucket.php index 7cd4d396e9..e489d2f1e1 100644 --- a/lib/Elastica/Aggregation/SumBucket.php +++ b/lib/Elastica/Aggregation/SumBucket.php @@ -12,7 +12,7 @@ class SumBucket extends AbstractAggregation { /** * @param string $name - * @param string|null $bucketsPath + * @param string|null $bucketsPath */ public function __construct($name, $bucketsPath = null) { diff --git a/lib/Elastica/Bulk/Action.php b/lib/Elastica/Bulk/Action.php index c4292100e8..53b62e1da9 100644 --- a/lib/Elastica/Bulk/Action.php +++ b/lib/Elastica/Bulk/Action.php @@ -206,7 +206,7 @@ public function toString() $string .= $source; } elseif (is_array($source) && array_key_exists('doc', $source) && is_string($source['doc'])) { if (isset($source['doc_as_upsert'])) { - $docAsUpsert = ', "doc_as_upsert": ' . ($source['doc_as_upsert'] ? 'true' : 'false' ); + $docAsUpsert = ', "doc_as_upsert": '.($source['doc_as_upsert'] ? 'true' : 'false'); } else { $docAsUpsert = ''; } diff --git a/lib/Elastica/Index.php b/lib/Elastica/Index.php index 44cbd60e1f..388a65e349 100644 --- a/lib/Elastica/Index.php +++ b/lib/Elastica/Index.php @@ -118,7 +118,7 @@ public function getSettings() /** * Uses _bulk to send documents to the server. * - * @param array|\Elastica\Document[] $docs Array of Elastica\Document + * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api * * @return \Elastica\Bulk\ResponseSet @@ -137,7 +137,7 @@ public function updateDocuments(array $docs, array $options = []) /** * Uses _bulk to send documents to the server. * - * @param array|\Elastica\Document[] $docs Array of Elastica\Document + * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api * * @return \Elastica\Bulk\ResponseSet diff --git a/lib/Elastica/QueryBuilder/DSL/Aggregation.php b/lib/Elastica/QueryBuilder/DSL/Aggregation.php index eda13188c2..8e4247895f 100644 --- a/lib/Elastica/QueryBuilder/DSL/Aggregation.php +++ b/lib/Elastica/QueryBuilder/DSL/Aggregation.php @@ -101,8 +101,8 @@ public function sum($name) * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-sum-bucket-aggregation.html * - * @param string $name - * @param string|null $bucketsPath + * @param string $name + * @param string|null $bucketsPath * * @return SumBucket */ @@ -125,13 +125,13 @@ public function avg($name) return new Avg($name); } - /** + /** * avg bucket aggregation. * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-pipeline-avg-bucket-aggregation.html * - * @param string $name - * @param string|null $bucketsPath + * @param string $name + * @param string|null $bucketsPath * * @return AvgBucket */ diff --git a/lib/Elastica/Type.php b/lib/Elastica/Type.php index 5539bb4fe6..0f300ca8f6 100644 --- a/lib/Elastica/Type.php +++ b/lib/Elastica/Type.php @@ -166,7 +166,7 @@ public function updateDocument($data, array $options = []) /** * Uses _bulk to send documents to the server. * - * @param array|\Elastica\Document[] $docs Array of Elastica\Document + * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api * * @return \Elastica\Bulk\ResponseSet @@ -185,8 +185,9 @@ public function updateDocuments(array $docs, array $options = []) /** * Uses _bulk to send documents to the server. * - * @param array|\Elastica\Document[] $docs Array of Elastica\Document + * @param array|\Elastica\Document[] $docs Array of Elastica\Document * @param array $options Array of query params to use for query. For possible options check es api + * * @return \Elastica\Bulk\ResponseSet * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html @@ -204,9 +205,10 @@ public function addDocuments(array $docs, array $options = []) * Uses _bulk to send documents to the server. * * @param object[] $objects - * @param array $options Array of query params to use for query. For possible options check es api + * @param array $options Array of query params to use for query. For possible options check es api * * @return Bulk\ResponseSet + * * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-bulk.html */ public function addObjects(array $objects, array $options = []) diff --git a/lib/Elastica/Util.php b/lib/Elastica/Util.php index 6e5044634e..b14c9011a5 100644 --- a/lib/Elastica/Util.php +++ b/lib/Elastica/Util.php @@ -74,7 +74,7 @@ public static function escapeDateMath($requestUri) /** * Replace known reserved words (e.g. AND OR NOT) * and - * escape known special characters (e.g. + - && || ! ( ) { } [ ] ^ " ~ * ? : etc.) + * escape known special characters (e.g. + - && || ! ( ) { } [ ] ^ " ~ * ? : etc.). * * @link https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_boolean_operators * @link https://www.elastic.co/guide/en/elasticsearch/reference/5.1/query-dsl-query-string-query.html#_reserved_characters @@ -111,7 +111,7 @@ public static function escapeTerm($term) foreach ($escapableChars as $char) { $result = str_replace($char, '\\'.$char, $result); } - + // < and > cannot be escaped, so they should be removed // @see https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters $nonEscapableChars = ['<', '>']; diff --git a/test/Elastica/Aggregation/AvgBucketTest.php b/test/Elastica/Aggregation/AvgBucketTest.php index 1dc0811bae..55e67457c1 100644 --- a/test/Elastica/Aggregation/AvgBucketTest.php +++ b/test/Elastica/Aggregation/AvgBucketTest.php @@ -42,8 +42,7 @@ public function testAvgBucketAggregation() ->addAggregation( (new AvgBucket('avg_likes_by_page')) ->setBucketsPath('pages>avg_likes') - ) - ; + ); $results = $this->_getIndexForTest()->search($query)->getAggregations(); diff --git a/test/Elastica/Aggregation/SumBucketTest.php b/test/Elastica/Aggregation/SumBucketTest.php index 1ed4f2df19..74bde5446b 100644 --- a/test/Elastica/Aggregation/SumBucketTest.php +++ b/test/Elastica/Aggregation/SumBucketTest.php @@ -42,8 +42,7 @@ public function testSumBucketAggregation() ->addAggregation( (new SumBucket('sum_likes_by_page')) ->setBucketsPath('pages>sum_likes') - ) - ; + ); $results = $this->_getIndexForTest()->search($query)->getAggregations(); diff --git a/test/Elastica/Bulk/Action/UpdateDocumentTest.php b/test/Elastica/Bulk/Action/UpdateDocumentTest.php index 378b54d0f7..df1a068b0b 100644 --- a/test/Elastica/Bulk/Action/UpdateDocumentTest.php +++ b/test/Elastica/Bulk/Action/UpdateDocumentTest.php @@ -2,12 +2,12 @@ namespace Elastica\Test\BulkAction; use Elastica\Bulk\Action\UpdateDocument; +use Elastica\Document; use Elastica\Index; use Elastica\Test\Base as BaseTest; use Elastica\Type; -use Elastica\Document; -class ActionTest extends BaseTest +class UpdateDocumentTest extends BaseTest { /** * @group unit @@ -61,7 +61,6 @@ public function testUpdateDocument() $expected = '{"update":{"_index":"index2","_type":"type2","_id":1,"_routing":1}}'."\n"; $expected .= $docExpected; $this->assertEquals($expected, $action->toString()); - } /** @@ -77,7 +76,7 @@ public function testUpdateDocumentAsUpsert() $this->assertTrue($action->hasSource()); $expected = '{"update":{"_index":"index","_type":"type","_id":1}}'."\n" - . '{"doc":{"foo":"bar"},"doc_as_upsert":true}'."\n"; + .'{"doc":{"foo":"bar"},"doc_as_upsert":true}'."\n"; $this->assertEquals($expected, $action->toString()); $document->setDocAsUpsert(1); @@ -87,7 +86,7 @@ public function testUpdateDocumentAsUpsert() $document->setDocAsUpsert(false); $action->setDocument($document); $expected = '{"update":{"_index":"index","_type":"type","_id":1}}'."\n" - . '{"doc":{"foo":"bar"}}'."\n"; + .'{"doc":{"foo":"bar"}}'."\n"; $this->assertEquals($expected, $action->toString()); $document->setDocAsUpsert(0); diff --git a/test/Elastica/BulkTest.php b/test/Elastica/BulkTest.php index 7f1c853aa3..c40f16e524 100644 --- a/test/Elastica/BulkTest.php +++ b/test/Elastica/BulkTest.php @@ -562,7 +562,9 @@ public function testUpsert() $doc2 = $type->createDocument(2, ['name' => 'Beckenbauer']); $doc3 = $type->createDocument(3, ['name' => 'Baggio']); $doc4 = $type->createDocument(4, ['name' => 'Cruyff']); - $documents = array_map(function($d){ $d->setDocAsUpsert(true); return $d;}, [$doc1, $doc2, $doc3, $doc4]); + $documents = array_map(function ($d) { $d->setDocAsUpsert(true); + +return $d;}, [$doc1, $doc2, $doc3, $doc4]); //index some documents $bulk = new Bulk($client); diff --git a/test/Elastica/Query/TermsTest.php b/test/Elastica/Query/TermsTest.php index b73d08cf8a..bb2272e48c 100644 --- a/test/Elastica/Query/TermsTest.php +++ b/test/Elastica/Query/TermsTest.php @@ -48,7 +48,7 @@ public function testFilteredSearchWithLookup() $lookupType = $lookupIndex->getType('user'); $lookupType->addDocuments([ - new Document(1, ['terms' => ['ruflin', 'nicolas']]) + new Document(1, ['terms' => ['ruflin', 'nicolas']]), ]); $type->addDocuments([ @@ -63,7 +63,7 @@ public function testFilteredSearchWithLookup() 'index' => $lookupIndex->getName(), 'type' => $lookupType->getName(), 'id' => '1', - 'path' => 'terms' + 'path' => 'terms', ]); $index->refresh(); $lookupIndex->refresh(); @@ -113,7 +113,6 @@ public function testSetMinimum($minimum) $this->assertEquals($minimum, $data['terms']['minimum_match']); } - /** * @group unit */ @@ -124,10 +123,10 @@ public function testSetTermsLookup() 'index' => 'index_name', 'type' => 'type_name', 'id' => '1', - 'path' => 'terms' + 'path' => 'terms', ]; - $query = new Terms; + $query = new Terms(); $query->setTermsLookup($key, $terms); $data = $query->toArray(); $this->assertEquals($terms, $data['terms'][$key]); diff --git a/test/Elastica/Transport/AwsAuthV4Test.php b/test/Elastica/Transport/AwsAuthV4Test.php index c9a9899408..ab15e98fa0 100644 --- a/test/Elastica/Transport/AwsAuthV4Test.php +++ b/test/Elastica/Transport/AwsAuthV4Test.php @@ -84,13 +84,12 @@ public function testSetHttpsIfItIsRequired() 'aws_secret_access_key' => 'bar', 'aws_session_token' => 'baz', 'aws_region' => 'us-east-1', - 'ssl' => true + 'ssl' => true, ]; $client = $this->_getClient($config); try { $client->request('_status', 'GET'); - } catch (GuzzleException $e) { $guzzleException = $e->getGuzzleException(); if ($guzzleException instanceof RequestException) {