Skip to content

Commit d679b0a

Browse files
committed
Better resource guarding.
1 parent 0b62f33 commit d679b0a

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

Changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Prior to phpMussel v3, the "phpMussel Co
7373
[2023.09.04; Maikuolan]: The atHit method has been migrated from the Loader class to the Scanner class, affecting some calls to that method at the Web class; Those calls have been updated accordingly.
7474

7575
[2023.09.16~18; Maikuolan]: Significantly refactored all L10N data.
76+
77+
[2023.09.18; Maikuolan]: Better resource guarding.

src/Web.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* License: GNU/GPLv2
99
* @see LICENSE.txt
1010
*
11-
* This file: Upload handler (last modified: 2023.09.16).
11+
* This file: Upload handler (last modified: 2023.09.18).
1212
*/
1313

1414
namespace phpMussel\Web;
@@ -118,7 +118,10 @@ public function __construct(\phpMussel\Core\Loader &$Loader, \phpMussel\Core\Sca
118118
$Truncate = $this->Loader->readBytes($this->Loader->Configuration['core']['truncate']);
119119
$WriteMode = ($Truncate > 0 && filesize($File) >= $Truncate) ? 'wb' : 'ab';
120120
}
121-
$Stream = fopen($File, $WriteMode);
121+
if (!is_resource($Stream = fopen($File, $WriteMode))) {
122+
trigger_error('The "writeToUploadsLog" event failed to open "' . $File . '" for writing.');
123+
return false;
124+
}
122125
fwrite($Stream, $Data);
123126
fclose($Stream);
124127
$this->Loader->logRotation($this->Loader->Configuration['web']['uploads_log']);

0 commit comments

Comments
 (0)