Skip to content

Commit 968f200

Browse files
author
Sergey Shvets
committed
MAGETWO-83646: Encrypted scope-specific config values fail to decrypt on PHP7 #8591
1 parent ab10b9c commit 968f200

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

lib/internal/Magento/Framework/App/Config/Scope/Converter.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,19 +28,28 @@ public function convert($source)
2828
/**
2929
* Set array value by path
3030
*
31-
* @param array $output
31+
* @param array $container
3232
* @param string $path
3333
* @param string $value
3434
* @return array
3535
*/
36-
protected function _setArrayValue(array $output, $path, $value)
36+
protected function _setArrayValue(array $container, $path, $value)
3737
{
38-
$parts = array_reverse(explode('/', $path));
38+
$parts = explode('/', $path);
3939

40-
$result = $value;
41-
foreach ($parts as $part) {
42-
$result = [$part => $result];
40+
if (count($parts) > 0) {
41+
$parts = array_reverse($parts);
42+
43+
$result = $value;
44+
foreach ($parts as $part) {
45+
$part = trim($part);
46+
if ($part !== '') {
47+
$result = [$part => $result];
48+
}
49+
}
50+
51+
$container = array_merge_recursive($container, $result);
4352
}
44-
return array_merge_recursive($output, $result);
53+
return $container;
4554
}
4655
}

lib/internal/Magento/Framework/App/Test/Unit/Config/Scope/ConverterTest.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,17 @@ public function testConvert()
2525
'some/config/path2' => 'value2',
2626
'some/config/path2' => 'value3',
2727
'some2/config/path2' => 'value4',
28+
'some/bad/path////' => 'value5',
2829
];
2930
$expectedResult = [
3031
'some' => [
3132
'config' => [
3233
'path1' => 'value1',
3334
'path2' => 'value3',
34-
]
35+
],
36+
'bad' => [
37+
'path' => 'value5',
38+
],
3539
],
3640
'some2' => [
3741
'config' => [

0 commit comments

Comments
 (0)