From: tomator at poczta dot onet dot pl
Operating system: WinXP pro
PHP version: 5.0.3
PHP Bug Type: Session related
Bug description: Unsetting $_SESSION variables seems to restart script
Description:
------------
I've made a small application that searches given website, gathers links,
follows them and collects informations about file sizes. Becouse it's time
consuming, for bigger sites my page is being reloaded few times. All needed
data are stored in and restored from $_SESSION. Everything works fine if
website is small enough to count it in one step. If not, instead of final
summary page I was getting a start page! I found, that it was caused by
destroyed session variables. But they were to be destroyed at the end,
where I include this file and after the results should have been
displayed. See attached code...
This is the only place where I use unset. When these lines are commented,
I can see a data presentation. But then I can't go back to initial page
(becouse of still existing session vars).
When unset were not commented, and I put exit() before them, the results
were visible.
So I think that after unsetting session vars script runs again from
begining and looses any informations stored already in output buffer.
Well, it seems it is. I put flush() before unsets and made it working
almost well.
I'm using WinXP Pro, PHP 5.0.3, Apache 2.0.43 (as service), P4 HT
It may be Apache related issue as I found it working on another server
with PHP 5.0.3 and server software IPL (iPlanet?) and not working on
another one with Linux - but don't know if it has an Apache and what
version.
Reproduce code:
---------------
<?php
$files=$_SESSION['files'];
$total=count($files);
$done=$_SESSION['fid'];
$sum=0;
foreach ($files as $file)
{
if ($file['size']>0) $sum+=$file['size'];
}
?>
<TABLE><!--here some result presentation--></TABLE>
<?php
unset ($_SESSION['files']);
unset ($_SESSION['filter']);
unset ($_SESSION['presentFiles']);
unset ($_SESSION['fid']);
unset ($_SESSION['url']);
unset ($_SESSION['progress']);
?>
Expected result:
----------------
A table should be wisible with results of counting that was done in
foreach loop.
Actual result:
--------------
If unset ($_SESSION['progress']) is enabled, I'm getting initial page,
like when entering first time.
If unset ($_SESSION['progress']) is disabled, application remembers what
should it display, but I'm getting messages about wrong indexes (files,
fid) and bad parameter of foreach.
If all unsets are disabled, results are fine, but application can't return
to it's initial state to take new job.
--
Edit bug report at http://bugs.php.net/?id=33939&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=33939&r=trysnapshot4
Try a CVS snapshot (php5.0):
http://bugs.php.net/fix.php?id=33939&r=trysnapshot50
Try a CVS snapshot (php5.1):
http://bugs.php.net/fix.php?id=33939&r=trysnapshot51
Fixed in CVS: http://bugs.php.net/fix.php?id=33939&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=33939&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=33939&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=33939&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=33939&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=33939&r=support
Expected behavior: http://bugs.php.net/fix.php?id=33939&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=33939&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=33939&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=33939&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=33939&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=33939&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=33939&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=33939&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=33939&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=33939&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=33939&r=mysqlcfg