Skip to content

Commit 395c569

Browse files
committed
Merge remote-tracking branch 'origin/2.4' into 2.5
2 parents 3c89d26 + a34ee30 commit 395c569

File tree

6 files changed

+66
-19
lines changed

6 files changed

+66
-19
lines changed

.github/ci/files/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,10 @@
1717
},
1818
"require-dev": {
1919
"codeception/codeception": "^5.3.2",
20-
"codeception/stub": "^4.3.0",
2120
"codeception/phpunit-wrapper": "^9",
2221
"codeception/module-asserts": "^2",
2322
"codeception/module-symfony": "^3.1.1",
24-
"phpunit/phpunit": "^10.5.63"
23+
"phpunit/phpunit": "10.2.7"
2524
},
2625
"autoload": {
2726
"psr-4": {

doc/02_Configuration/05_Elasticsearch.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pimcore_elasticsearch_client:
1818
hosts: ['elastic:9200']
1919
username: 'elastic'
2020
password: 'somethingsecret'
21-
logger_channel: 'pimcore.elasicsearch'
21+
logger_channel: 'pimcore.elasticsearch'
2222

2323
# Define the client to be used by your bundle (default client_type is 'openSearch')
2424
pimcore_generic_data_index:

doc/04_Searching_For_Data_In_Index/09_Pimcore_Query_Language/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Pimcore Query Language
1+
# Pimcore Query Language (PQL)
22

33
Pimcore Query Language (PQL) is a query language that allows you to search for data in the Pimcore Generic Data Index. It is a simple and powerful query language that allows you to search for data using a wide range of search criteria.
44

src/SearchIndexAdapter/DefaultSearch/DataObject/FieldDefinitionAdapter/TextKeywordAdapter.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,4 @@ public function getIndexMapping(): array
3939
$this->searchIndexConfigService->getSearchAnalyzerAttributes()
4040
);
4141
}
42-
43-
public function normalize(mixed $value): mixed
44-
{
45-
if (is_string($value) && $value !== '') {
46-
return preg_replace("/src=(['\"])data:[^;]+;base64,.+?\\1/", '', $value);
47-
}
48-
49-
return parent::normalize($value);
50-
}
5142
}

src/SearchIndexAdapter/DefaultSearch/DataObject/FieldDefinitionAdapter/TimeAdapter.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ public function getIndexMapping(): array
2727
'format' => 'strict_hour_minute',
2828
];
2929
}
30+
31+
public function normalize(mixed $value): mixed
32+
{
33+
if ($value === '') {
34+
return null;
35+
}
36+
37+
return parent::normalize($value);
38+
}
3039
}

src/SearchIndexAdapter/DefaultSearch/PathService.php

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ private function updatePath(string $indexName, string $currentPath, string $newP
124124
'params' => [
125125
'currentPath' => $currentPath . '/',
126126
'newPath' => $newPath . '/',
127-
'changePathLevel' => count($pathLevels) - 1,
128-
'newPathLevelName' => end($pathLevels),
129127
],
130128
],
131129

@@ -154,15 +152,65 @@ private function getScriptSource(): string
154152
String subFullPath = ctx._source.system_fields.fullPath.substring(params.currentPath.length());
155153
ctx._source.system_fields.fullPath = params.newPath + subFullPath;
156154
157-
for (int i = 0; i < ctx._source.system_fields.pathLevels.length; i++) {
158-
155+
if(ctx._source.system_fields.thumbnail != null &&
156+
ctx._source.system_fields.thumbnail.length() >= params.currentPath.length()) {
157+
String thumbnailPrefix = ctx._source.system_fields.thumbnail.substring(
158+
0,
159+
params.currentPath.length()
160+
);
161+
if(thumbnailPrefix == params.currentPath) {
162+
String thumbnailSubPath = ctx._source.system_fields.thumbnail.substring(
163+
params.currentPath.length()
164+
);
165+
ctx._source.system_fields.thumbnail = params.newPath + thumbnailSubPath;
166+
}
167+
}
159168
160-
if(ctx._source.system_fields.pathLevels[i].level == params.changePathLevel) {
169+
if(ctx._source.containsKey("custom_fields") &&
170+
ctx._source.custom_fields.containsKey("PortalEngineBundle") &&
171+
ctx._source.custom_fields.PortalEngineBundle.containsKey("system_fields") &&
172+
ctx._source.custom_fields.PortalEngineBundle.system_fields.containsKey("thumbnail")) {
173+
def customFields = ctx._source.custom_fields.PortalEngineBundle.system_fields;
174+
if(customFields.thumbnail != null && customFields.thumbnail instanceof String) {
175+
String thumb = customFields.thumbnail;
176+
String prefix = "";
177+
int pathStart = 0;
178+
179+
if(thumb.startsWith("/cache-buster-")) {
180+
int slashPos = thumb.indexOf("/", 1);
181+
if(slashPos > 0) {
182+
prefix = thumb.substring(0, slashPos);
183+
pathStart = slashPos;
184+
}
185+
}
186+
187+
String encodedCurrentPath = params.currentPath.replace(" ", "%20");
188+
String thumbPath = thumb.substring(pathStart);
189+
190+
if(thumbPath.startsWith(encodedCurrentPath) || thumbPath.startsWith(params.currentPath)) {
191+
String matchedPath = thumbPath.startsWith(encodedCurrentPath) ?
192+
encodedCurrentPath : params.currentPath;
193+
String remainingPath = thumbPath.substring(matchedPath.length());
194+
String encodedNewPath = params.newPath.replace(" ", "%20");
195+
customFields.thumbnail = prefix + encodedNewPath + remainingPath;
196+
}
197+
198+
}
199+
}
161200
162-
ctx._source.system_fields.pathLevels[i].name = params.newPathLevelName;
201+
String[] newPathParts = ctx._source.system_fields.path.splitOnToken("/");
202+
203+
def newLevels = [];
204+
int levelCounter = 1;
205+
for (int i = 0; i < newPathParts.length; i++) {
206+
if(newPathParts[i].length() > 0) {
207+
newLevels.add(["level": levelCounter, "name": newPathParts[i]]);
208+
levelCounter++;
163209
}
164210
}
211+
ctx._source.system_fields.pathLevels = newLevels;
165212
}
213+
ctx._source.system_fields.modificationDate = Instant.now().toString();
166214
ctx._source.system_fields.checksum = 0';
167215
}
168216

0 commit comments

Comments
 (0)