mirror of
https://github.com/nextcloud/server.git
synced 2026-06-13 18:50:47 -04:00
fix: Silence PHP warnings from fopen and mkdir
We are testing the result and logging our own error anyway. Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com> Signed-off-by: Benjamin Gaussorgues <benjamin.gaussorgues@nextcloud.com>
This commit is contained in:
parent
6515fa638a
commit
b2a69d0095
2 changed files with 5 additions and 8 deletions
|
|
@ -50,13 +50,14 @@ class TempManager implements ITempManager {
|
|||
$path = $this->generateTemporaryPath($postFix);
|
||||
|
||||
$old_umask = umask(0077);
|
||||
$fp = fopen($path, 'x');
|
||||
$fp = @fopen($path, 'x');
|
||||
umask($old_umask);
|
||||
if ($fp === false) {
|
||||
$this->log->warning(
|
||||
'Can not create a temporary file in directory {dir}. Check it exists and has correct permissions',
|
||||
[
|
||||
'dir' => $this->tmpBaseDir,
|
||||
'error' => error_get_last(),
|
||||
]
|
||||
);
|
||||
return false;
|
||||
|
|
@ -71,11 +72,12 @@ class TempManager implements ITempManager {
|
|||
public function getTemporaryFolder($postFix = ''): string|false {
|
||||
$path = $this->generateTemporaryPath($postFix) . '/';
|
||||
|
||||
if (mkdir($path, 0700) === false) {
|
||||
if (@mkdir($path, 0700) === false) {
|
||||
$this->log->warning(
|
||||
'Can not create a temporary folder in directory {dir}. Check it exists and has correct permissions',
|
||||
[
|
||||
'dir' => $this->tmpBaseDir,
|
||||
'error' => error_get_last(),
|
||||
]
|
||||
);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -36,12 +36,7 @@ class TempManagerTest extends \Test\TestCase {
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?LoggerInterface $logger
|
||||
* @param ?IConfig $config
|
||||
* @return TempManager
|
||||
*/
|
||||
protected function getManager($logger = null, $config = null) {
|
||||
protected function getManager(?LoggerInterface $logger = null, ?IConfig $config = null): TempManager {
|
||||
if (!$logger) {
|
||||
$logger = $this->createMock(LoggerInterface::class);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue