#20871 [Fbk->Opn]: Apache restarts with no output

From: Date: Sun, 26 Jan 2003 18:34:11 +0000
Subject: #20871 [Fbk->Opn]: Apache restarts with no output
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-31280@lists.php.net to get a copy of this message
ID: 20871 User updated by: ctocopok@fond-darina.ru Reported By: ctocopok@fond-darina.ru -Status: Feedback +Status: Open Bug Type: IMAP related Operating System: win2K PHP Version: 4.3.0-dev New Comment: Yes. The crash happens with any e-mail. Does not depend on the e-mail encoding or charset or whatever. It happens, I suppose, in imap_fetchbody, the function I use to get the raw e-mail headers (the used to fall into section #0 of the e-mail body, no matter if mail had any parts). As to the script - the PHP-file I use to test the bug is constantly growing as I add more debug output to find the exact point where the 'crash' occurs. As to the servers - there are many if them. WinRoute's internal pop3 server (my local), and some other servers on the net (mail.ru, goals.ru, valuehost.ru) - these are the servers I tried. Local testing reports that the mails get transferred to PHP. Even twice (so if the mailbox occupies 100Kbytes of mail for user, the total session traffic would be 200K). Here is the script I use now (still crashiong with fetchbody): <? ini_set("display_startup_errors","1"); $f=fopen('log','w+'); $enc[0]="7BIT"; $enc[]="8BIT"; $enc[]="BINARY"; $enc[]="BASE64"; $enc[]="QUOTED-PRINTABLE"; $enc[]="OTHER"; $port="110"; $server="localhost"; $uname="test"; $passw="1234"; //phpinfo(); function desc_arr($arr,$prefix) { global $f; foreach($arr as $key=>$value) { echo "$prefix [$key] = $value <br>"; fputs($f, "$prefix [$key] = $value <br>\n"); if (is_array($value))desc_arr($value, "$prefix [$key]"); if (is_object($value))desc_obj($value,"$prefix [$key]"); } } function desc_obj($obj, $prefix) { global $f; foreach($obj as $key=>$value) { echo "$prefix -> $key = $value <br>"; fputs($f, "$prefix -> $key = $value <br>\n"); if (is_array($value))desc_arr($value, "$prefix -> $key"); if (is_object($value))desc_obj($value,"$prefix -> $key"); } } fputs($f, "connecting to $server<br>\n"); echo "connecting to $server<br>"; $mbox = imap_open ("{".$server.":".$port."/pop3}INBOX", "$uname", "$passw"); echo imap_last_error()."<br>"; fputs($f,imap_last_error()."<br>\n"); echo "Retrieving messages...<br>"; fputs($f, "Retrieving messages...<br>"); $totmsg=imap_num_msg($mbox); $check = imap_mailboxmsginfo($mbox); if($check) { print "Date: " . $check->Date ."<br>\n" ; fputs($f, "Date: " . $check->Date ."<br>\n" ); print "Driver: " . $check->Driver ."<br>\n" ; print "Mailbox: " . $check->Mailbox ."<br>\n" ; print "Messages: ". $check->Nmsgs ."<br>\n" ; print "Recent: " . $check->Recent ."<br>\n" ; print "Unread: " . $check->Unread ."<br>\n" ; print "Deleted: " . $check->Deleted ."<br>\n" ; print "Size: " . $check->Size ."<br>\n" ; } else { print "imap_check() failed: ".imap_last_error(). "<br>\n"; fputs($f,"imap_check() failed: ".imap_last_error(). "<br>\n"); } if ($totmsg>0) {echo "some messages found<br>";fputs($f,"some messages found<br>\n");} if ($totmsg>0) echo "some messages found<br>"; if ($totmsg>0) echo "some messages found line 3<br>"; $headers=imap_search($mbox, "FROM @", 0);// if (is_array($headers)) {echo "Total messages found: ".count($headers)."/$totmsg<br>"; fputs($f,"Total messages found: ".count($headers)."/$totmsg<br>\n"); desc_arr($headers, "headers"); } while (list ($key,$val) = each ($headers)) { unset($hdr); $hdr=imap_headerinfo($mbox, ($val)); desc_obj($hdr, "HDR:"); echo "Plaintext is:<br><code>".nl2br(imap_body($mbox, ($val)))."</code><br>"; fputs($f,"Plaintext is:<br><code>".nl2br(imap_body($mbox, ($val)))."</code><br>\n"); echo "<hr>...Fetching structure<br>"; fputs($f,"<hr>...Fetching structure<br>\n"); unset($struc); $struc=imap_fetchstructure($mbox,($val)); echo "struc assigned<br>"; fputs($f, "struc assigned\n"); desc_obj($struc, "structure"); if (isset($struc->parts)) //There are some parts { echo "<b>there are ".count($struc->parts)." parts in the message</b><br>"; fputs($f, "<b>there are ".count($struc->parts)." parts in the message</b><br>\n"); foreach($struc->parts as $num=>$part) { echo "foreach struc-parts started<br>"; fputs($f, "foreach struc-parts started<br>\n"); echo "Part $num<br>"; fputs ($f, "Part $num<br>\n"); if ($part->subtype=='PLAIN') { echo "part subtype=PLAIN<br>"; fputs($f, "part subtype=PLAIN<br>\n"); $msg=imap_fetchbody($mbox,$key, $num); // ***CRASH *** // echo "The text is ".nl2br($msg)." <br>"; fputs($f,"The text is ".nl2br($msg)." <br>\n"); } $filename=""; if ($part->ifdisposition==1) { echo "Part $num has disposition $part->disposition<br>"; fputs($f, "Part $num has disposition $part->disposition<br>\n"); if ($part->ifdparameters==1) { echo "there are Dparameters for it<br>"; fputs($f, "there are Dparameters for it<br>\n"); foreach ($part->dparameters as $dpname=>$dpval) { if ($dpval->attribute=="FILENAME"){ echo "Filename is ".($filename=$dpval->value)."<br>"; fputs($f, "Filename is ".($filename=$dpval->value)."<br>\n"); } } } } } } else { echo "<b>Seems this message has the only part</b>:<br><code>".imap_body($mbox, ($val))."</code><br>"; fputs($f, "<b>Seems this message has the only part</b>:<br><code>".imap_body($mbox, ($val))."</code><br>\n"); } echo "<hr>Body:<br>".imap_body($mbox, ($val))."<br><hr>"; fputs($f, "<hr>Body:<br>".imap_body($mbox, ($val))."<br><hr>\n"); echo "Part0 if exists:<br>"; fputs($f, "Part0 if exists:<br>\n"); echo "Key: $key, val: $val<br>"; $alerts=imap_alerts(); if(is_array($alerts))echo "Here we have alerts:<br>".desc_arr($alerts," ALRT:"); echo "Alerts:".$alerts; echo "lalala".imap_fetchheader($mbox,$key+1); // fputs($f, "\nlalala".imap_fetchbody($mbox,$key, 0)); //commented out because of crash } imap_close($mbox); ?> Previous Comments: ------------------------------------------------------------------------ [2003-01-18 01:11:18] sniper@php.net Does the crash happen with any email you're trying to get? And please add short example script here too and information about the imap/pop3 server you're connecting to. (Version, etc.) ------------------------------------------------------------------------ [2002-12-23 09:03:21] ctocopok@fond-darina.ru imap_fetchbody() fails. I had to add some code to the script to make it write all it's output to some file on disk (i simply cloned "echo" with "fputs"). Now it seems that the imap_fetchbody() function makes apache restart (and PHP - to crash). Sorry for previous mishinting. ------------------------------------------------------------------------ [2002-12-19 16:37:35] ctocopok@fond-darina.ru Sorry for bothering. Any good news on the subject? ------------------------------------------------------------------------ [2002-12-11 05:48:21] ctocopok@fond-darina.ru <? $port="110"; $server="localhost"; $uname="test"; $passw="1234"; phpinfo(); //to start the output $mbox = imap_open ("{".$server.":".$port."/pop3}INBOX", "$uname", "$passw"); echo imap_last_error()."<br>"; $totmsg=imap_num_msg($mbox); //still works if ($totmsg>0) echo "some messages found<br>"; $headers=imap_search($mbox, "FROM @", 0);//fails $headers=imap_headers($mbox);//fails //any of above would 'crash'. if (is_array($headers))echo "Total messages found: ".count($headers)."/$totmsg<br>"; ?> ------------------------------------------------------------------------ [2002-12-11 05:14:11] sniper@php.net Please provide a short, complete and self-contained example script which can be used to reproduce this. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/20871 -- Edit this bug report at http://bugs.php.net/?id=20871&edit=1

« previous php.bugs (#31280) next »