[dw-free] migrate LJ::load_user_props -> $u->preload_props
[commit: http://hg.dwscoalition.org/dw-free/rev/8efc50a6349e]
http://bugs.dwscoalition.org/show_bug.cgi?id=2653
Refactor redirection to a specific URL for renamed journals.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2653
Refactor redirection to a specific URL for renamed journals.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/User.pm
- htdocs/talkpost.bml
- htdocs/talkread.bml
- htdocs/view/index.bml
-------------------------------------------------------------------------------- diff -r 15398892e6bc -r 8efc50a6349e cgi-bin/LJ/User.pm --- a/cgi-bin/LJ/User.pm Fri Jun 11 15:56:55 2010 +0800 +++ b/cgi-bin/LJ/User.pm Fri Jun 11 16:06:25 2010 +0800 @@ -1098,6 +1098,16 @@ sub record_login { } +sub redirect_rename { + my ( $u, $uri ) = @_; + return undef unless $u->is_redirect; + my $renamedto = $u->prop( 'renamedto' ) or return undef; + my $ru = LJ::load_user( $renamedto ) or return undef; + $uri ||= ''; + return BML::redirect( $ru->journal_base . $uri ); +} + + # my $sess = $u->session (returns current session) # my $sess = $u->session($sessid) (returns given session id for user) sub session { diff -r 15398892e6bc -r 8efc50a6349e htdocs/talkpost.bml --- a/htdocs/talkpost.bml Fri Jun 11 15:56:55 2010 +0800 +++ b/htdocs/talkpost.bml Fri Jun 11 16:06:25 2010 +0800 @@ -72,11 +72,9 @@ body<= # redirect if account was renamed if ( $u->is_redirect ) { - $u->preload_props( "renamedto" ); - if ($u->{'renamedto'} ne "") { - my $id = $FORM{'itemid'}+0; - return BML::redirect(LJ::journal_base($u->{'renamedto'}) . "/$id.html?mode=reply"); - } + my $id = $FORM{'itemid'} + 0; + my $redirect = $u->redirect_rename( "/$id.html?mode=reply" ); + return $redirect if $redirect; } LJ::Hooks::run_hooks("need_res_for_journals", $u); diff -r 15398892e6bc -r 8efc50a6349e htdocs/talkread.bml --- a/htdocs/talkread.bml Fri Jun 11 15:56:55 2010 +0800 +++ b/htdocs/talkread.bml Fri Jun 11 16:06:25 2010 +0800 @@ -95,10 +95,8 @@ body<= # redirect if account was renamed if ( $u->is_redirect ) { - $u->preload_props( "renamedto" ); - if ($u->{'renamedto'} ne "") { - return BML::redirect(LJ::journal_base($u->{'renamedto'}) . "/$ditemid.html"); - } + my $redirect = $u->redirect_rename( "/$ditemid.html" ); + return $redirect if $redirect; } # now check for init->error, since we know the account wasn't renamed diff -r 15398892e6bc -r 8efc50a6349e htdocs/view/index.bml --- a/htdocs/view/index.bml Fri Jun 11 15:56:55 2010 +0800 +++ b/htdocs/view/index.bml Fri Jun 11 16:06:25 2010 +0800 @@ -59,11 +59,10 @@ _c?> } if ( $u->is_redirect ) { - $u->preload_props( "renamedto" ); - if ( $u->{'renamedto'} ) { - return BML::redirect( sprintf( LJ::journal_base( $u->{'renamedto'} ) - . "/%04d/%02d/", $FORM{'y'}, $FORM{'m'} ) ); - } + my $redirect = $u->redirect_rename( + sprintf( "/%04d/%02d/", $FORM{'y'}, $FORM{'m'} ) + ); + return $redirect if $redirect; } my $remote = LJ::get_remote(); --------------------------------------------------------------------------------