php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19715 Script re-executes instead of timing out
Submitted: 2002-10-02 08:16 UTC Modified: 2002-10-04 07:51 UTC
From: lauri dot kotilainen at unifile dot fi Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.2 OS: Linux (dist. unknown)
Private report: No CVE-ID: None
 [2002-10-02 08:16 UTC] lauri dot kotilainen at unifile dot fi
 I have a script I've used to send MIME-encoded mails. The script reads in an address file, explodes it into an array then sends a mail message to each address. I tested the script before with some 30-40 addresses and it worked fine. Then I commented out the line that sends the mail and instead printed the address to make sure the addresses are correct before sending.

 Being fairly confident I then un-commented the line, removed the print() and re-ran the script. Once.

 My browser didn't receive a reply in the next 20 minutes. I never repeated the request. However, I know the script has run at least nine times, with no loop in it that could possibly cause that.

 The effect being, that a load of people have received a lot of what they now consider spam, and are rather angry.

 So, am I looking at 
a) a bug or a feature of the browser that caused the page to be re-requested (at least nine times) 
b) a bug in php that caused a re-run instead of a timeout or 
c) my reflection in the mirror as I realise that the error has been mine?

Here's the offending script:
<?php
        error_reporting(E_ALL);
        include('htmlMimeMail.php');
        $mail = new htmlMimeMail();
        $logo = $mail->getFile('xxxx.gif');
        $fd = fopen("xxxx.txt","r");
		$rivi = '';
     	while (!feof($fd))
		{
			$rivi .= fgets($fd, 1000);
		}
       fclose ($fd);
		$sendTo = explode("\n",$rivi);
        $html = $mail->getFile('xxxx.html');
        $mail->setHtml($html);
        $mail->addHtmlImage($logo, 'xxxx.gif', 'image/gif');
		$mail->setFrom('"xxxxxx" <xxxxx@xxxxxxx.com>');
		$mail->setSubject('xxxxxxxxx');
		$mail->setHeader('X-Mailer', 'xxxxxxxx');
		$count = 0;
		foreach($sendTo as $rec)
		{ 
			$result = $mail->send(array($rec), 'mail');
			$count++;
		}
			echo "$count Mails sent!";
?>

-Lauri Kotilainen-

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-10-02 08:17 UTC] lauri dot kotilainen at unifile dot fi
Sorry about the indenting. I copy-pasted directly from Dreamweaver.
 [2002-10-02 11:18 UTC] sander@php.net
Well... I guess that's a browser problem... try wget and see what happens...
 [2002-10-03 01:32 UTC] lauri dot kotilainen at unifile dot fi
To tell you the truth, I don't know how and I need to tread carefully around this issue anyway as of now. Would it help to know that I was running Opera 6.0? and how could it be explained, that the same script ran perfectly well on the tested 40 addresses?

Basically - is a browser supposed to reissue the request when it hasn't even timed out yet?
 [2002-10-04 07:31 UTC] lauri dot kotilainen at unifile dot fi
Turns out the script never timed out properly, and Opera re-requested the page adter five minutes of waiting. The reason is still a mystery, but I gather it has to do with the sheer volume of the addresses.

-Lauri-
 [2002-10-04 07:36 UTC] iliaa@php.net
Sorry, but the bug system is not the appropriate forum for asking
support questions. Your problem does not imply a bug in PHP itself.
For a list of more appropriate places to ask for help using PHP,
please visit http://www.php.net/support.php

Thank you for your interest in PHP.

A browser issue (Opera), this is not something PHP can do anything about.
 [2002-10-04 07:42 UTC] lauri dot kotilainen at unifile dot fi
My point never was the way Opera re-requested. It was the way THE PHP SCRIPT DIDN'T TIME OUT IN THE 30 SECONDS IT WAS SUPPOSED TO. But it's not my concern anymore, in the future I will limit the number of addresses so the script will complete in 30 seconds.
 [2002-10-04 07:51 UTC] hholzgra@php.net
> "THE PHP SCRIPT DIDN'T TIME OUT IN THE 30 SECONDS IT WAS SUPPOSED TO."

max_execution_time limits the *cpu* time the process executing your PHP code *itself* uses, it does not measure 'real' time and it can't take into account cpu time used by other processes your script depends on

As your script either talks to a SMTP server directly 
or uses mail() which uses a sub-process on unix you don't
use much cpu time in your script itself while it is 
waiting for either the SMPT server or the mail() subprocess 

So it's real cpu time usage will be very low even if
it has run for some minutes.

If you want to limit real time usage you have to check
for that yourself using time()
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Aug 17 13:01:28 2024 UTC