|
From: Mitra <mit...@ea...> - 2003-03-06 03:25:20
|
OK
Thanks for the explanations. Two points.
OK - I agree that it would be better to store the same URL twice in
the case of no resampling required. However there was no way in your
code to distinguish between the case of NO-SAMPLING-REQUIRED and the
case of SAMPLING-REQUIRED-BUT-NOT-POSSIBLE.
Ok - so that $thumbnails code isn't wrong, its just very ugly !
Having spent a lot of time trying to figure out this code it looked
like a bug to me, especially since I'd already found one bug like
this in the same file (the use of $f) if you are going to do
something as ugly as this then it at least needs a comment. I've
added one ...
I've committed my changes to CVS - which are working on this system,
including several cases where the original code failed, and lots of
debugging to help figure out what is going on (set $debugupload=1 to
test, but note it will exit on failure if debugupload is set - as
otherwise the error message is lost in the redirect ).
- Mitra
At 7:13 PM +0100 5/3/03, Norbert Brazda wrote:
>Hi Mitra,
>
>I will try to do English translation for Stano:
>
>
>> > it would have been useful if you had answered my other points as
>> > well, I have made quite a number of fixes in that code, fixes to real
>> > problems that I hit. These are fixes that I'd like to commit to CVS
>> > so that I can use them on other installations. The main change is to
>> > the behavior when it cannot or does not need to do a resample. I have
>> > ResampleImage to the copy in those cases, this change allowed me to
>> > fix a number of bugs that I found with different situations.
>
>Stano thinks that you changes should be OK but he did not have time
>to test it. There is just one comment: There is no need to make
>multiple copies of the same image file (in case of no need for
>resampling) as it should be enough to store just reference (URL) to
>that file in respective field(s) which is current logic.
>
>
>> > Also - that second item IS a bug, $thumbnails is NOT defined in the
>> > CVS version in function Store_Item, it doesn't matter what you are
>> > doing to it IF IT IS NOT DEFINED!
>
>
>
>// POINT1
>
>if ($fnc["fnc"]=="fil")
> {
>// POINT2
> if (is_array($thumbnails)) {
> reset($thumbnails);
> while(list(,$v_stop) = each($thumbnails))
> if ($v_stop==$fid) $stop=true;
> };
>// POINT3
> if (!$stop)
> $thumbnails = $fncname($id, $f, $v,
>$fncpar["param"], $fields);
>
> // newly added = we reset $stop variable back to false:
> $stop=false;
>
> }
>// POINT4
> else
> $fncname($id, $f, $v, $fncpar["param"]);
>
>
>
>Here is the logic (correct me if I am wrong):
>
>--- first loop ---
>
>* if you fill-in file upload field on input form, the first
>condition (POINT1) is met
>
>* $thumbnails is not yet defined (POINT2) so we continue with next condition
>
>* $stop is not defined so the condition (POINT3) is met and we
>execute $fncname function
>
> * if there are no thumbnail fields defined in parameters to the
>current field,
> image is uploaded, $thumbnails is set empty
>
> * if there is one or more thumbnail fields defined in parameters
>to the current
> field, image is resized according to parameters in these
>fields and URLs to
> the resized images are stored in respective fields;
>$thumbnails array is filled
> by IDs of those fields we filled (WE WILL CONTINUE WITH THIS OPTION)
>
>--- next loop ---
>
>we are processing some other field from the input form
>field is of type input text, so the first condition (POINT1) is not
>met, we continue with normal processing (POINT4)
>
>--- next loop ---
>
>* there is another file upload field so we go to process it (POINT1)
>
>* thumbnails is already set from the first loop so we process it (POINT2)
>
> * we go through array and compare current field ID ($fid) with
>image fields that we have
> already filled in the first loop. If it is equal, we set
>$stop to true.
>
> * $stop is true so we skip this condition (POINT3) -field is
>already filled, so we do not want to
> execute $fncname()
>
> * we already used $stop variable co we can set it back to false
>
>--- next loop ---
>
>etc...
>
>
>
>
>
>Norbert Brazda
>br...@ch...
>tel: 0905-729359
>
>ChangeNet - informacny servis o obcianskej spolocnosti
>Mlynske nivy 41, 821 09 Bratislava, Slovakia
>tel/fax: 02-55560026, eMail: in...@ch...
>http://www.changenet.sk
>
>SPAJAME LUDI, KTORI MENIA SVET
--
Mitra Technology Consulting - www.mitra.biz - mi...@mi...
02-6684-8096 or 0414-648-0722
Life is a Mystery to be Lived, not a Problem to be Solved
|