Permalink
Browse files

(bug 4436) Fix ljdb tool, fix ml strings.

  • Loading branch information...
anall committed Jul 10, 2012
1 parent 292a4f0 commit 974754e45f5f321e25692198226d6d61647e4a6c
Showing with 24 additions and 11 deletions.
  1. +3 −0 bin/ljdb
  2. +15 −6 cgi-bin/Apache/LiveJournal.pm
  3. +1 −1 cgi-bin/LJ/Directories.pm
  4. +5 −4 cgi-bin/LJ/Lang.pm
View
@@ -21,6 +21,9 @@
use strict;
use lib "$ENV{LJHOME}/cgi-bin";
+BEGIN {
+ require "$ENV{LJHOME}/cgi-bin/ljlib.pl";
+}
use LJ::DB;
use Getopt::Long;
@@ -287,13 +287,19 @@ sub resolve_path_for_uri {
if ( $uri !~ m!(\.\.|\%|\.\/)! ) {
if ( exists $FILE_LOOKUP_CACHE{$uri} ) {
- return $FILE_LOOKUP_CACHE{$uri};
+ return @{ $FILE_LOOKUP_CACHE{$uri} };
}
foreach my $dir ( LJ::get_all_directories( 'htdocs' ) ) {
my $file = "$dir/$uri";
- $file .= "index.bml" if -e "$file/index.bml" && $uri eq '/';
- $file .= ".bml" if -e "$file.bml";
+ if ( -e "$file/index.bml" && $uri eq '/' ) {
+ $file .= "index.bml";
+ $uri .= "/index.bml";
+ }
+ if ( -e "$file.bml" ) {
+ $file .= ".bml";
+ $uri .= ".bml";
+ }
next unless -e $file;
if ( -d $file && -e "$file/index.bml" ) {
@@ -303,7 +309,9 @@ sub resolve_path_for_uri {
$file = abs_path( $file );
if ( $file ) {
- return $FILE_LOOKUP_CACHE{$uri} = $file;
+ $uri =~ s!^/+!/!;
+ $FILE_LOOKUP_CACHE{$uri} = [ $uri, $file ];
+ return @{ $FILE_LOOKUP_CACHE{$uri} };
}
}
}
@@ -375,7 +383,7 @@ sub trans
} else { # not is_initial_req
if ($r->status == 404) {
my $fn = $LJ::PAGE_404 || "404-error.bml";
- my $path = resolve_path_for_uri($fn);
+ my ( $uri, $path ) = resolve_path_for_uri($fn);
return $bml_handler->( $path ) if $path;
}
}
@@ -393,8 +401,9 @@ sub trans
$LJ::USERPIC_ROOT = $LJ::USERPICROOT_BAK if $LJ::USERPICROOT_BAK;
}
- my $alt_path = resolve_path_for_uri($uri);
+ my ( $alt_uri, $alt_path ) = resolve_path_for_uri($uri);
if ( $alt_path ) {
+ $r->uri( $alt_uri );
$r->filename( $alt_path );
return OK;
}
@@ -66,7 +66,7 @@ my %SCOPE_ORDER = (
my @SCOPES =
sort { $SCOPE_ORDER{$b} <=> $SCOPE_ORDER{$a} } keys %SCOPE_ORDER;
-unless ( $INC_PATCHED ) {
+unless ( 0 ) { #$INC_PATCHED ) {
lib->import( $LJ::HOME . "/src/DSMS/lib" );
{
View
@@ -561,19 +561,20 @@ sub get_text
my ($localcode, @files);
if ($code =~ m!^(/.+\.bml)(\..+)!) {
my $file;
- ($file, $localcode) = ("$LJ::HTDOCS$1", $2);
+ ($file, $localcode) = ("htdocs$1", $2);
@files = ("$file.text.local", "$file.text");
} elsif ( $code =~ m!^(/.+\.tt)(\..+)! ) {
my $file;
- ( $file, $localcode ) = ( "$LJ::HOME/views$1", $2 );
+ ( $file, $localcode ) = ( "views$1", $2 );
@files = ( "$file.text.local", "$file.text" );
} else {
$localcode = $code;
- @files = ("$LJ::HOME/bin/upgrading/$LJ::DEFAULT_LANG.dat",
- "$LJ::HOME/bin/upgrading/en.dat");
+ @files = ("bin/upgrading/$LJ::DEFAULT_LANG.dat",
+ "bin/upgrading/en.dat");
}
foreach my $tf (@files) {
+ $tf = LJ::resolve_file( $tf );
next unless -e $tf;
# compare file modtime to when the string was updated in the DB.

2 comments on commit 974754e

Member

swaldman3 replied Aug 13, 2012

Since this commit I've been getting a flood of "Use of initialized value $tf" messages in the logs, every time that "$tf = LJ::resolve_file( $tf );" is called on a file that does not exist (Line 577 in Lang.pm).
Is there anything that can be done about that?
Thanks! :-)

(Incidentally, I have no idea whether anybody will actually see this note. I'm hoping that the person who did the commit may be automagically subscribed to it ;-))

(EDIT: to be clear, the error refers to line 578 - but it's 577 that "uninitializes" the variable if the file doesn't exist, I think.)

Please sign in to comment.