in reply to File upload became deaf after upgrading from 5.8.7 to 5.8.9

Can you tell us something more about the versions of CGI.pm on both servers? I've heard bad things about the latest upgrades of that module, though nothing related to file uploads, but I wouldn't rule it out.
  • Comment on Re: File upload became deaf after upgrading from 5.8.7 to 5.8.9

Replies are listed 'Best First'.
Re^2: File upload became deaf after upgrading from 5.8.7 to 5.8.9
by aquarium (Curate) on Nov 04, 2010 at 22:36 UTC
    along a similar vein of thinking...have you turned on some debugging output for CGI.pm and or checked your webserver logs? run the CGI from command line?..i think you can even provide the file upload parameter on command line. is the file upload form parameter being passed into the CGI for sure? sniff the network with wireshark? check webserver config is not pointing to older (incompatible) .dll/.exe for perl. also check the upgraded perl doesn't point to older modules somehow/somewhere.
    i'm sure you know all these things to check..probably just stressed out too much. just remembered another useful thing: run Filemon utility and check the log, possibility of a file permission issue.
    good luck.
    the hardest line to type correctly is: stty erase ^H
Re^2: File upload became deaf after upgrading from 5.8.7 to 5.8.9
by Andre_br (Pilgrim) on Nov 04, 2010 at 23:43 UTC
    Hey bart, hey aquarium

    Thanks for the replies!

    I've just found the cure.

    Before that part of the code, I had a sub that initiated the CGI object within itself. For example:

    #!/usr/bin/perl -wT use CGI; my $q = new CGI; #... my ( $user_id, $name ) = identify ( $auth_token ); # ... my $fh = $q->upload( "file" ); my $filesize = -s $fh; die $filesize; # undef at debugging! # ... file read routines, that resulted blank after the upgrade
    Then, on my personal lib, mylib1.pm, I had this subroutine:
    sub identify { my $token = shift; # my $q = new CGI; # it started working when I removed this line! # identification routines # some calls to CGI.pm methods, where I used $q }
    After hours of mystery, I decided to remove this inner initialization. And it worked! I'm now passing $q as a parameter to the sub.

    sub identify { my $token = shift; my $q = shift; # and including this element on the sub call, of cou +rse my $q = new CGI; # it started working when I removed this line! # identification routines # some calls to CGI.pm methods, where I used $q }
    Tell me, guys, what's the explanation? Is this a bug on CGI.pm garbage collection or is it the case that I was doing ugly things.

    Funny is that it worked with 5.8.7.

    Thanks

    Andre

      Uh, creating a CGI object effectively reads the data from the input. After that, it is gone, when the data is POSTed (as is necessary for file upload) — you may repeat reading parameters from GET.

      It's not a matter of garbage collecting, it's a matter of a physical action performed when creating the object. An action that cannot stand being repeated.

        That's very clarifying, thanks a lot Bart!

        But it is incredible as it worked for years with 5.8.7.
        Probably something they were being tolerant with bad code.
        I'll watch out for this from now on.

        Thanks!

        André