From b05490e9be22d8e9ac576ac62b646ddd9b5f3ffe Mon Sep 17 00:00:00 2001 From: Yuriy Andamasov Date: Sat, 23 May 2026 13:28:12 +0300 Subject: E5 fixup: guard buildIndexMappings() against reserved field name collisions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🤖 Generated by [robots](https://vyos.io) --- src/engine/VyOSElasticModernFulltextStorageEngine.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src/engine/VyOSElasticModernFulltextStorageEngine.php') diff --git a/src/engine/VyOSElasticModernFulltextStorageEngine.php b/src/engine/VyOSElasticModernFulltextStorageEngine.php index 16c519c..f798e4b 100644 --- a/src/engine/VyOSElasticModernFulltextStorageEngine.php +++ b/src/engine/VyOSElasticModernFulltextStorageEngine.php @@ -51,6 +51,23 @@ abstract class VyOSElasticModernFulltextStorageEngine public function buildIndexMappings( array $doc_types, array $fields, array $relationships, $text_type) { + // These are emitted as fixed standard fields at the end of the mapping. + // Caller-supplied $fields or $relationships must not shadow them. + static $reserved = array('documentType', 'dateCreated', 'lastModified'); + + $all_caller_keys = array_merge( + $fields, + $relationships, + array_map(function($r) { return $r.'_ts'; }, $relationships)); + $collisions = array_intersect($all_caller_keys, $reserved); + if ($collisions) { + throw new Exception( + pht( + 'buildIndexMappings(): caller-supplied field(s) "%s" collide with '. + 'reserved mapping keys.', + implode('", "', array_values($collisions)))); + } + $properties = array(); foreach ($fields as $field) { -- cgit v1.2.3