Loading ...
Sorry, an error occurred while loading the content.
 

Re[6]: Problem with PerlTransHandler

Expand Messages
  • "Sergey V. Stashinskas"
    It s my original very simple script: package Apache::StripSession; use strict; use Apache; use Apache::Constants qw(:common); use DBI; sub handler { my $r =
    Message 1 of 9 , Jun 27, 2003
      It's my original very simple script:
      package Apache::StripSession;
      use strict;
      use Apache;
      use Apache::Constants qw(:common);
      use DBI;
      sub handler {
      my $r = shift;
      my $dbh = DBI->connect('dbi:mysql:altboards', 'root', '');
      # Session
      return DECLINED unless $r->uri =~ /^\/session\/([a-zA-Z0-9]{32})(.*)/;
      warn "$1, $2";
      $r->subprocess_env(SESSION => $1);
      $r->uri($2);
      return DECLINED;
      }
      1;

      When I try to get page from http://localhost/session/123343..12121/index
      it work perfectly.
      And this string has appeared in error.log -
      "12345678901234567890123456789012, /index at ...."

      But if I comment out string 'warn "$1, $2"; ' the same script with the same url doesn't work.
      $2 is undefined and browser tell me something like "www.localhost could not be found ..."
      Why???

      __END__

      -----Original Message-----
      From: "Raf" <rafiq@...>
      To: <sergei_stashinsk@...>
      Date: Fri, 27 Jun 2003 15:35:16 -0000 (GMT)
      Subject: Re: Re[4]: Problem with PerlTransHandler

      >
      > Sergey V. Stashinskas said:
      > > Problem is not in connection with database.
      > > When I try to connect then $2 regexp variable becomes undefined and
      > > script can not redirect anywhere. ($r->uri($2)) But when script is not
      > > connected with database all works perfectly and this variable has a real
      > > defined value. I can not understand this ...
      >
      > What are you actually getting in your logs? Are you sure that it's even
      > getting to $2? My thought is this:
      >
      > * if you don't get a $dbh back, then under strict you should get a
      > cock-up reporting that it can't run the method disconnect on an undefined
      > reference.
      >
      > Can't see why this would happen. How you tried to dump the uri with a
      > STDERR? Noticed that you're from Russia, so perhaps it's some kind of
      > character encoding/local problem, since you're matching against latin
      > character classes? Can weird character creep into your session string?
      >
      > Just thoughts. Final thought is running it through Apache::DB if you
      > fancy building it. Just a thought.
      >
      > Cheers,
      >
      > R.
      >
      >
      >
      >
      >
      >
      >
      >
      > > Original source:
      > > package Apache::StripSession;
      > > use strict;
      > > use Apache;
      > > use Apache::Constants qw(:common);
      > >
      > > sub handler {
      > > my $r = shift;
      > >
      > > my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
      > > $dbh->disconnect;
      > > return DECLINED unless $r->uri =~
      > > /^\/session\/([a-zA-Z0-9]{32})(.*)/;
      > >
      > > $r->subprocess_env(SESSION => $1);
      > > $r->uri($2);
      > >
      > > return DECLINED;
      > > }
      > >
      > > 1;
      > >
      > > -----Original Message-----
      > > From: "Raf" <rafiq@...>
      > > To: <sergei_stashinsk@...>
      > > Date: Fri, 27 Jun 2003 15:09:13 -0000 (GMT)
      > > Subject: Re: Re[2]: Problem with PerlTransHandler
      > >
      > >>
      > >> Sergey V. Stashinskas said:
      > >> > If these lines are commented out then script is working ok.
      > >> >
      > >> > -----Original Message-----
      > >> > From: <csebe@...>
      > >> > To: "Sergey V. Stashinskas "
      > >> > <sergei_stashinsk@...>,<modperl@...> Date: Fri, 27
      > >> Jun 2003 16:39:12 +0300
      > >> > Subject: RE: Problem with PerlTransHandler
      > >> >
      > >> >>
      > >> >> Have you tried to comment out the 2 DBI lines like this:
      > >> >>
      > >> >> #my $dbh = DBI->connect('dbi:mysql:db', 'user', 'pswd');
      > >> >> #$dbh->disconnect;
      > >>
      > >> Can't find your original post, however try doing something like:
      > >>
      > >> $dbh->disconnect if ref($dbh);
      > >>
      > >> or:
      > >>
      > >> if (ref $dbh) {
      > >> $dbh->disconnect;
      > >> else {
      > >> ## CHECK LOGS for this
      > >> print STDERR "\n Failed to connect \n";
      > >> };
      > >>
      > >> Cheers,
      > >>
      > >> Raf
      > >>
      > >>
      > >>
      > >>
      >
      >
      >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.