Skip to content

Commit d6c3152

Browse files
committed
ENGCOM-2841: Fix external Sodium Encryption PR
1 parent 87e0084 commit d6c3152

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

app/code/Magento/EncryptionKey/Setup/Patch/Data/SodiumChachaPatch.php

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?php
2-
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
36
declare(strict_types=1);
47

58
namespace Magento\EncryptionKey\Setup\Patch\Data;
@@ -27,26 +30,26 @@ class SodiumChachaPatch implements DataPatchInterface
2730
private $encryptor;
2831

2932
/**
30-
* @var \Magento\Framework\Config\ScopeInterface
33+
* @var \Magento\Framework\App\State
3134
*/
32-
private $scope;
35+
private $state;
3336

3437
/**
3538
* @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
3639
* @param \Magento\Config\Model\Config\Structure\Proxy $structure
3740
* @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
38-
* @param \Magento\Framework\Config\ScopeInterface $scope
41+
* @param \Magento\Framework\App\State $state
3942
*/
4043
public function __construct(
4144
\Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
4245
\Magento\Config\Model\Config\Structure\Proxy $structure,
4346
\Magento\Framework\Encryption\EncryptorInterface $encryptor,
44-
\Magento\Framework\Config\ScopeInterface $scope
47+
\Magento\Framework\App\State $state
4548
) {
4649
$this->moduleDataSetup = $moduleDataSetup;
4750
$this->structure = $structure;
4851
$this->encryptor = $encryptor;
49-
$this->scope = $scope;
52+
$this->state = $state;
5053
}
5154

5255
/**
@@ -79,17 +82,16 @@ public function getAliases()
7982

8083
private function reEncryptSystemConfigurationValues()
8184
{
82-
$currentScope = $this->scope->getCurrentScope();
83-
84-
$this->scope->setCurrentScope(\Magento\Framework\App\Area::AREA_ADMINHTML);
85-
86-
$paths = $this->structure->getFieldPathsByAttribute(
87-
'backend_model',
88-
\Magento\Config\Model\Config\Backend\Encrypted::class
85+
$structure = $this->structure;
86+
$paths = $this->state->emulateAreaCode(
87+
\Magento\Framework\App\Area::AREA_ADMINHTML,
88+
function () use ($structure) {
89+
return $structure->getFieldPathsByAttribute(
90+
'backend_model',
91+
\Magento\Config\Model\Config\Backend\Encrypted::class
92+
);
93+
}
8994
);
90-
91-
$this->scope->setCurrentScope($currentScope);
92-
9395
// walk through found data and re-encrypt it
9496
if ($paths) {
9597
$table = $this->moduleDataSetup->getTable('core_config_data');

0 commit comments

Comments
 (0)