Bug #78158 [Opn]: imap_open does not respect OP_DEBUG or /debug
| From: | cmb@php.net | Date: | Wed, 14 Oct 2020 13:50:58 +0000 |
| Subject: | Bug #78158 [Opn]: imap_open does not respect OP_DEBUG or /debug | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-229618@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78158&edit=1
ID: 78158
Updated by: cmb@php.net
Reported by: marco@php.net
Summary: imap_open does not respect OP_DEBUG or /debug
Status: Open
Type: Bug
Package: IMAP related
Operating System: OS X 10.14
PHP Version: 7.3.6
Block user comment: N
Private report: N
New Comment:
> I propose extending the imap extension API to include a function
> "imap_debug_callback" accepting a userland function with a single
> string parameter.
That seems to be reasonable. A pull request would be welcome!
Previous Comments:
------------------------------------------------------------------------
[2019-06-13 14:45:42] marco@php.net
The actual root cause is that c-client, the library behind the imap extension, uses a callback
("mm_dlog") to pass the connection debug log to the application.
mm_dlog is defined in ext/imap/php_imap.c:5077 (in current master) and is a no-op at the moment. I
propose extending the imap extension API to include a function "imap_debug_callback"
accepting a userland function with a single string parameter. Now, when mm_dlog gets called, the
imap extension checks if a callback has been registered; if not a E_WARNING gets raised (text e.g.
"IMAP mm_dlog got called without registering a callback in imap_debug_callback before"),
if yes the callback gets called.
This way, simple applications can have the callback simple ("function xxx($line) { echo
$line."\n"; }"), while more complex applications such as the php-imap shim and its
Symfony wrapper secit-pl/imap-bundle can use the PSR logging mechanisms.
------------------------------------------------------------------------
[2019-06-13 14:38:02] marco@php.net
Description:
------------
When calling imap_open with either OP_DEBUG as flag or by specifying /debug in the mailbox string,
there is no debug output.
This is especially bad when trying to troubleshoot situations like Exchange servers accessed over
SSL as the connection cannot be monitored by Wireshark or other monitors without significant effort.
Test script:
---------------
<?php
$handle=imap_open('{imap.example.net:993/imap/ssl/novalidate-cert/debug}INBOX','user','pass');
Expected result:
----------------
Expecting on stdout (or in a callback) the communication to/from the IMAP server.
Actual result:
--------------
Only the error message (e.g. "AUTHENTICATE failed") is visible via imap_error.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78158&edit=1