Skip to content

Commit 7b0be6d

Browse files
authored
[BUG] Fix SqLiteIndex for multi-dimensional arrays
- Without this change the script breaks for property values with nested arrays - TODO: Not sure if it's possible for properties to be objects, if it is we have the same problem for objects
1 parent cd403eb commit 7b0be6d

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

Classes/Domain/Service/SqLiteIndex.php

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function insertOrUpdatePropertiesToIndex($properties, $identifier) {
114114
$statementArgumentNumber = 1;
115115
foreach ($properties as $propertyValue) {
116116
if (is_array($propertyValue)) {
117-
$propertyValue = implode(',', $propertyValue);
117+
$propertyValue = $this->implodeRecursive(',', $propertyValue);
118118
}
119119
$preparedStatement->bindValue($this->preparedStatementArgumentName($statementArgumentNumber), $propertyValue);
120120
$statementArgumentNumber++;
@@ -300,4 +300,21 @@ protected function adjustIndexToGivenProperties(array $propertyNames) {
300300
}
301301
}
302302
}
303+
304+
/**
305+
* @param string $glue
306+
* @param array $pieces
307+
* @return string
308+
*/
309+
private function implodeRecursive($glue, $pieces) {
310+
$stringValue = '';
311+
array_walk_recursive($pieces,
312+
function($cellValue) use (&$stringValue, $glue) {
313+
$stringValue .= $cellValue . $glue;
314+
});
315+
316+
// Remove trailing glue
317+
$stringValue = substr($stringValue, 0, 0 - strlen($glue));
318+
return $stringValue;
319+
}
303320
}

0 commit comments

Comments
 (0)