php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #48429 example for ignore_user_abort() is not working
Submitted: 2009-05-29 14:01 UTC Modified: 2009-11-16 13:41 UTC
Votes:3
Avg. Score:4.3 ± 0.9
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:0 (0.0%)
From: carsten_sttgt at gmx dot de Assigned:
Status: Wont fix Package: Documentation problem
PHP Version: Irrelevant OS: Windows_NT; FreeBSD
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: carsten_sttgt at gmx dot de
New email:
PHP Version: OS:

 

 [2009-05-29 14:01 UTC] carsten_sttgt at gmx dot de
Description:
------------
Hello,

I think the description for the "Connection Handling" and detecting the connection status must be better explained.

The example for ignore_user_abort is also not working for me (the break was never triggered in my tests) and should be changed to a working one (and the server setup you must have for the example must be explained).

My test environment is Apache 2.2.11 Windows XP/FreeBSD7.2 and PHP 5.2.9 (module, cgi and fastcgi (mod_fgcid))

Then I have test, if the script really is terminated, if the user is dropping the connection. Following the notes to flush, I'm using ob_flush and flush() after the echo.

Im accessing the script in the shell with:
$ lwp-request -t 2 http://localhost/abort.php

So the client is disconnecting after 2 second. You can also use telnet or your browser.


With Script 1, and reading the manual at [1] and [2], I was surprised, that the file 'abort.txt' was created. Even ignore_user_abort is false and the connection was dropped after 2 sec.

So I have enhanced the script with a loop (Script 2) and have played with the variable $loop:
- If I setup PHP as module, I need ~3 additional echo/flush's
  till the script is terminated
- If I setup PHP as CGI, I need ~40-80 (not always the same in
  each test) additional echo/flush's till the script is terminated
- If I setup PHP as FastCGI, the script was never terminated.
  (have test values 1-1000)

Well, so for me, you can't really trust the connection status. And if someone reads the manual, he must think:
"Hey, if ignore_user_abort is false (PHP default), the script is terminated if the connection is dropped."
But many times that's not true.

Regards,
Carsten


[1] http://de.php.net/manual/en/function.ignore-user-abort.php
[2] http://de.php.net/manual/en/features.connection-handling.php


Reproduce code:
---------------
Script 1:
---------

<?php
set_time_limit(0);
ignore_user_abort(false);
@unlink('abort.txt');

sleep(10);
echo ' ';
ob_flush();
flush();

file_put_contents('abort.txt', connection_status());
exit;
?>

Script 2:
---------

<?php
set_time_limit(0);
ignore_user_abort(false);
@unlink('abort.txt');

sleep(10);
echo ' ';
ob_flush();
flush();

$loops = 3;

for ($x = 1; $x <= $loops; $x++) {
    echo ' ';
    ob_flush();
    flush();
}

file_put_contents('abort.txt', connection_status());
exit;
?>



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-16 13:41 UTC] vrana@php.net
The script will terminate but not necessarily immediately.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Mar 14 08:01:32 2025 UTC