@@ -735,7 +735,11 @@ PHP_FUNCTION(imap_open)
735735 RETURN_THROWS ();
736736 }
737737
738- if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | CL_EXPUNGE | OP_DEBUG | OP_SHORTCACHE
738+ /* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
739+ * to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
740+ * the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
741+ * IMAPConnection object being destroyed naturally at the end of the PHP script */
742+ if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | PHP_EXPUNGE | OP_DEBUG | OP_SHORTCACHE
739743 | OP_SILENT | OP_PROTOTYPE | OP_SECURE )) != 0 )) {
740744 zend_argument_value_error (4 , "must be a bitmask of the OP_* constants, and CL_EXPUNGE" );
741745 RETURN_THROWS ();
@@ -858,7 +862,11 @@ PHP_FUNCTION(imap_reopen)
858862 }
859863
860864 /* TODO Verify these are the only options available as they are pulled from the php.net documentation */
861- if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | CL_EXPUNGE )) != 0 )) {
865+ /* Check for PHP_EXPUNGE and not CL_EXPUNGE as the user land facing CL_EXPUNGE constant is defined
866+ * to something different to prevent clashes between CL_EXPUNGE and an OP_* constant allowing setting
867+ * the CL_EXPUNGE flag which will expunge when the mailbox is closed (be that manually, or via the
868+ * IMAPConnection object being destroyed naturally at the end of the PHP script */
869+ if (options && ((options & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | OP_EXPUNGE | PHP_EXPUNGE )) != 0 )) {
862870 zend_argument_value_error (3 , "must be a bitmask of OP_READONLY, OP_ANONYMOUS, OP_HALFOPEN, "
863871 "OP_EXPUNGE, and CL_EXPUNGE" );
864872 RETURN_THROWS ();
0 commit comments