From: George Peter Banyard Date: Sat, 27 Feb 2021 13:14:23 +0000 (+0000) Subject: Merge branch 'PHP-8.0' X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfd3fda0f4d25dc70580ebcd193ef3b141524b62;p=php Merge branch 'PHP-8.0' * PHP-8.0: Fix Bug #80800 imap_open() fails when the flags parameter includes CL_EXPUNGE --- bfd3fda0f4d25dc70580ebcd193ef3b141524b62 diff --cc ext/imap/php_imap.c index e62d6f7b2a,9ff1ae0618..9a1ded643b --- a/ext/imap/php_imap.c +++ b/ext/imap/php_imap.c @@@ -898,10 -857,16 +902,14 @@@ PHP_FUNCTION(imap_reopen RETURN_THROWS(); } - if ((imap_le_struct = (pils *)zend_fetch_resource(Z_RES_P(streamind), "imap", le_imap)) == NULL) { - RETURN_THROWS(); - } + GET_IMAP_STREAM(imap_conn_struct, imap_conn_obj); /* TODO Verify these are the only options available as they are pulled from the php.net documentation */ - if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | CL_EXPUNGE)) != 0)) { + /* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined + * to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting + * the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the + * IMAPConnection object being destroyed naturally at the end of the PHP script */ + if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | PHP_EXPUNGE)) != 0)) { zend_argument_value_error(3, "must be a bitmask of OP_READONLY, OP_ANONYMOUS, OP_HALFOPEN, " "OP_EXPUNGE, and CL_EXPUNGE"); RETURN_THROWS();