Skip to content

Commit e9e8b67

Browse files
committed
MAGETWO-96459: Fix performance on MAGETWO-83832
- fix arch review
1 parent cb0e7ce commit e9e8b67

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

app/code/Magento/Config/App/Config/Type/System.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ class System implements ConfigTypeInterface
7272
private $availableDataScopes;
7373

7474
/**
75-
* @var \Magento\Framework\Filter\Encrypt\AdapterInterface
75+
* @var Encryptor
7676
*/
77-
private $encryptorFilter;
77+
private $encryptor;
7878

7979
/**
8080
* @param ConfigSourceInterface $source
@@ -108,7 +108,7 @@ public function __construct(
108108
$this->serializer = $serializer;
109109
$this->configType = $configType;
110110
$this->reader = $reader ?: ObjectManager::getInstance()->get(Reader::class);
111-
$this->encryptorFilter = ObjectManager::getInstance()->get(\Magento\Framework\Encryption\Encryptor::class);
111+
$this->encryptor = ObjectManager::getInstance()->get(\Magento\Framework\Encryption\Encryptor::class);
112112
}
113113

114114
/**
@@ -198,7 +198,7 @@ private function loadAllData()
198198
if ($cachedData === false) {
199199
$data = $this->readData();
200200
} else {
201-
$data = $this->serializer->unserialize($this->encryptorFilter->decrypt($cachedData));
201+
$data = $this->serializer->unserialize($this->encryptor->decrypt($cachedData));
202202
}
203203

204204
return $data;
@@ -218,7 +218,7 @@ private function loadDefaultScopeData($scopeType)
218218
$data = $this->readData();
219219
$this->cacheData($data);
220220
} else {
221-
$data = [$scopeType => $this->serializer->unserialize($this->encryptorFilter->decrypt($cachedData))];
221+
$data = [$scopeType => $this->serializer->unserialize($this->encryptor->decrypt($cachedData))];
222222
}
223223

224224
return $data;
@@ -239,7 +239,7 @@ private function loadScopeData($scopeType, $scopeId)
239239
if ($this->availableDataScopes === null) {
240240
$cachedScopeData = $this->cache->load($this->configType . '_scopes');
241241
if ($cachedScopeData !== false) {
242-
$serializedCachedData = $this->encryptorFilter->decrypt($cachedScopeData);
242+
$serializedCachedData = $this->encryptor->decrypt($cachedScopeData);
243243
$this->availableDataScopes = $this->serializer->unserialize($serializedCachedData);
244244
}
245245
}
@@ -249,7 +249,7 @@ private function loadScopeData($scopeType, $scopeId)
249249
$data = $this->readData();
250250
$this->cacheData($data);
251251
} else {
252-
$serializedCachedData = $this->encryptorFilter->decrypt($cachedData);
252+
$serializedCachedData = $this->encryptor->decrypt($cachedData);
253253
$data = [$scopeType => [$scopeId => $this->serializer->unserialize($serializedCachedData)]];
254254
}
255255

@@ -267,12 +267,12 @@ private function loadScopeData($scopeType, $scopeId)
267267
private function cacheData(array $data)
268268
{
269269
$this->cache->save(
270-
$this->encryptorFilter->encryptWithFastestAlgorithm($this->serializer->serialize($data)),
270+
$this->encryptor->encryptWithFastestAvailableAlgorithm($this->serializer->serialize($data)),
271271
$this->configType,
272272
[self::CACHE_TAG]
273273
);
274274
$this->cache->save(
275-
$this->encryptorFilter->encryptWithFastestAlgorithm($this->serializer->serialize($data['default'])),
275+
$this->encryptor->encryptWithFastestAvailableAlgorithm($this->serializer->serialize($data['default'])),
276276
$this->configType . '_default',
277277
[self::CACHE_TAG]
278278
);
@@ -281,14 +281,14 @@ private function cacheData(array $data)
281281
foreach ($data[$curScopeType] ?? [] as $curScopeId => $curScopeData) {
282282
$scopes[$curScopeType][$curScopeId] = 1;
283283
$this->cache->save(
284-
$this->encryptorFilter->encryptWithFastestAlgorithm($this->serializer->serialize($curScopeData)),
284+
$this->encryptor->encryptWithFastestAvailableAlgorithm($this->serializer->serialize($curScopeData)),
285285
$this->configType . '_' . $curScopeType . '_' . $curScopeId,
286286
[self::CACHE_TAG]
287287
);
288288
}
289289
}
290290
$this->cache->save(
291-
$this->encryptorFilter->encryptWithFastestAlgorithm($this->serializer->serialize($scopes)),
291+
$this->encryptor->encryptWithFastestAvailableAlgorithm($this->serializer->serialize($scopes)),
292292
$this->configType . '_scopes',
293293
[self::CACHE_TAG]
294294
);

lib/internal/Magento/Framework/Encryption/Encryptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ public function encrypt($data)
295295
* @param string $data
296296
* @return string
297297
*/
298-
public function encryptWithFastestAlgorithm($data)
298+
public function encryptWithFastestAvailableAlgorithm($data)
299299
{
300300
$crypt = $this->getCrypt();
301301
if (null === $crypt) {

setup/src/Magento/Setup/Model/CryptKeyGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(Random $random)
3737
*/
3838
public function generate()
3939
{
40-
return $this->getRandomString();
40+
return md5($this->getRandomString());
4141
}
4242

4343
/**

setup/src/Magento/Setup/Test/Unit/Model/CryptKeyGeneratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,6 @@ public function testReturnsMd5OfRandomString()
5454

5555
$actual = $this->cryptKeyGenerator->generate();
5656

57-
$this->assertEquals($expected, md5($actual));
57+
$this->assertEquals($expected, $actual);
5858
}
5959
}

0 commit comments

Comments
 (0)