|
1 | 1 | <?php
|
2 |
| - |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
3 | 6 | declare(strict_types=1);
|
4 | 7 |
|
5 | 8 | namespace Magento\EncryptionKey\Setup\Patch\Data;
|
@@ -27,26 +30,26 @@ class SodiumChachaPatch implements DataPatchInterface
|
27 | 30 | private $encryptor;
|
28 | 31 |
|
29 | 32 | /**
|
30 |
| - * @var \Magento\Framework\Config\ScopeInterface |
| 33 | + * @var \Magento\Framework\App\State |
31 | 34 | */
|
32 |
| - private $scope; |
| 35 | + private $state; |
33 | 36 |
|
34 | 37 | /**
|
35 | 38 | * @param \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup
|
36 | 39 | * @param \Magento\Config\Model\Config\Structure\Proxy $structure
|
37 | 40 | * @param \Magento\Framework\Encryption\EncryptorInterface $encryptor
|
38 |
| - * @param \Magento\Framework\Config\ScopeInterface $scope |
| 41 | + * @param \Magento\Framework\App\State $state |
39 | 42 | */
|
40 | 43 | public function __construct(
|
41 | 44 | \Magento\Framework\Setup\ModuleDataSetupInterface $moduleDataSetup,
|
42 | 45 | \Magento\Config\Model\Config\Structure\Proxy $structure,
|
43 | 46 | \Magento\Framework\Encryption\EncryptorInterface $encryptor,
|
44 |
| - \Magento\Framework\Config\ScopeInterface $scope |
| 47 | + \Magento\Framework\App\State $state |
45 | 48 | ) {
|
46 | 49 | $this->moduleDataSetup = $moduleDataSetup;
|
47 | 50 | $this->structure = $structure;
|
48 | 51 | $this->encryptor = $encryptor;
|
49 |
| - $this->scope = $scope; |
| 52 | + $this->state = $state; |
50 | 53 | }
|
51 | 54 |
|
52 | 55 | /**
|
@@ -79,17 +82,16 @@ public function getAliases()
|
79 | 82 |
|
80 | 83 | private function reEncryptSystemConfigurationValues()
|
81 | 84 | {
|
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 | + } |
89 | 94 | );
|
90 |
| - |
91 |
| - $this->scope->setCurrentScope($currentScope); |
92 |
| - |
93 | 95 | // walk through found data and re-encrypt it
|
94 | 96 | if ($paths) {
|
95 | 97 | $table = $this->moduleDataSetup->getTable('core_config_data');
|
|
0 commit comments