fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
[personal profile] fu
I keep tripping over $r which is from DW::Request->get, and is a DW::Request object $r which is an actual Apache2::RequestRec object -- the two are used in similar contexts and often have similarly named methods, but then you'll run into a method which behaves a a bit differently from one to the other and spend two hours debugging a completely unrelated thing.

We're trying to move away from Apache2::RequestRec objects and converting them into DW::Request where needed. How about we rename the old $r to $apache_r, and keep the new $r the same, so it's obvious at a glance which is which?

ETA: I've gone ahead and done just that for https://github.com/dreamwidth/dw-free/pull/211
pauamma: Cartooney crab holding drink (Default)
[personal profile] pauamma
Apache::LiveJournal::db_logger() was disabled early on as part of the Apache2 conversion. The intent was apparently to revisit that later, but it's been over 3 years and there's no "later" yet. As far as I can tell, Apache::LiveJournal::db_logger() is the only bit that uses LJ::AccessLogRecord, LJ::AccessLogSink, and LJ::AccessLogSink::* (there are other references, but they're in stuff like confcheck, so they don;t count).

Get rid of those? Or is there a planned use or another reason to keep them in the codebase?
mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
[staff profile] mark
Here's a quick and dirty guide to things you will need to watch for when touching files and how to help us convert everything to Apache 2 / mod_perl 2 compatibility.

1) The Request Object

Never call Apache->request.  If you need the request object, use BML::get_request() which will do the Right Thing to return the appropriate request object for you to mess with.

2) $ENV{LJHOME} is Dead

You should use $LJ::HOME instead.  (Caveat: if you're writing a command line tool, you may need to use the environment variable, depending on what libraries you load... but for web context, always use $LJ::HOME!)

3) Methods become Hashes

In a move that I don't particularly understand, now we must pluralize some things and treat most things like a hash.  If you are used to this:

   $r->header_in("Host")
   $r->header_in("Host" => "bar");
   $r->notes("Something")

Then you should now get used to this:

   $r->headers_in->{Host};
   $r->headers_in->{Host} = "bar";
   $r->notes->{Something}

Not much of a change.  This goes for all of the header calls: headers_in, headers_out, err_headers_in, err_headers_out, etc as well as notes and pnotes.  There are probably other changes I've missed that do this too.

4) $r->send_http_header defunct?

I've yet to figure out a replacement for this function.  It seems to not be required anymore?  The modules seem to do the right thing, at least in all of the cases I've tried, without ever calling this.

5) ...?

I'm sure I'm missing something.  But at this point, if you want to start grepping through dw-free for header_in, send_http_header, notes, etc and then start fixing it, go for it!  It's appreciated, as there are still many files that have these.

As a second/other thought, I've been debating creating an LJ::Request object that we can use instead of Apache2::RequestRec (or whatever it is).  That way, if we ever need to change the way something works (i.e. upgrade to Apache 2.2 / mod_perl 2.2?) then we can change that one module.

Opinions and discussion are welcome, of course!

Profile

dw_dev: The word "develop" using the Swirly D logo.  (Default)
Dreamwidth Open Source Development

March 2017

S M T W T F S
   1234
5678 91011
12131415161718
1920212223 2425
262728293031 

Syndicate

RSS Atom

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Mar. 26th, 2017 05:25 am
Powered by Dreamwidth Studios