Skip to content

Commit f872581

Browse files
committed
build bug fixes
1 parent 4419ba4 commit f872581

File tree

2 files changed

+28
-24
lines changed

2 files changed

+28
-24
lines changed

decode/MailReader.php

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -279,19 +279,21 @@ public function getMessages(string $email, int $offset = 0, int $max = 20)
279279
$dbc = $this->pdo;
280280
if ($dbc instanceof \PDO) {
281281
$emails = $dbc->prepare("SELECT * FROM emails WHERE toaddr=:mail LIMIT :offset, :max");
282-
$emails->bindValue(':mail', $email);
283-
$emails->bindValue(':offset', $offset, \PDO::PARAM_INT);
284-
$emails->bindValue(':max', $max, \PDO::PARAM_INT);
285-
$emails->execute();
286-
287-
$records = [];
288-
while ($record = $emails->fetchObject('Mail\Messages')) {
289-
$records[] = $record;
290-
}
282+
if (!is_bool($email)) {
283+
$emails->bindValue(':mail', $email);
284+
$emails->bindValue(':offset', $offset, \PDO::PARAM_INT);
285+
$emails->bindValue(':max', $max, \PDO::PARAM_INT);
286+
$emails->execute();
287+
288+
$records = [];
289+
while ($record = $emails->fetchObject('Mail\Messages')) {
290+
$records[] = $record;
291+
}
291292

292-
unset($emails);
293-
if (\count($records) > 0)
294-
return $records;
293+
unset($emails);
294+
if (\count($records) > 0)
295+
return $records;
296+
}
295297
}
296298

297299
return false;
@@ -302,17 +304,19 @@ public function getMessageAttachments(int $message_id)
302304
$dbc = $this->pdo;
303305
if ($dbc instanceof \PDO) {
304306
$files = $dbc->prepare("SELECT * FROM files WHERE email=:id");
305-
$files->bindValue(':id', $message_id, \PDO::PARAM_INT);
306-
$files->execute();
307+
if (!is_bool($files)) {
308+
$files->bindValue(':id', $message_id, \PDO::PARAM_INT);
309+
$files->execute();
307310

308-
$records = [];
309-
while ($record = $files->fetchObject('Mail\MessageAttachments')) {
310-
$records[] = $record;
311-
}
311+
$records = [];
312+
while ($record = $files->fetchObject('Mail\MessageAttachments')) {
313+
$records[] = $record;
314+
}
312315

313-
unset($files);
314-
if (\count($records) > 0)
315-
return $records;
316+
unset($files);
317+
if (\count($records) > 0)
318+
return $records;
319+
}
316320
}
317321

318322
return false;

tests/MailReaderTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class MailReaderTest extends TestCase
1717

1818
protected $handle;
1919

20-
protected function setUp(): void
20+
protected function setUp()
2121
{
2222
if (!\extension_loaded('pdo_mysql')) {
2323
$this->markTestSkipped(
@@ -39,7 +39,7 @@ protected function setUp(): void
3939
);
4040
}
4141

42-
protected function tearDown(): void
42+
protected function tearDown()
4343
{
4444
$this->handle->query('DROP TABLE emails;');
4545
$this->handle->query('DROP TABLE files;');
@@ -54,7 +54,7 @@ public function testMailPipe()
5454
if ('\\' == \DIRECTORY_SEPARATOR)
5555
$output = \shell_exec('type tests\testfile | php mailPipe.php');
5656
else
57-
$output = \shell_exec('cat tests/testfile | ./mailPipe.php');
57+
$output = \shell_exec('cat tests/testfile | php mailPipe.php');
5858

5959
$this->assertNull($output);
6060

0 commit comments

Comments
 (0)