summaryrefslogtreecommitdiff
path: root/src/engine/VyOSElasticModernFulltextStorageEngine.php
diff options
context:
space:
mode:
authorYuriy Andamasov <yuriy@vyos.io>2026-05-23 13:28:12 +0300
committerYuriy Andamasov <yuriy@vyos.io>2026-05-23 13:28:12 +0300
commitb05490e9be22d8e9ac576ac62b646ddd9b5f3ffe (patch)
tree3a64fdfcb59b0bedbe4425d3194621e949751dfa /src/engine/VyOSElasticModernFulltextStorageEngine.php
parent9259fbf741f4a080285fbdd8d8586681558c0ab6 (diff)
downloadphorge-elasticsearch-modern-b05490e9be22d8e9ac576ac62b646ddd9b5f3ffe.tar.gz
phorge-elasticsearch-modern-b05490e9be22d8e9ac576ac62b646ddd9b5f3ffe.zip
E5 fixup: guard buildIndexMappings() against reserved field name collisions
🤖 Generated by [robots](https://vyos.io)
Diffstat (limited to 'src/engine/VyOSElasticModernFulltextStorageEngine.php')
-rw-r--r--src/engine/VyOSElasticModernFulltextStorageEngine.php17
1 files changed, 17 insertions, 0 deletions
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) {