Skip to content

Commit 5bef840

Browse files
author
Code Slicer
committed
hotfix: use absolute path for lock file
to prevent exception on servers without nginx MAGENTO_ROOT properly defined
1 parent 2b671ae commit 5bef840

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

Model/MessageManagement.php

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
class MessageManagement implements MessageManagementInterface
1919
{
20+
private const LOCK_FILE = 'discorgento_queue.lock';
21+
2022
private DateTime $date;
2123
private FileDriver $fileDriver;
2224
private LoggerInterface $logger;
@@ -127,20 +129,20 @@ public function getToBeRetried()
127129
*/
128130
private function checkLockfile()
129131
{
130-
$lockfilePath = DirectoryList::VAR_DIR . '/discorgento_queue.lock';
131-
if ($this->fileDriver->isFile($lockfilePath)) {
132+
$lockFilepath = BP . DIRECTORY_SEPARATOR . DirectoryList::VAR_DIR . DIRECTORY_SEPARATOR . self::LOCK_FILE;
133+
if ($this->fileDriver->isFile($lockFilepath)) {
132134
$lockTimeLifespan = floatval($this->scopeConfig->getValue('queue/general/lockfile_expires')) * 3600 ?: 3600;
133-
if (time() - filectime($lockfilePath) < $lockTimeLifespan) {
135+
if (time() - filectime($lockFilepath) < $lockTimeLifespan) {
134136
throw new LocalizedException(
135-
__('Queue already running! If you think this is mistake, delete the "%1" lock file.', $lockfilePath)
137+
__('Queue already running! If you think this is mistake, delete the "%1" lock file.', $lockFilepath)
136138
);
137139
}
138140

139-
$this->fileDriver->deleteFile($lockfilePath);
141+
$this->fileDriver->deleteFile($lockFilepath);
140142
}
141143

142-
$this->fileDriver->touch($lockfilePath);
144+
$this->fileDriver->touch($lockFilepath);
143145

144-
return $lockfilePath;
146+
return $lockFilepath;
145147
}
146148
}

0 commit comments

Comments
 (0)