Re: Bug #10850 imap_uid() does not produce an Unique ID Number from POP Servers

From: Date: Tue, 15 May 2001 16:30:35 +0000
Subject: Re: Bug #10850 imap_uid() does not produce an Unique ID Number from POP Servers
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-55348@lists.php.net to get a copy of this message
UID's will be unique for IMAP, not POP servers. At least, as far as I remember, c-client will return a numer (a long, if I am not mistaken); that is the UID you get. 3afffb5300000001 is not gonna fit in there. I do not think you can get much more. If there is a capability in POP3 part of c-client to return the unique numbers you want, please point me to that part, and I'll implement it. Vlad Mattias Segerdahl wrote:
Hi Mark, I was doing some php coding the other day and did something simular as, The following code should echo out the Unique ID's generated by UIDL on the IMAP/POP Server, but echo's out a sequencial number starting with 1 instead... It should probably produce ID's like, 3afffb5300000001, 3afffb5300000002, etc. etc. $mbox = imap_open ("{your.pop3.host:143}", "username", "password"); $headers = imap_headers ($mbox); if ($headers == true) { while (list ($key,$val) = each ($headers)) { echo imap_uid($mbox, $key); } } else { echo "No messages in inbox"; } Since this was producing a sequencual number ("1,2,3,4,5"), same as the message number, I though there was a bug in php, so I checked the ext/imap/php_imap.c and found the following code, /* {{{ proto int imap_uid(int stream_id, int msg_no) Get the unique message id associated with a standard sequential message number */ PHP_FUNCTION(imap_uid) {
        zval **streamind, **msgno;
        int ind, ind_type, msgindex;
        pils *imap_le_struct;
        if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &streamind,
&msgno) == FAILURE) {
                ZEND_WRONG_PARAM_COUNT();
        }
        convert_to_long_ex(streamind);
        convert_to_long_ex(msgno);
        ind = Z_LVAL_PP(streamind);
        imap_le_struct = (pils *) zend_list_find(ind, &ind_type);
        if (!imap_le_struct || !IS_STREAM(ind_type)) {
                php_error(E_WARNING, "Unable to find stream pointer");
                RETURN_FALSE;
        }
        msgindex = Z_LVAL_PP(msgno);
        if ((msgindex < 1) || ((unsigned) msgindex >
imap_le_struct->imap_stream->nmsgs)) {
                php_error(E_WARNING, "Bad message number");
                RETURN_FALSE;
        }
        RETURN_LONG(mail_uid(imap_le_struct->imap_stream,
Z_LVAL_PP(msgno))); } /* }}} */ When reading this code, it still baffles me that I don't get the correct UID's, the UIDL produces, I came to the fact that it must be the c-client.. The bug seems to be in src/c-client/mail.h line 1364 ... mail_uid returns an unsigned long // Mattias


« previous php.dev (#55348) next »