Skip to content

Commit 4802950

Browse files
mazhalaieddielau
authored andcommitted
MAGETWO-31850: [GITHUB] install.log can not be created with open_basedir restriction #796
- reverting few changes in weblogger
1 parent 40148b3 commit 4802950

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

setup/module/Magento/Setup/src/Model/WebLogger.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ class WebLogger implements LoggerInterface
1818
/**
1919
* Log File
2020
*
21-
* @const string
21+
* @var string
2222
*/
23-
const LOG_WEB = 'install.log';
23+
protected $logFile = 'install.log';
2424

2525
/**
2626
* Currently open file resource
@@ -46,10 +46,14 @@ class WebLogger implements LoggerInterface
4646
/**
4747
* Constructor
4848
* @param Filesystem $filesystem
49+
* @param string $logFile
4950
*/
50-
public function __construct(Filesystem $filesystem)
51+
public function __construct(Filesystem $filesystem, $logFile = null)
5152
{
5253
$this->directory = $filesystem->getDirectoryWrite(DirectoryList::LOG);
54+
if ($logFile) {
55+
$this->logFile = $logFile;
56+
}
5357
}
5458

5559
/**
@@ -105,7 +109,7 @@ public function logMeta($message)
105109
*/
106110
private function writeToFile($message)
107111
{
108-
$this->directory->writeFile(self::LOG_WEB, $message, 'a+');
112+
$this->directory->writeFile($this->logFile, $message, 'a+');
109113
}
110114

111115
/**
@@ -115,7 +119,7 @@ private function writeToFile($message)
115119
*/
116120
public function get()
117121
{
118-
$fileContents = explode('\n', $this->directory->readFile(self::LOG_WEB));
122+
$fileContents = explode('\n', $this->directory->readFile($this->logFile));
119123
return $fileContents;
120124
}
121125

@@ -126,8 +130,8 @@ public function get()
126130
*/
127131
public function clear()
128132
{
129-
if ($this->directory->isExist(self::LOG_WEB)) {
130-
$this->directory->delete(self::LOG_WEB);
133+
if ($this->directory->isExist($this->logFile)) {
134+
$this->directory->delete($this->logFile);
131135
}
132136
}
133137

0 commit comments

Comments
 (0)