PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » HTTP » HTTP_Upload » Bug #4332

problem when using 2 instance of HTTP_Upload & 2 files

Details

Submitted2005-05-12 07:37 UTC
Fromshordeaux at waterproof dot fr
Assignedwenz
StatusClosed
PackageHTTP_Upload
PHP Version4.3.11
OSWinXP
Roadmaps(Not assigned)

Comments

[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

[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.

[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'.