Skip to content

Commit 2e18329

Browse files
author
Oleksii Korshenko
authored
Merge pull request #1563 from magento-engcom/2.1-develop-prs
Public Pull Requests #11201 #11148
2 parents fdf7480 + 1231495 commit 2e18329

File tree

3 files changed

+5
-15
lines changed

3 files changed

+5
-15
lines changed

app/code/Magento/Catalog/Model/Product/Gallery/UpdateHandler.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ protected function processDeletedImages($product, array &$images)
2929
if (!empty($image['removed'])) {
3030
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
3131
$recordsToDelete[] = $image['value_id'];
32-
// only delete physical files if they are not used by any other products
33-
if (!($this->resourceModel->countImageUses($image['file']) > 1)) {
32+
$catalogPath = $this->mediaConfig->getBaseMediaPath();
33+
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
34+
// only delete physical files if they are not used by any other products and if this file exists
35+
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
3436
$filesToDelete[] = ltrim($image['file'], '/');
3537
}
3638
}

lib/internal/Magento/Framework/App/Response/Http/FileFactory.php

-12
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,7 @@ public function create(
9999
if (!empty($content['rm'])) {
100100
$dir->delete($file);
101101
}
102-
$this->callExit();
103102
}
104103
return $this->_response;
105104
}
106-
107-
/**
108-
* Call exit
109-
*
110-
* @return void
111-
* @SuppressWarnings(PHPMD.ExitExpression)
112-
*/
113-
protected function callExit()
114-
{
115-
exit(0);
116-
}
117105
}

lib/internal/Magento/Framework/App/Test/Unit/Response/Http/FileFactoryTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ private function getModelMock()
244244
{
245245
$modelMock = $this->getMock(
246246
'Magento\Framework\App\Response\Http\FileFactory',
247-
['callExit'],
247+
null,
248248
[
249249
'response' => $this->responseMock,
250250
'filesystem' => $this->fileSystemMock,

0 commit comments

Comments
 (0)