|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-02-25 15:52 UTC] nikic@php.net
-Assigned To:
+Assigned To: girgias
[2021-02-27 13:15 UTC] girgias@php.net
[2021-02-27 13:15 UTC] girgias@php.net
-Status: Assigned
+Status: Closed
[2021-02-27 13:18 UTC] girgias@php.net
-Operating System: Linux Mint
+Operating System:
-PHP Version: 8.0.2
+PHP Version: 8.0.0
[2021-02-27 13:18 UTC] girgias@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 10:00:01 2025 UTC |
Description: ------------ Code to open a mailbox using imap_open() works fine for php 7 and earlier but fails with php 8. This is when the fourth parameter is set to CL_EXPUNGE. If any other valid flag is used, such as OP_DEBUG, then the open is successful. IMAP c-Client Version 2007f Looking at the c code for the imap extension, php 8 has some extra validation of the flags parameter. This is the line that throws the error if (flags && ((flags & ~(OP_READONLY | OP_ANONYMOUS | OP_HALFOPEN | CL_EXPUNGE | OP_DEBUG | OP_SHORTCACHE | OP_SILENT | OP_PROTOTYPE | OP_SECURE)) != 0)) { https://github.com/php/php-src/commit/25569679aae88af948ee0d28c24aa2b2d1ec5398#diff-e7d2d77c4b01ac1a055eaa7b5bb2b8bb52cc3a04dc849130078104aa90602e49R716 The use of the C constant CL_EXPUNGE looks possibly wrong. That is the value provided by the c client library, not the PHP value. The flags parameter will have the PHP constant value 32768 and it is that which should be tested. A few lines down the flags parameter is tested for PHP_EXPUNGE and then that bit is cleared. if (flags & PHP_EXPUNGE) { https://github.com/php/php-src/commit/25569679aae88af948ee0d28c24aa2b2d1ec5398#diff-e7d2d77c4b01ac1a055eaa7b5bb2b8bb52cc3a04dc849130078104aa90602e49R728 Test script: --------------- // can use any server because it doesn't get as far as connecting $link = imap_open('{imap.gmail.com:993}INBOX', 'zzzxxxx', 'asasasasa', CL_EXPUNGE); Expected result: ---------------- The mailbox should be opened and the program continue executing. Actual result: -------------- [Thu Feb 25 15:27:24.083079 2021] [php:error] [pid 22835] [client 127.0.0.1:33586] PHP Fatal error: Uncaught ValueError: imap_open(): Argument #4 ($flags) must be a bitmask of the OP_* constants, and CL_EXPUNGE in /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php:367 Stack trace: #0 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php(367): imap_open() #1 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php(497): processPop() #2 /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/index.php(752): include('...') #3 {main} thrown in /home/duncan/Development/GitHub/phplist3/public_html/lists/admin/processbounces.php on line 367, referer: http://strontian/lists/admin/?page=bouncemgt&tk=6b1ba5b4ffee3a1a0d1d550a0290cd5f