Skip to content

Commit c4b7e1c

Browse files
fix
1 parent d518fac commit c4b7e1c

File tree

3 files changed

+35
-3
lines changed

3 files changed

+35
-3
lines changed

src/ImapClient.php

+10-2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ class ImapClient
6262
protected $capability_readed = false;
6363
protected $debug = false;
6464
protected $debug_handler = false;
65+
protected $rawLastLine;
6566

6667
const ERROR_OK = 0;
6768
const ERROR_NO = -1;
@@ -1448,9 +1449,11 @@ public function createFolder($mailbox, $types = null)
14481449
$args[] = '(USE (' . implode(' ', $types) . '))';
14491450
}
14501451

1451-
$result = $this->execute('CREATE', $args, self::COMMAND_NORESPONSE);
1452+
$result = $this->execute('CREATE', $args, self::COMMAND_RAW_LASTLINE);
14521453

1453-
return $result == self::ERROR_OK;
1454+
$this->rawLastLine = $result[1];
1455+
1456+
return $result[0] == self::ERROR_OK;
14541457
}
14551458

14561459
/**
@@ -4143,4 +4146,9 @@ protected function debug($message)
41434146
echo "DEBUG: $message\n";
41444147
}
41454148
}
4149+
4150+
public function getRawLastLine()
4151+
{
4152+
return $this->rawLastLine;
4153+
}
41464154
}

src/Mailbox.php

+7-1
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,13 @@ public static function createMailbox($imap, $mailbox)
243243
$mailbox = (string) \preg_replace('/^{.+}/', '', $mailbox);
244244
}
245245

246-
return $client->createFolder($mailbox);
246+
$success = $client->createFolder($mailbox);
247+
248+
if (!$success) {
249+
Errors::appendError($client->getRawLastLine());
250+
}
251+
252+
return $success;
247253
}
248254

249255
public static function renameMailbox($imap, $from, $to)

tests/CompatibilityTest.php

+18
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,24 @@ public function testCreateMailbox()
320320
$imap1 = imap_open($this->mailbox, $this->username, $this->password);
321321
$imap2 = imap2_open($this->mailbox, $this->username, $this->accessToken, OP_XOAUTH2);
322322

323+
// Reset error buffers
324+
imap_alerts();
325+
imap_errors();
326+
imap2_alerts();
327+
imap2_errors();
328+
329+
$inbox = 'INBOX';
330+
$createMailbox1 = imap_createmailbox($imap1, $this->mailbox . $inbox);
331+
$imapAlerts1 = imap_alerts();
332+
$imapErrors1 = imap_errors();
333+
$createMailbox2 = imap2_createmailbox($imap2, $this->mailbox . $inbox);
334+
$imapAlerts2 = imap2_alerts();
335+
$imapErrors2 = imap2_errors();
336+
337+
$this->assertEquals($createMailbox1, $createMailbox2);
338+
$this->assertEquals($imapAlerts1, $imapAlerts2);
339+
$this->assertEquals($imapErrors1, $imapErrors2);
340+
323341
/*
324342
$randomMailboxName1 = 'Mailbox ' . Functions::unique();
325343
$randomMailboxName2 = 'Mailbox ' . Functions::unique();

0 commit comments

Comments
 (0)