diff --git a/Changelog.md b/Changelog.md index 6250ff7..d72fd23 100644 --- a/Changelog.md +++ b/Changelog.md @@ -53,3 +53,5 @@ __*Why "v3.0.0" instead of "v1.0.0?"*__ Because the linker is intended for use w [2023.09.04; Maikuolan]: Added L10N for Afrikaans and Romanian. [2023.09.16~18; Maikuolan]: Significantly refactored all L10N data. + +[2023.09.18; Maikuolan]: Better resource guarding. diff --git a/src/Linker.php b/src/Linker.php index 4ff401b..f029ded 100644 --- a/src/Linker.php +++ b/src/Linker.php @@ -8,7 +8,7 @@ * License: GNU/GPLv2 * @see LICENSE.txt * - * This file: PHPMailer-phpMussel linker (last modified: 2022.02.13). + * This file: PHPMailer-phpMussel linker (last modified: 2023.09.18). */ namespace phpMussel\PHPMailer; @@ -81,7 +81,10 @@ public function __construct(\phpMussel\Core\Loader &$Loader) $Truncate = $this->Loader->readBytes($this->Loader->Configuration['core']['truncate']); $WriteMode = (!file_exists($EventLog) || ($Truncate > 0 && filesize($EventLog) >= $Truncate)) ? 'wb' : 'ab'; - $Handle = fopen($EventLog, $WriteMode); + if (!is_resource($Handle = fopen($EventLog, $WriteMode))) { + trigger_error('The "writeToPHPMailerEventLog" event failed to open "' . $EventLog . '" for writing.'); + return false; + } fwrite($Handle, $Data); fclose($Handle); $this->Loader->logRotation($this->Loader->Configuration['phpmailer']['event_log']);