From b8067146305d3d21fbd1d8a23779882534a93918 Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Tue, 28 Nov 2017 10:33:41 -0500 Subject: [PATCH 1/6] Fix: bufferAdd only allowed commitWithin/overwrite values to be set when flush is manually called and would not set these values when the flush method automatically triggered due to reaching the buffersize. Getter/setter methods were provided similar to bufferSize to allow these values to be preset so that automatic calls to flush would still provide these values. --- .../Plugin/BufferedAdd/BufferedAdd.php | 47 +++++++++++++++++++ .../Plugin/BufferedAdd/BufferedAddTest.php | 12 +++++ 2 files changed, 59 insertions(+) diff --git a/library/Solarium/Plugin/BufferedAdd/BufferedAdd.php b/library/Solarium/Plugin/BufferedAdd/BufferedAdd.php index e2a5e5d10..5f8aa3eab 100644 --- a/library/Solarium/Plugin/BufferedAdd/BufferedAdd.php +++ b/library/Solarium/Plugin/BufferedAdd/BufferedAdd.php @@ -126,6 +126,50 @@ public function getBufferSize() return $this->getOption('buffersize'); } + /** + * Set commitWithin time option. + * + * @param int $time + * + * @return self + */ + public function setCommitWithin($time) + { + return $this->setOption('commitwithin', $time); + } + + /** + * Get commitWithin time option value. + * + * @return int + */ + public function getCommitWithin() + { + return $this->getOption('commitwithin'); + } + + /** + * Set overwrite boolean option. + * + * @param boolean $value + * + * @return self + */ + public function setOverwrite($value) + { + return $this->setOption('overwrite', $value); + } + + /** + * Get overwrite boolean option value. + * + * @return boolean + */ + public function getOverwrite() + { + return $this->getOption('overwrite'); + } + /** * Create a document object instance and add it to the buffer. * @@ -219,6 +263,9 @@ public function flush($overwrite = null, $commitWithin = null) return false; } + $overwrite = is_null($overwrite) ? $this->getOverwrite() : $overwrite; + $commitWithin = is_null($commitWithin) ? $this->getCommitWithin() : $commitWithin; + $event = new PreFlushEvent($this->buffer, $overwrite, $commitWithin); $this->client->getEventDispatcher()->dispatch(Events::PRE_FLUSH, $event); diff --git a/tests/Solarium/Tests/Plugin/BufferedAdd/BufferedAddTest.php b/tests/Solarium/Tests/Plugin/BufferedAdd/BufferedAddTest.php index e6984f6fe..23b81df48 100644 --- a/tests/Solarium/Tests/Plugin/BufferedAdd/BufferedAddTest.php +++ b/tests/Solarium/Tests/Plugin/BufferedAdd/BufferedAddTest.php @@ -57,6 +57,18 @@ public function testSetAndGetBufferSize() $this->assertEquals(500, $this->plugin->getBufferSize()); } + public function testSetAndGetOverwrite() + { + $this->plugin->setOverwrite(true); + $this->assertTrue($this->plugin->getOverwrite()); + } + + public function testSetAndGetCommitWithin() + { + $this->plugin->setCommitWithin(500); + $this->assertEquals(500, $this->plugin->getCommitWithin()); + } + public function testAddDocument() { $doc = new Document(); From 004120974abbbecd5078f358c2a54da6028194b6 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Thu, 1 Nov 2018 08:49:40 +0100 Subject: [PATCH 2/6] fixed format --- src/Plugin/BufferedAdd/BufferedAdd.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Plugin/BufferedAdd/BufferedAdd.php b/src/Plugin/BufferedAdd/BufferedAdd.php index a5d44d21c..51cd27441 100644 --- a/src/Plugin/BufferedAdd/BufferedAdd.php +++ b/src/Plugin/BufferedAdd/BufferedAdd.php @@ -225,8 +225,8 @@ public function flush($overwrite = null, $commitWithin = null) return false; } - $overwrite = is_null($overwrite) ? $this->getOverwrite() : $overwrite; - $commitWithin = is_null($commitWithin) ? $this->getCommitWithin() : $commitWithin; + $overwrite = is_null($overwrite) ? $this->getOverwrite() : $overwrite; + $commitWithin = is_null($commitWithin) ? $this->getCommitWithin() : $commitWithin; $event = new PreFlushEvent($this->buffer, $overwrite, $commitWithin); $this->client->getEventDispatcher()->dispatch(Events::PRE_FLUSH, $event); From a7bda74546abf3ba5301d30a4e065c5909141d27 Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Thu, 1 Nov 2018 08:54:15 +0100 Subject: [PATCH 3/6] fixes #531 --- src/Plugin/BufferedAdd/BufferedAdd.php | 4 ++-- tests/Plugin/BufferedAdd/BufferedAddTest.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Plugin/BufferedAdd/BufferedAdd.php b/src/Plugin/BufferedAdd/BufferedAdd.php index 51cd27441..1c1ecc11e 100644 --- a/src/Plugin/BufferedAdd/BufferedAdd.php +++ b/src/Plugin/BufferedAdd/BufferedAdd.php @@ -113,7 +113,7 @@ public function getCommitWithin() /** * Set overwrite boolean option. * - * @param boolean $value + * @param bool $value * * @return self */ @@ -125,7 +125,7 @@ public function setOverwrite($value) /** * Get overwrite boolean option value. * - * @return boolean + * @return bool */ public function getOverwrite() { diff --git a/tests/Plugin/BufferedAdd/BufferedAddTest.php b/tests/Plugin/BufferedAdd/BufferedAddTest.php index b1cacbdfe..d2c404978 100644 --- a/tests/Plugin/BufferedAdd/BufferedAddTest.php +++ b/tests/Plugin/BufferedAdd/BufferedAddTest.php @@ -37,13 +37,13 @@ public function testSetAndGetOverwrite() { $this->plugin->setOverwrite(true); $this->assertTrue($this->plugin->getOverwrite()); - } + } public function testSetAndGetCommitWithin() { $this->plugin->setCommitWithin(500); $this->assertSame(500, $this->plugin->getCommitWithin()); - } + } public function testAddDocument() { From fb72f8b0c69c804909d12102375ecd5a46c1cf9c Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Thu, 1 Nov 2018 09:01:49 +0100 Subject: [PATCH 4/6] updated Changelog --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 82606cc73..60f521a0a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Endpoint::getCoreBaseUri - Expression::indent - Set erroneous expression on StreamException +- BufferedAdd::setCommitWithin +- BufferedAdd::setOverwrite ### Changed From b289a05ae40b2dd777ec7dfc47550f283b4c74eb Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Thu, 1 Nov 2018 11:20:55 +0100 Subject: [PATCH 5/6] prepared 4.2.0-beta.1 --- CHANGELOG.md | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60f521a0a..32c6c4c3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,29 +4,24 @@ All notable changes to the solarium library will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). -## [master] +## [4.2.0-beta.1] ### Added - Basic support for PUT requests in the HttpAdapter layer +- Support for managed resources - Core Admin Queries - Endpoint::getServerUri - Endpoint::getCoreBaseUri - Expression::indent -- Set erroneous expression on StreamException - BufferedAdd::setCommitWithin - BufferedAdd::setOverwrite - -### Changed +- Set erroneous expression on StreamException ### Deprecated - Endpoint::getBaseUri is deprecated. Please use getServerUri or getCoreBaseUri now. -### Removed - ### Fixed - Allow multiple Field Facets for the same field by dynamically using local facet params if required -### Security - ## [4.1.0] ### Added @@ -34,7 +29,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - Basic support for DELETE requests in the HttpAdapter layer - Introduced an AdapterHelper class to start unifying implementations across all HTTP adapters - ### Changed - To unify the file extraction across all HTTP Adapters, the filename is now always reduced to its basepath From e7a9f92fff4b0e243ae5ab0c556ab6fa0e2fed4b Mon Sep 17 00:00:00 2001 From: Markus Kalkbrenner Date: Thu, 1 Nov 2018 11:22:12 +0100 Subject: [PATCH 6/6] prepared CHANGELOG for master --- CHANGELOG.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32c6c4c3c..4ba1f600f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,20 @@ All notable changes to the solarium library will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [master] +### Added + +### Changed + +### Deprecated + +### Removed + +### Fixed + +### Security + + ## [4.2.0-beta.1] ### Added - Basic support for PUT requests in the HttpAdapter layer