Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.0.0b4

Bug #4332 problem when using 2 instance of HTTP_Upload & 2 files
Submitted: 2005-05-12 07:37 UTC
From: shordeaux at waterproof dot fr Assigned: wenz
Status: Closed Package: HTTP_Upload
PHP Version: 4.3.11 OS: WinXP
Roadmaps: (Not assigned)    
Subscription  


 [2005-05-12 07:37 UTC] shordeaux at waterproof dot fr
Description: ------------ If I have a form with 2 upload fields, and if I create 2 instances of HTTP_Upload then the second one wil not work due to the usage of the static variable is_built which is used to cache the internal initialisation of the files array, here: http://cvs.php.net/co.php/pear/HTTP_Upload/Upload.php?r=1.49#375 If the variable is changed from static variable into private property for example everything works fine. This means: 1. adding var $_IsBuilt = FALSE; 2. Removing line 375 3. Changing line 377 and 390 to use the property instead of the sattic variable. Another more efficient solution would be to store the array itself as static instead of the is_built property. ie. initializing it to NULL, then if the variable is NULL the array need to be computed, elsewhere it's done. Reproduce code: --------------- 1 form + 2 upload field & 2 instance of HTTP_Upload one for each file Expected result: ---------------- that all files are returned by the instance instead Actual result: -------------- second file is returned as NULL instead

Comments

 [2005-06-03 19:24 UTC] antonio
Can you please send us a diff with this changes?
 [2005-07-07 07:51 UTC] shordeaux at waterproof dot fr
This is the diff against version 1.42: Comparer : (<)C:\Documents and Settings\Sébastien Hordeaux\Bureau\Upload-2.php (31055 octets) avec : (>)C:\Documents and Settings\Sébastien Hordeaux\Bureau\Upload.php (31919 octets) 315a315,316 > var $__isBuilt = false; > 331,333c333,334 < static $is_built = false; < //build only once for multiple calls < if (!$is_built) { --- > //build only once for multiple calls > if (!$this->__isBuilt) { 346c347 < $is_built = true; --- > $this->__isBuilt = true;
 [2005-09-30 16:26 UTC] rlwixson at thoughtprocess dot net
I experienced the same problem, HTTP_Upload 0.9.1. I had a form with an image upload and pdf upload, each needed to be handled differently, so I was against using single function to handle both files. I applied the suggested fix (thanks shordeaux) and it worked well. It took 5 minutes to do; I see no reason why this bug cannot be fixed and closed.
 [2005-10-10 13:04 UTC] wenz
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. fix is good, applied it with only cosmetic changes in CVS. Does it work for you? Thanks for the patience ...
 [2006-01-06 18:02 UTC] glamm at a-s-i dot com
When is the next package release of HTTP_Upload? I'd like to have my hosting provider download this fix and make it easy on them by just having them 'pear upgrade HTTP_Upload'.