From:             rixsta at hotmail dot com
Operating system: Cent OS
PHP version:      Irrelevant
Package:          IMAP related
Bug Type:         Bug
Bug description:imap_search has a bug

Description:
------------
---
>From manual page: http://www.php.net/function.imap-search#refsect1-
function.imap-search-description
---

The following example should highlight this bug clearly:
$newCount = count(imap_search($imap_stream, 'UNSEEN'));

We use the function above to count the number of 'UNSEEN' messages in the 
mailbox folders. It works fine until we have read all messages and in this
case 
we would expect the $newCount to be 0. However it remains at 1!  We have
been 
able to work around this bug with the following fix/function (see test
script)



This returns the count as we would expect.  If you do address this bug we
would 
appreciate a quick email and advise on the version of PHP it will be
included 
in.

Many thanks.

Test script:
---------------
$newCount = $this->count_unread_email($imap_stream);

  function count_unread_email($imap_stream) {
      $count = 0;
      if (!$imap_stream) {
          echo "Error";
      } else {
          $headers = imap_headers($imap_stream);
          foreach ($headers as $mail) {
              $flags = substr($mail, 0, 4);
              $isunr = (strpos($flags, "U") !== false);
              if ($isunr)
              $count++;
          }
      }
      return $count;
  }

Expected result:
----------------
We expect the function to return 0 when there are no remaining 'UNSEEN'
messages, 
not 1.

Actual result:
--------------
We receive a 1 even though there are 0 'UNSEEN' messages remaining in our
mailbox 
folder.

-- 
Edit bug report at https://bugs.php.net/bug.php?id=64271&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64271&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64271&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64271&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64271&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64271&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64271&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64271&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64271&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64271&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64271&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64271&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64271&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64271&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64271&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64271&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64271&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64271&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64271&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64271&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64271&r=mysqlcfg

Reply via email to