Skip to content

Commit 666fc1d

Browse files
committed
Merge remote-tracking branch 'origin/MC-35020' into 2.4-develop-pr30
2 parents 3a65cdc + c9c728e commit 666fc1d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/internal/Magento/Framework/Cache/Backend/RemoteSynchronizedCache.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function save($data, $id, $tags = [], $specificLifetime = false)
237237
$dataToSave = $data;
238238
$remHash = $this->loadRemoteDataVersion($id);
239239

240-
if ($remHash !== false) {
240+
if ($remHash !== false && $this->getDataVersion($data) === $remHash) {
241241
$dataToSave = $this->remote->load($id);
242242
} else {
243243
$this->remote->save($data, $id, $tags, $specificLifetime);

lib/internal/Magento/Framework/Cache/Test/Unit/Backend/RemoteSynchronizedCacheTest.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ public function testClean()
248248
$this->remoteSyncCacheInstance->clean();
249249
}
250250

251-
public function testSaveWithRemoteData()
251+
public function testSaveWithEqualRemoteData()
252252
{
253253
$remoteData = 1;
254254

@@ -270,6 +270,21 @@ public function testSaveWithRemoteData()
270270
$this->remoteSyncCacheInstance->save($remoteData, 1);
271271
}
272272

273+
public function testSaveWithMismatchedRemoteData()
274+
{
275+
$remoteData = '1';
276+
277+
$this->remoteCacheMockExample
278+
->expects($this->at(0))
279+
->method('load')
280+
->willReturn(\hash('sha256', $remoteData));
281+
282+
$this->remoteCacheMockExample->expects($this->exactly(2))->method('save');
283+
$this->localCacheMockExample->expects($this->once())->method('save');
284+
285+
$this->remoteSyncCacheInstance->save(2, 1);
286+
}
287+
273288
public function testSaveWithoutRemoteData()
274289
{
275290
$this->remoteCacheMockExample

0 commit comments

Comments
 (0)