Skip to content

Commit dbd2fd4

Browse files
authored
ENGCOM-5582: Fix random fails during parallel SCD execution #22886
2 parents 19371e3 + e23188f commit dbd2fd4

File tree

2 files changed

+8
-47
lines changed

2 files changed

+8
-47
lines changed

lib/internal/Magento/Framework/View/Asset/LockerProcess.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public function __construct(Filesystem $filesystem)
6262
*/
6363
public function lockProcess($lockName)
6464
{
65-
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
65+
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
6666
return;
6767
}
6868

@@ -78,11 +78,12 @@ public function lockProcess($lockName)
7878

7979
/**
8080
* @inheritdoc
81+
*
8182
* @throws FileSystemException
8283
*/
8384
public function unlockProcess()
8485
{
85-
if ($this->getState()->getMode() == State::MODE_PRODUCTION) {
86+
if ($this->getState()->getMode() === State::MODE_PRODUCTION || PHP_SAPI === 'cli') {
8687
return;
8788
}
8889

@@ -115,9 +116,10 @@ private function isProcessLocked()
115116
}
116117

117118
/**
118-
* Get name of lock file
119+
* Get path to lock file
119120
*
120121
* @param string $name
122+
*
121123
* @return string
122124
*/
123125
private function getFilePath($name)
@@ -126,7 +128,10 @@ private function getFilePath($name)
126128
}
127129

128130
/**
131+
* Get State object
132+
*
129133
* @return State
134+
*
130135
* @deprecated 100.1.1
131136
*/
132137
private function getState()

lib/internal/Magento/Framework/View/Test/Unit/Asset/LockerProcessTest.php

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,6 @@ protected function setUp()
6464
);
6565
}
6666

67-
/**
68-
* Test for lockProcess method
69-
*
70-
* @param string $method
71-
*
72-
* @dataProvider dataProviderTestLockProcess
73-
*/
74-
public function testLockProcess($method)
75-
{
76-
$this->stateMock->expects(self::once())->method('getMode')->willReturn(State::MODE_DEVELOPER);
77-
$this->filesystemMock->expects(self::once())
78-
->method('getDirectoryWrite')
79-
->with(DirectoryList::VAR_DIR)
80-
->willReturn($this->$method());
81-
82-
$this->lockerProcess->lockProcess(self::LOCK_NAME);
83-
}
84-
8567
public function testNotLockProcessInProductionMode()
8668
{
8769
$this->stateMock->expects(self::once())->method('getMode')->willReturn(State::MODE_PRODUCTION);
@@ -90,21 +72,6 @@ public function testNotLockProcessInProductionMode()
9072
$this->lockerProcess->lockProcess(self::LOCK_NAME);
9173
}
9274

93-
/**
94-
* Test for unlockProcess method
95-
*/
96-
public function testUnlockProcess()
97-
{
98-
$this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_DEVELOPER);
99-
$this->filesystemMock->expects(self::once())
100-
->method('getDirectoryWrite')
101-
->with(DirectoryList::VAR_DIR)
102-
->willReturn($this->getTmpDirectoryMockFalse(1));
103-
104-
$this->lockerProcess->lockProcess(self::LOCK_NAME);
105-
$this->lockerProcess->unlockProcess();
106-
}
107-
10875
public function testNotUnlockProcessInProductionMode()
10976
{
11077
$this->stateMock->expects(self::exactly(2))->method('getMode')->willReturn(State::MODE_PRODUCTION);
@@ -114,17 +81,6 @@ public function testNotUnlockProcessInProductionMode()
11481
$this->lockerProcess->unlockProcess();
11582
}
11683

117-
/**
118-
* @return array
119-
*/
120-
public function dataProviderTestLockProcess()
121-
{
122-
return [
123-
['method' => 'getTmpDirectoryMockTrue'],
124-
['method' => 'getTmpDirectoryMockFalse']
125-
];
126-
}
127-
12884
/**
12985
* @return WriteInterface|\PHPUnit_Framework_MockObject_MockObject
13086
*/

0 commit comments

Comments
 (0)