Skip to content

Commit

Permalink
Merge pull request #1563 from magento-engcom/2.1-develop-prs
Browse files Browse the repository at this point in the history
Public Pull Requests

#11201
#11148
  • Loading branch information
Oleksii Korshenko authored Oct 6, 2017
2 parents fdf7480 + 1231495 commit 2e18329
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ protected function processDeletedImages($product, array &$images)
if (!empty($image['removed'])) {
if (!empty($image['value_id']) && !isset($picturesInOtherStores[$image['file']])) {
$recordsToDelete[] = $image['value_id'];
// only delete physical files if they are not used by any other products
if (!($this->resourceModel->countImageUses($image['file']) > 1)) {
$catalogPath = $this->mediaConfig->getBaseMediaPath();
$isFile = $this->mediaDirectory->isFile($catalogPath . $image['file']);
// only delete physical files if they are not used by any other products and if this file exists
if (!($this->resourceModel->countImageUses($image['file']) > 1) && $isFile) {
$filesToDelete[] = ltrim($image['file'], '/');
}
}
Expand Down
12 changes: 0 additions & 12 deletions lib/internal/Magento/Framework/App/Response/Http/FileFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,19 +99,7 @@ public function create(
if (!empty($content['rm'])) {
$dir->delete($file);
}
$this->callExit();
}
return $this->_response;
}

/**
* Call exit
*
* @return void
* @SuppressWarnings(PHPMD.ExitExpression)
*/
protected function callExit()
{
exit(0);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ private function getModelMock()
{
$modelMock = $this->getMock(
'Magento\Framework\App\Response\Http\FileFactory',
['callExit'],
null,
[
'response' => $this->responseMock,
'filesystem' => $this->fileSystemMock,
Expand Down

0 comments on commit 2e18329

Please sign in to comment.