#49425 [Opn]: imap_reopen() returns TRUE instead FALSE called with nonexistant mailbox

From: Date: Mon, 31 Aug 2009 19:24:37 +0000
Subject: #49425 [Opn]: imap_reopen() returns TRUE instead FALSE called with nonexistant mailbox
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-2701@lists.php.net to get a copy of this message
ID: 49425 Updated by: jani@php.net Reported By: jake dot levitt at mailtrust dot com Status: Open -Bug Type: IMAP related +Bug Type: Documentation problem Operating System: CentOS 5 PHP Version: 5.3.0 New Comment: Call to imap_reopen() with invalid mailbox does not close the already opened stream. mail_open() will not return NIL in such case, just sets the error and returns the original stream with the originally opened mailbox. As such, this is not a bug but undocumented "feature" of this function and should be documented on the imap_reopen() page. Previous Comments: ------------------------------------------------------------------------ [2009-08-31 16:41:22] jake dot levitt at mailtrust dot com Description: ------------ When calling imap_reopen() on a folder that doesn't exist, the function returns true instead of the expected result of false. It seems this was reported back in 2002 but marked as bogus (http://bugs.php.net/bug.php?id=15197). I have reproduced this bug in the most recent version of php. Reproduce code: --------------- <?php $flags = '/novalidate-cert'; $host = 'imap.server.example.com:143'; $username = 'test.user@example.com'; $password = 'password'; $folder = 'INBOX'; $base_imap_string = '{' . $host . $flags . '}'; $connect_string = $base_imap_string . $folder; $mailbox = imap_open($connect_string, $username, $password, 0, 3); $connect_string = $base_imap_string . $folder . '.No such critter'; $reopen_success = imap_reopen($mailbox, $connect_string, 0, 3); $error_message = imap_last_error(); if (!$mailbox) { exit(0); } if ($reopen_success) { echo "Reopen SUCCEEDED and error message is: $error_message\n"; } else { echo "Reopen FAILED and error message is: $error_message\n"; } Expected result: ---------------- Output: Reopen FAILED and error message is: Mailbox doesn't exist: No such critter Actual result: -------------- Output: Reopen SUCCEEDED and error message is: Mailbox doesn't exist: No such critter ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49425&edit=1

« previous php.doc.bugs (#2701) next »