Skip to content

Commit ca6564a

Browse files
committed
Merge remote-tracking branch 'tier4/ACP2E-3339' into PR-10-04-24
2 parents 0ad7317 + b94fdc4 commit ca6564a

File tree

2 files changed

+26
-6
lines changed

2 files changed

+26
-6
lines changed

app/code/Magento/Analytics/Model/ExportDataHandler.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public function __construct(
9090
public function prepareExportData()
9191
{
9292
try {
93-
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::TMP);
93+
$tmpDirectory = $this->filesystem->getDirectoryWrite(DirectoryList::SYS_TMP);
9494
$this->prepareDirectory($tmpDirectory, $this->getTmpFilesDirRelativePath());
9595
$this->reportWriter->write($tmpDirectory, $this->getTmpFilesDirRelativePath());
9696

@@ -122,7 +122,17 @@ public function prepareExportData()
122122
*/
123123
private function getTmpFilesDirRelativePath()
124124
{
125-
return $this->subdirectoryPath . 'tmp/';
125+
return $this->subdirectoryPath . 'tmp/' . $this->getInstanceIdentifier() . '/';
126+
}
127+
128+
/**
129+
* Return unique identifier for an instance.
130+
*
131+
* @return string
132+
*/
133+
private function getInstanceIdentifier()
134+
{
135+
return hash('sha256', BP);
126136
}
127137

128138
/**

app/code/Magento/Analytics/Test/Unit/Model/ExportDataHandlerTest.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,23 @@ protected function setUp(): void
112112
);
113113
}
114114

115+
/**
116+
* Return unique identifier for an instance.
117+
*
118+
* @return string
119+
*/
120+
private function getInstanceIdentifier()
121+
{
122+
return hash('sha256', BP);
123+
}
124+
115125
/**
116126
* @param bool $isArchiveSourceDirectory
117127
* @dataProvider prepareExportDataDataProvider
118128
*/
119129
public function testPrepareExportData($isArchiveSourceDirectory)
120130
{
121-
$tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/';
131+
$tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/' . $this->getInstanceIdentifier() . '/';
122132
$archiveRelativePath = $this->subdirectoryPath . $this->archiveName;
123133

124134
$archiveSource = $isArchiveSourceDirectory ? (__DIR__) : '/tmp/' . $tmpFilesDirectoryPath;
@@ -127,7 +137,7 @@ public function testPrepareExportData($isArchiveSourceDirectory)
127137
$this->filesystemMock
128138
->expects($this->once())
129139
->method('getDirectoryWrite')
130-
->with(DirectoryList::TMP)
140+
->with(DirectoryList::SYS_TMP)
131141
->willReturn($this->directoryMock);
132142
$this->directoryMock
133143
->expects($this->exactly(4))
@@ -210,13 +220,13 @@ public static function prepareExportDataDataProvider()
210220
public function testPrepareExportDataWithLocalizedException()
211221
{
212222
$this->expectException('Magento\Framework\Exception\LocalizedException');
213-
$tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/';
223+
$tmpFilesDirectoryPath = $this->subdirectoryPath . 'tmp/' . $this->getInstanceIdentifier() . '/';
214224
$archivePath = $this->subdirectoryPath . $this->archiveName;
215225

216226
$this->filesystemMock
217227
->expects($this->once())
218228
->method('getDirectoryWrite')
219-
->with(DirectoryList::TMP)
229+
->with(DirectoryList::SYS_TMP)
220230
->willReturn($this->directoryMock);
221231
$this->reportWriterMock
222232
->expects($this->once())

0 commit comments

Comments
 (0)