@@ -782,7 +782,11 @@ PHP_FUNCTION(imap_open)
782782 RETURN_THROWS ();
783783 }
784784
785- if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | CL_EXPUNGE | OP_DEBUG | OP_SHORTCACHE
785+ /* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
786+ * to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
787+ * the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
788+ * IMAPConnection object being destroyed naturally at the end of the PHP script */
789+ if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | PHP_EXPUNGE | OP_DEBUG | OP_SHORTCACHE
786790 | OP_SILENT | OP_PROTOTYPE | OP_SECURE )) != 0 )) {
787791 zend_argument_value_error (4 , "must be a bitmask of the OP_* constants, and CL_EXPUNGE" );
788792 RETURN_THROWS ();
@@ -901,7 +905,11 @@ PHP_FUNCTION(imap_reopen)
901905 GET_IMAP_STREAM (imap_conn_struct , imap_conn_obj );
902906
903907 /* TODO Verify these are the only options available as they are pulled from the php.net documentation */
904- if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | CL_EXPUNGE )) != 0 )) {
908+ /* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
909+ * to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
910+ * the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
911+ * IMAPConnection object being destroyed naturally at the end of the PHP script */
912+ if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | PHP_EXPUNGE )) != 0 )) {
905913 zend_argument_value_error (3 , "must be a bitmask of OP_READONLY, OP_ANONYMOUS, OP_HALFOPEN, "
906914 "OP_EXPUNGE, and CL_EXPUNGE" );
907915 RETURN_THROWS ();
0 commit comments