From 04acd3d6b9a95ff49d430eaf4f65aabc25282d88 Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Fri, 22 May 2026 10:56:29 +0300 Subject: Engine: Add setVersion() with strict validation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Engine accepts only versions 7 and above (covering ES 7.x, 8.x, and OpenSearch 1.x/2.x/3.x via the typeless API). Anything below 7 raises with a clear message pointing at the bundled engine for ES 5 users. 🤖 Generated by [robots](https://vyos.io) --- src/__phutil_library_map__.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/__phutil_library_map__.php') diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index 298810e..d365d58 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -10,12 +10,14 @@ phutil_register_library_map(array( '__library_version__' => 2, 'class' => array( 'VyOSElasticModernFulltextStorageEngine' => 'engine/VyOSElasticModernFulltextStorageEngine.php', + 'VyOSElasticModernFulltextStorageEngineTestCase' => '__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php', 'VyOSElasticModernHost' => 'host/VyOSElasticModernHost.php', 'VyOSElasticModernHostTestCase' => '__tests__/VyOSElasticModernHostTestCase.php', ), 'function' => array(), 'xmap' => array( 'VyOSElasticModernFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine', + 'VyOSElasticModernFulltextStorageEngineTestCase' => 'PhutilTestCase', 'VyOSElasticModernHost' => 'PhabricatorSearchHost', 'VyOSElasticModernHostTestCase' => 'PhutilTestCase', ), -- cgit v1.2.3 From ed0dee0333acf8a1c79845bba6455506c8210bad Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Sat, 23 May 2026 13:13:22 +0300 Subject: E1 fixup: initialize $version to null; getVersion() throws if unset; use TestDouble in tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated by [robots](https://vyos.io) --- src/__phutil_library_map__.php | 2 ++ ...SElasticModernFulltextStorageEngineTestCase.php | 35 ++++++++++++++++++++-- .../VyOSElasticModernFulltextStorageEngine.php | 6 +++- 3 files changed, 40 insertions(+), 3 deletions(-) (limited to 'src/__phutil_library_map__.php') diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php index d365d58..291fb03 100644 --- a/src/__phutil_library_map__.php +++ b/src/__phutil_library_map__.php @@ -11,6 +11,7 @@ phutil_register_library_map(array( 'class' => array( 'VyOSElasticModernFulltextStorageEngine' => 'engine/VyOSElasticModernFulltextStorageEngine.php', 'VyOSElasticModernFulltextStorageEngineTestCase' => '__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php', + 'VyOSElasticModernFulltextStorageEngineTestDouble' => '__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php', 'VyOSElasticModernHost' => 'host/VyOSElasticModernHost.php', 'VyOSElasticModernHostTestCase' => '__tests__/VyOSElasticModernHostTestCase.php', ), @@ -18,6 +19,7 @@ phutil_register_library_map(array( 'xmap' => array( 'VyOSElasticModernFulltextStorageEngine' => 'PhabricatorFulltextStorageEngine', 'VyOSElasticModernFulltextStorageEngineTestCase' => 'PhutilTestCase', + 'VyOSElasticModernFulltextStorageEngineTestDouble' => 'VyOSElasticModernFulltextStorageEngine', 'VyOSElasticModernHost' => 'PhabricatorSearchHost', 'VyOSElasticModernHostTestCase' => 'PhutilTestCase', ), diff --git a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php index 7a41ca1..7c0755c 100644 --- a/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php +++ b/src/__tests__/VyOSElasticModernFulltextStorageEngineTestCase.php @@ -1,11 +1,42 @@ newEngine(); $caught = null; try { $engine->setVersion($v); @@ -22,7 +53,7 @@ final class VyOSElasticModernFulltextStorageEngineTestCase public function testSetVersionRejectsBelowSeven() { foreach (array(0, 1, 2, 5, 6) as $v) { - $engine = new VyOSElasticModernFulltextStorageEngine(); + $engine = $this->newEngine(); $caught = null; try { $engine->setVersion($v); diff --git a/src/engine/VyOSElasticModernFulltextStorageEngine.php b/src/engine/VyOSElasticModernFulltextStorageEngine.php index 60683b1..2570311 100644 --- a/src/engine/VyOSElasticModernFulltextStorageEngine.php +++ b/src/engine/VyOSElasticModernFulltextStorageEngine.php @@ -7,7 +7,7 @@ abstract class VyOSElasticModernFulltextStorageEngine extends PhabricatorFulltextStorageEngine { - private $version; + private $version = null; public function setVersion($version) { $version = (int)$version; @@ -25,6 +25,10 @@ abstract class VyOSElasticModernFulltextStorageEngine } public function getVersion() { + if ($this->version === null) { + throw new Exception( + pht('Version not configured; call setVersion() or setService() first.')); + } return $this->version; } -- cgit v1.2.3