php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #33039 on shutdown: Notice: Unknown: Mailbox is empty (errflg=1) in Unknown on line 0
Submitted: 2005-05-16 08:35 UTC Modified: 2010-08-11 23:17 UTC
From: mpb dot mail at gmail dot com Assigned:
Status: Not a bug Package: IMAP related
PHP Version: 5.*, 4.* OS: *
Private report: No CVE-ID: None
 [2005-05-16 08:35 UTC] mpb dot mail at gmail dot com
Description:
------------
If you imap_open an empty pop mailbox, a "Mailbox is empty (errflg=1)" notice will be printed during PHP's "shutdown" or "cleanup" phase after your script has finished running (assuming E_NOTICE is set, of course).

As there is nothing wrong with having an empty mailbox, I believe that PHP should not print this notice.  I suspect that PHP is misinterpreting a return code from the IMAP library, or is making an unnecessary call to the IMAP library.  It is also possible that the IMAP library is buggy and should not be returning an errflg=1 (whatever that means).

If, in the reproduce code, you uncomment the final ini_set then the notice will not be printed (as E_NOTICE is no longer set during PHP's shutdown).

If you are unable to reproduce this problem with the empty POP mailbox of your choice, let me know and I will set up a POP mailbox for you to test against.

See also bug 7207.

Reproduce code:
---------------
ini_set ('error_reporting', E_ALL);

$imap = imap_open
  ( '{host.com:110/pop/novalidate-cert}INBOX',
    'user', 'password' );

trigger_error ('test notice');

sleep (5);

// ini_set ('error_reporting', E_ALL ^ E_NOTICE);


Expected result:
----------------
Notice: test notice in /root/pinstall/local/vl0/test.php on line 8


Actual result:
--------------
Notice: test notice in /root/pinstall/local/vl0/test.php on line 8

Notice: Unknown: Mailbox is empty (errflg=1) in Unknown on line 0


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-19 15:38 UTC] iliaa@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

On request termination PHP flushes all not yet reported IMAP errors at E_NOTICE error reporting level. The fact there are any is the result of the IMAP library reporting them.
 [2007-07-30 12:21 UTC] timj@php.net
I think the key point here is that imap_errors() should be called after doing the imap_open(), which would clear the error stack and stop PHP throwing E_NOTICEs.

This isn't very clear in the manual, which is arguably a doc bug.
 [2010-08-11 20:09 UTC] kiall at managedit dot ie
In my opinion ... this is an issue. "Bug" maybe not, poor implementation? Most 
certainly. 

If imap_open() generates an error. imap_open() should raise an error. 

Script termination should only raise an error, if *script termination* raises an 
error.

Really - This needs to be fixed.
 [2010-08-11 20:09 UTC] contractfrombelow at gmail dot com
I spent about two days trying to figure this problem out before I ran across this 
bug. If you turn errors into exceptions (using set_error_handler), you can run 
into some awfully hard code to debug (unknown exception on line 0). There's no 
reason it should generate a warning in an invisible shutdown handler. I know 
that's how it works now, but that doesn't mean it can't change to a more logical 
way.
 [2010-08-11 23:17 UTC] jani@php.net
-Assigned To: sniper +Assigned To:
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sun Jun 20 03:01:23 2021 UTC