vadvs (vadvs) wrote in changelog,
vadvs
vadvs
changelog

[bml] r112: use LJ::Request instead of Apache(->requ...

Committer: vad
use LJ::Request instead of Apache(->request).
U   branches/modernize2/lib/Apache/BML.pm
Modified: branches/modernize2/lib/Apache/BML.pm
===================================================================
--- branches/modernize2/lib/Apache/BML.pm	2010-01-18 11:05:58 UTC (rev 111)
+++ branches/modernize2/lib/Apache/BML.pm	2010-01-19 08:24:33 UTC (rev 112)
@@ -59,7 +59,7 @@
 # instead of just using Apache->request because when using
 # Apache::FakeRequest and non-mod_perl env, I can't seem to get/set
 # the value of Apache->request
-use vars qw($r);
+#use vars qw($r);
 
 # regexps to match open and close tokens. (but old syntax (=..=) is deprecated)
 my ($TokenOpen, $TokenClose) = ('<\?', '\?>');
@@ -69,7 +69,7 @@
 
 sub handler
 {
-    my $r = $Apache::BML::r = LJ::Request->r;
+    #my $r = $Apache::BML::r = LJ::Request->r;
 
     # determine what file we're supposed to work with:
     my $file = Apache::BML::decide_file_and_stat();
@@ -90,7 +90,7 @@
     return FORBIDDEN if $file =~ /\b_config/;
 
     # create new request
-    my $req = Apache::BML::initialize_cur_req($r, $file);
+    my $req = Apache::BML::initialize_cur_req($file);
 
     # setup env
     my $env = $req->{env};
@@ -249,6 +249,12 @@
         }
     }
 
+use Data::Dumper;
+warn "GET=" . Dumper(\%BMLCodeBlock::GET);
+warn "POST=" . Dumper(\%BMLCodeBlock::POST);
+warn "FORM=" . Dumper(\%BMLCodeBlock::FORM);
+
+
      %BMLCodeBlock::GET_POTENTIAL_XSS = ();
      if ($env->{MildXSSProtection}) {
          foreach my $k (keys %BMLCodeBlock::GET) {
@@ -264,7 +270,7 @@
         eval {
             $env->{'HOOK-startup'}->();
         };
-        return report_error($r, "<b>Error running startup hook:</b><br />\n$@")
+        return report_error("<b>Error running startup hook:</b><br />\n$@")
             if $@;
     }
 
@@ -274,7 +280,7 @@
     $BML::CODE_INIT_PERL = "";
     if ($env->{'HOOK-codeblock_init_perl'}) {
         $BML::CODE_INIT_PERL = eval { $env->{'HOOK-codeblock_init_perl'}->(); };
-        return report_error($r, "<b>Error running codeblock_init_perl hook:</b><br />\n$@") if $@;
+        return report_error("<b>Error running codeblock_init_perl hook:</b><br />\n$@") if $@;
     }
 
     my $scheme = LJ::Request->notes('bml_use_scheme') ||
@@ -291,7 +297,7 @@
         $default_scheme_override = eval {
             $env->{'HOOK-default_scheme_override'}->($scheme || $env->{DefaultScheme});
         };
-        return report_error($r, "<b>Error running scheme override hook:</b><br />\n$@") if $@;
+        return report_error("<b>Error running scheme override hook:</b><br />\n$@") if $@;
     }
 
     $scheme ||= $default_scheme_override || $env->{'DefaultScheme'};
@@ -324,7 +330,7 @@
 
     if ($env->{'HOOK-before_decode'}) {
         eval { $env->{'HOOK-before_decode'}->(); };
-        return report_error($r, "<b>Error running before_decode hook:</b><br />\n$@") if $@;
+        return report_error("<b>Error running before_decode hook:</b><br />\n$@") if $@;
     }
 
     bml_decode($req, \$bmlsource, \$html, { DO_CODE => $env->{'AllowCode'} })
@@ -431,7 +437,6 @@
         # when another handler needs to invoke BML directly
         stat($file);
     } else {
-        # normal case - $r->filename is already stat'd
         $file = LJ::Request->filename;
         LJ::Request->finfo;
     }
@@ -446,12 +451,11 @@
 
 sub initialize_cur_req
 {
-    my $r = shift;
     my $file = shift;
 
     my $req = $cur_req = fields::new('BML::Request');
-    $req->{file} = $file || Apache::BML::decide_file_and_stat($r);
-    $req->{r}    = $r;
+    $req->{file} = $file || Apache::BML::decide_file_and_stat();
+    $req->{r}    = LJ::Request->r; # TODO: remove
     $req->{BlockStack} = [""];
     $req->{scratch}    = {};  # _CODE blocks can play
     $req->{cookies} = {};
@@ -466,7 +470,6 @@
 
 sub report_error
 {
-    my $r = shift;
     my $err = shift;
 
     LJ::Request->content_type("text/html");
@@ -497,7 +500,6 @@
     my ($volume,$dirs,$file) = File::Spec->splitpath($ffile);
 
     # see which configs are denied
-    my $r = $Apache::BML::r;
     if (LJ::Request->dir_config("BML_denyconfig") && ! %DenyConfig) {
         my $docroot = LJ::Request->document_root();
         my $deny = LJ::Request->dir_config("BML_denyconfig");
@@ -1405,7 +1407,6 @@
 sub parse_multipart
 {
     my ($dest, $error, $max_size) = @_;
-    my $r = $Apache::BML::r;
     my $err = sub { $$error = $_[0]; return 0; };
 
     my $size = LJ::Request->header_in("Content-length");
@@ -1763,12 +1764,16 @@
     # callers sometimes use %BML::COOKIE, so $Apache::BML::r isn't set.
     # the cookie FETCH below calls this function to try and use Apache->request,
     # else fall back to the global one (for use in profiling/debugging)
-    my $r;
-    eval {
-        $r = LJ::Request->request;
-    };
-    $r ||= $Apache::BML::r;
-    return $r;
+    
+    #my $r;
+    #eval {
+    #    $r = LJ::Request->r;
+    #};
+    #$r ||= $Apache::BML::r;
+    #return $r;
+    #
+
+    return eval { LJ::Request->r };
 }
 
 sub get_query_string
@@ -1850,7 +1855,6 @@
 {
     my ($code, $msg) = @_;
 
-    my $r = $Apache::BML::r;
     LJ::Request->status($code);
     LJ::Request->content_type('text/html');
     LJ::Request->print($msg);
@@ -1960,7 +1964,6 @@
 {
     my ($lang, $getter) = @_;  # getter is optional
     my BML::Request $req = $Apache::BML::cur_req;
-    #my $r = BML::get_request();
     LJ::Request->notes('langpref' => $lang);
 
     # don't rely on $req (the current BML request) being defined, as
@@ -2244,7 +2247,6 @@
     my ($t, $key) = @_;
     # we do this, and not use $Apache::BML::r directly because some non-BML
     # callers sometimes use %BML::COOKIE.
-    my $r = BML::get_request();
     unless ($BML::COOKIES_PARSED) {
         foreach (split(/;\s+/, LJ::Request->header_in("Cookie"))) {
             next unless ($_ =~ /(.*)=(.*)/);

Tags: bml, pm, vadvs
Subscribe

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments