From 5e5f9b220e34fdcc1a55b9153323e2548f9a51f1 Mon Sep 17 00:00:00 2001 From: Emanuele Panzeri Date: Fri, 29 Nov 2024 08:37:01 +0100 Subject: [PATCH 1/4] Prepare release v8.1.0 (#2235) --- CHANGELOG.md | 20 ++++++++++---------- README.md | 38 +++++++++++++++++--------------------- 2 files changed, 27 insertions(+), 31 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbfb41567..121518180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,27 +4,27 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [Unreleased](https://github.com/ruflin/Elastica/compare/8.0.0...8.x) +## [Unreleased](https://github.com/ruflin/Elastica/compare/8.1.0...8.x) ### Backward Compatibility Breaks +### Added +### Changed +### Deprecated +### Removed +### Fixed +### Security + +## [8.1.0](https://github.com/ruflin/Elastica/compare/8.0.0...8.1.0) ### Added * Added support for the multi-match query type `bool_prefix` [#2220](https://github.com/ruflin/Elastica/pull/2220) -* Supported PHP 8.4 [#2221](https://github.com/ruflin/Elastica/pull/2221) +* Added support for PHP 8.4 [#2221](https://github.com/ruflin/Elastica/pull/2221) * Added support for custom key to IpRange and GeoDistance `addRange` using a common trait [#2227](https://github.com/ruflin/Elastica/pull/2227) * Added bucket sort aggregation [#2229](https://github.com/ruflin/Elastica/pull/2229) -### Changed - -### Deprecated - -### Removed - ### Fixed * Fixed Pipeline Processor handling to allow for multiple processors of the same type [#2218](https://github.com/ruflin/Elastica/pull/2218) -### Security - ## [8.0.0](https://github.com/ruflin/Elastica/compare/8.0.0-alpha1...8.0.0) This a major release with breaking changes. diff --git a/README.md b/README.md index 35ce4ed3d..653a7711f 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,4 @@ -Elastica: elasticsearch PHP Client -================================== +# Elastica: elasticsearch PHP Client [![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica) [![Build Status](https://github.com/ruflin/elastica/workflows/Continuous%20integration/badge.svg?branch=master)](https://github.com/ruflin/Elastica/actions?query=workflow%3A%22Continuous%20integration%22%20branch%3Amaster) @@ -10,40 +9,37 @@ Elastica: elasticsearch PHP Client [![Join the chat at https://gitter.im/ruflin/Elastica](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruflin/Elastica?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/). -If you have questions, don't hesitate to ask them on [Stack Overflow](http://stackoverflow.com/questions/tagged/elastica) and add the Tag "Elastica" or -in our [Gitter](https://gitter.im/ruflin/Elastica) channel. +If you have questions, don't hesitate to ask them on [Stack Overflow](http://stackoverflow.com/questions/tagged/elastica) +and add the Tag "Elastica" or in our [Gitter](https://gitter.im/ruflin/Elastica) channel. + All library issues should go to the [issue tracker from GitHub](https://github.com/ruflin/Elastica/issues). +## Compatibility -Compatibility -------------- This release is compatible with all Elasticsearch 8.0 releases and onwards. The testsuite is run against the most recent minor version of Elasticsearch, currently 8.8.0 and 8.9.0-SNAPSHOT +## Contributing -Contributing ------------- Contributions are always welcome. For details on how to contribute, check the [CONTRIBUTING](https://github.com/ruflin/Elastica/blob/master/CONTRIBUTING.md) file. +## Versions & Dependencies -Versions & Dependencies ------------- This project tries to follow Elasticsearch in terms of [End of Life](https://www.elastic.co/support/eol) and maintenance since 5.x. It is generally recommended to use the latest point release of the relevant branch. -| Elastica branch | ElasticSearch | elasticsearch-php | PHP | -| ----------------------------------------------------- | ------------- | ----------------- | -------------- | -| [8.x](https://github.com/ruflin/Elastica/tree/8.x) | 8.x | ^8.4 | >=8.0 <8.4 -| [7.x](https://github.com/ruflin/Elastica/tree/7.x) | 7.x | ^7.0 | ^7.2 \|\| ^8.0 | -| [6.x](https://github.com/ruflin/Elastica/tree/6.x) | 6.x | ^6.0 | ^7.0 \|\| ^8.0 | +| Elastica branch | ElasticSearch | elasticsearch-php | PHP | +|----------------------------------------------------|---------------|-------------------|----------------| +| [8.x](https://github.com/ruflin/Elastica/tree/8.x) | 8.x | ^8.4 | >=8.0 <8.4 | +| [7.x](https://github.com/ruflin/Elastica/tree/7.x) | 7.x | ^7.0 | ^7.2 \|\| ^8.0 | +| [6.x](https://github.com/ruflin/Elastica/tree/6.x) | 6.x | ^6.0 | ^7.0 \|\| ^8.0 | Unmaintained versions: -| Elastica version | ElasticSearch | elasticsearch-php | PHP | -| ----------------------------------------------------- | ------------- | ----------------- | -------------- | -| [5.x](https://github.com/ruflin/Elastica/tree/5.x) | 5.x | ^5.0 | \>=5.6 | -| [3.x](https://github.com/ruflin/Elastica/tree/3.x) | 2.4.0 | no | \>=5.4 | -| [2.x](https://github.com/ruflin/Elastica/tree/2.x) | 1.7.2 | no | \>=5.3.3 | ------------- +| Elastica version | ElasticSearch | elasticsearch-php | PHP | +|----------------------------------------------------|---------------|-------------------|----------| +| [5.x](https://github.com/ruflin/Elastica/tree/5.x) | 5.x | ^5.0 | \>=5.6 | +| [3.x](https://github.com/ruflin/Elastica/tree/3.x) | 2.4.0 | no | \>=5.4 | +| [2.x](https://github.com/ruflin/Elastica/tree/2.x) | 1.7.2 | no | \>=5.3.3 | From 6d122c69e7386ba91f199e0e6a84459cb12f98e8 Mon Sep 17 00:00:00 2001 From: Morne Alberts Date: Mon, 6 Jan 2025 06:25:29 +0200 Subject: [PATCH 2/4] Update badges (#2238) --- README.md | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 653a7711f..fdfb76349 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,9 @@ # Elastica: elasticsearch PHP Client -[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable.png)](https://packagist.org/packages/ruflin/elastica) -[![Build Status](https://github.com/ruflin/elastica/workflows/Continuous%20integration/badge.svg?branch=master)](https://github.com/ruflin/Elastica/actions?query=workflow%3A%22Continuous%20integration%22%20branch%3Amaster) -[![codecov.io](http://codecov.io/github/ruflin/Elastica/coverage.svg?branch=master)](http://codecov.io/github/ruflin/Elastica?branch=master) -[![Dependency Status](https://www.versioneye.com/php/ruflin:elastica/dev-master/badge.svg)](https://www.versioneye.com/php/ruflin:elastica/dev-master) -[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/ruflin/Elastica/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/ruflin/Elastica/?branch=master) -[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads.png)](https://packagist.org/packages/ruflin/elastica) +[![Latest Stable Version](https://poser.pugx.org/ruflin/Elastica/v/stable)](https://packagist.org/packages/ruflin/elastica) +[![Build Status](https://github.com/ruflin/elastica/actions/workflows/continuous-integration.yaml/badge.svg?branch=8.x)](https://github.com/ruflin/Elastica/actions/workflows/continuous-integration.yaml?query=branch%3A8.x) +[![codecov.io](https://codecov.io/gh/ruflin/Elastica/branch/8.x/graph/badge.svg)](https://app.codecov.io/github/ruflin/Elastica/tree/8.x) +[![Total Downloads](https://poser.pugx.org/ruflin/Elastica/downloads)](https://packagist.org/packages/ruflin/elastica) [![Join the chat at https://gitter.im/ruflin/Elastica](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/ruflin/Elastica?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) All documentation for Elastica can be found under [Elastica.io](http://Elastica.io/). From b37b6365b035149c82a08ad8f4ab666aeda07ea7 Mon Sep 17 00:00:00 2001 From: Marek Hauschwitz <79979498+MrkMrk00@users.noreply.github.com> Date: Fri, 14 Feb 2025 12:24:25 +0100 Subject: [PATCH 3/4] fix: do not mutate BoolQuery instance in toArray method (#2241) fix: do not mutate BoolQuery instance for serializing when `$this->_params` is empty - https://github.com/ruflin/Elastica/issues/1450 --------- Co-authored-by: Marek Hauschwitz --- CHANGELOG.md | 1 + src/Query/BoolQuery.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 121518180..cff9a7fdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Deprecated ### Removed ### Fixed +* `Elastica\Query\BoolQuery::toArray` no longer changes `$this->_params` to \stdClass when empty [#2241](https://github.com/ruflin/Elastica/pull/2241) ### Security ## [8.1.0](https://github.com/ruflin/Elastica/compare/8.0.0...8.1.0) diff --git a/src/Query/BoolQuery.php b/src/Query/BoolQuery.php index 89a8325f8..68d0074bf 100644 --- a/src/Query/BoolQuery.php +++ b/src/Query/BoolQuery.php @@ -87,11 +87,15 @@ public function setMinimumShouldMatch($minimum): self public function toArray(): array { - if (!$this->_params) { - $this->_params = new \stdClass(); + $data = parent::toArray(); + + // When the query has no params, ensure that the query + // serializes into a JSON object instead of an empty array. + if (!$data[$this->_getBaseName()]) { + $data[$this->_getBaseName()] = new \stdClass(); } - return parent::toArray(); + return $data; } /** From de5431bf7ed894040b1e27f4d8c2b90620210891 Mon Sep 17 00:00:00 2001 From: ryu818 Date: Tue, 22 Apr 2025 14:53:25 +0900 Subject: [PATCH 4/4] test: change testAddDocumentAcrossIndices Since if_primary_term and if_seq_no are automatically set in getDocument, it is an error to add them to another Index as is. Therefore, convert the acquired document to an Array before calling --- tests/IndexTest.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/IndexTest.php b/tests/IndexTest.php index 11c0f8bf5..ee68bd0e1 100644 --- a/tests/IndexTest.php +++ b/tests/IndexTest.php @@ -569,7 +569,14 @@ public function testAddDocumentAcrossIndices(): void $index1Doc = $index1->getDocument(1); - $index2->addDocument($index1Doc); + // Since if_primary_term and if_seq_no are automatically set in getDocument, + // it is an error to add them to another Index as is. + // Therefore, convert the acquired document to an Array before calling + $doc = new Document('1'); + $arr = $index1Doc->toArray(); + $doc->setData($arr['_source']); + + $index2->addDocument($doc); $index2Doc = $index1->getDocument(1); $this->assertEquals('Hello world', $index2Doc->get('title'));