|
8 | 8 | * License: GNU/GPLv2
|
9 | 9 | * @see LICENSE.txt
|
10 | 10 | *
|
11 |
| - * This file: The loader (last modified: 2023.09.17). |
| 11 | + * This file: The loader (last modified: 2023.09.18). |
12 | 12 | */
|
13 | 13 |
|
14 | 14 | namespace phpMussel\Core;
|
@@ -410,12 +410,12 @@ public function __construct(
|
410 | 410 | $WriteMode = 'ab';
|
411 | 411 | $Data = $this->InstanceCache['PendingErrorLogData'];
|
412 | 412 | }
|
413 |
| - $Handle = fopen($File, $WriteMode); |
414 |
| - if (is_resource($Handle)) { |
415 |
| - fwrite($Handle, $Data); |
416 |
| - fclose($Handle); |
417 |
| - $this->logRotation($this->Configuration['core']['error_log']); |
| 413 | + if (!is_resource($Handle = fopen($File, $WriteMode))) { |
| 414 | + return false; |
418 | 415 | }
|
| 416 | + fwrite($Handle, $Data); |
| 417 | + fclose($Handle); |
| 418 | + $this->logRotation($this->Configuration['core']['error_log']); |
419 | 419 | return true;
|
420 | 420 | });
|
421 | 421 |
|
@@ -476,8 +476,7 @@ public function readFile(string $File): string
|
476 | 476 | return '';
|
477 | 477 | }
|
478 | 478 |
|
479 |
| - $Handle = fopen($File, 'rb'); |
480 |
| - if (!is_resource($Handle)) { |
| 479 | + if (!is_resource($Handle = fopen($File, 'rb'))) { |
481 | 480 | return '';
|
482 | 481 | }
|
483 | 482 | $Data = fread($Handle, $Filesize);
|
@@ -960,8 +959,7 @@ public function readFileContentGZ(string $File): string
|
960 | 959 |
|
961 | 960 | $Data = '';
|
962 | 961 | if ($BlocksToRead > 0) {
|
963 |
| - $Handle = gzopen($File, 'rb'); |
964 |
| - if (!is_resource($Handle)) { |
| 962 | + if (!is_resource($Handle = gzopen($File, 'rb'))) { |
965 | 963 | return '';
|
966 | 964 | }
|
967 | 965 | $Done = 0;
|
@@ -1041,12 +1039,7 @@ public function gZCompressFile(string $File): bool
|
1041 | 1039 | return false;
|
1042 | 1040 | }
|
1043 | 1041 |
|
1044 |
| - $Handle = fopen($File, 'rb'); |
1045 |
| - if (!is_resource($Handle)) { |
1046 |
| - return false; |
1047 |
| - } |
1048 |
| - $HandleGZ = gzopen($File . '.gz', 'wb'); |
1049 |
| - if (!is_resource($HandleGZ)) { |
| 1042 | + if (!is_resource($Handle = fopen($File, 'rb')) || !is_resource($HandleGZ = gzopen($File . '.gz', 'wb'))) { |
1050 | 1043 | return false;
|
1051 | 1044 | }
|
1052 | 1045 | while (!feof($Handle)) {
|
@@ -1237,8 +1230,7 @@ public function updateConfiguration(): bool
|
1237 | 1230 | } else {
|
1238 | 1231 | return false;
|
1239 | 1232 | }
|
1240 |
| - $Handle = fopen($this->ConfigurationPath, 'wb'); |
1241 |
| - if (!is_resource($Handle)) { |
| 1233 | + if (!is_resource($Handle = fopen($this->ConfigurationPath, 'wb'))) { |
1242 | 1234 | return false;
|
1243 | 1235 | }
|
1244 | 1236 | $Err = fwrite($Handle, $Reconstructed);
|
|
0 commit comments