ID: 41672
User updated by: mfshop at comcast dot net
Reported By: mfshop at comcast dot net
Status: Open
Bug Type: Unknown/Other Function
Operating System: Windows 2003 Server
PHP Version: 4CVS-2007-06-12 (snap)
New Comment:
As a quick addendum. If I set the loop size in the above example code
to 60 then the results are the same except that the final line reads as
I would expact: "Final: 1, 1". Note that this seems to be related to
time and not the amount of data sent as keeping the loop count at 20 but
attempting to echo out a lot more text to the browser repeats the
original results. This seems to indicate that connection_status() and
connection_aborted() at least return the proper values when called
within a registered shutdown function AND enough time has passed.
However, the functions still return 0 outside of the shutdown function
and setting ignore_user_abort() one way or another has no effect. In
other words, the functions still can't be used to detect a browser abort
and stop execution of the script at that point (after performing any
required cleanup in the registered shutdown function).
Previous Comments:
------------------------------------------------------------------------
[2007-06-12 19:58:42] mfshop at comcast dot net
Description:
------------
Running IIS6 on Windows 2003 Server and the latest PHP 4.4.8-dev from
snaps.php.net. The problem also exists on PHP 4.4.7. Running as an
ISAPI module.
connection_status() and connection_abort() always return 0. Setting
ignore_user_abort(true) or ignore_user_abort(false) also seems to have
no effect. In the example script below, changing
ignore_user_abort(true) to ignore_user_abort(false) produces the exact
same results.
This seems to be similar or the same as Bug #30301 but for a PHP 4
instead (also that bug report seems to have been ignored/closed due to
no feedback status).
Reproduce code:
---------------
function script_end()
{
global $fd;
$clientstate = connection_aborted();
$clientstate2 = connection_status();
fwrite($fd, "Final: $clientstate, $clientstate2\n");
fclose($fd);
exit();
}
$fd=fopen("test.txt", "w"); // Change filename/dir to somewhere where
the IIS User has proper permissions as necessary.
register_shutdown_function("script_end");
ignore_user_abort(true);
for ($i=0; $i<20; $i++) {
echo "$i<br>\n";
Flush();
$clientstate = connection_aborted();
$clientstate2 = connection_status();
fwrite($fd, "$i: $clientstate, $clientstate2\n");
sleep(1);
}
Expected result:
----------------
Start loading the page and then hit the stop button before it finishes.
Look at the test.txt afterwards. We expect to see the values returned
by connection_aborted() and connection_status() to change/be something
other than 0 or, depending on how ignore_user_abort() is set, we may
expect to see the count not reach 20 (i.e. the script detecting user
abort and terminating the script).
Actual result:
--------------
The test.txt file will always end up looking like so:
0: 0, 0
1: 0, 0
2: 0, 0
3: 0, 0
4: 0, 0
5: 0, 0
6: 0, 0
7: 0, 0
8: 0, 0
9: 0, 0
10: 0, 0
11: 0, 0
12: 0, 0
13: 0, 0
14: 0, 0
15: 0, 0
16: 0, 0
17: 0, 0
18: 0, 0
19: 0, 0
Final: 0, 0
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41672&edit=1