Skip to content

Commit

Permalink
Better resource guarding.
Browse files Browse the repository at this point in the history
  • Loading branch information
Maikuolan committed Sep 18, 2023
1 parent 3d7350e commit 96e9f40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
7 changes: 5 additions & 2 deletions src/Linker.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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']);
Expand Down

0 comments on commit 96e9f40

Please sign in to comment.