diffs (911 lines):
diff -r 64de350ea481 -r a8493c11bfce bin/upgrading/s2layers/core2.s2
--- a/bin/upgrading/s2layers/core2.s2 Fri Jun 11 13:52:12 2010 +0800
+++ b/bin/upgrading/s2layers/core2.s2 Sun Jun 13 22:44:34 2010 +0800
@@ -419,6 +419,7 @@ class Comment extends EntryLite
var readonly bool screened "True if comment is in screened state.";
var readonly bool frozen "True if comment is in frozen state.";
var readonly bool deleted "True if comment has been deleted. Deleted
comments still show up if they are the parent of a thread.";
+ var readonly bool fromsuspended "True if comment's author has been
suspended.";
var readonly string anchor "Direct link to comment, via HTML name anchors";
var readonly bool comment_posted "True if comment was just posted by the
current user.";
var readonly bool edited "True if the comment has been edited.";
@@ -2555,6 +2556,16 @@ property string text_screened {
example = "(screened) ";
}
+property string text_deleted {
+ des = "The text used when a comment has been deleted";
+ example = "(deleted comment)";
+}
+
+property string text_fromsuspended {
+ des = "The text used when the comment's author has been suspended";
+ example = "(reply from suspended user)";
+}
+
property string text_frozen {
des = "The text used when a comment is frozen";
example = "(frozen) ";
@@ -2592,6 +2603,8 @@ property string text_website_default_nam
property string text_website_default_name { noui = 1; des = "If an account's
website is specified, but there's no website name, use this text instead"; }
set text_screened = "(screened) ";
+set text_deleted = "(deleted comment)";
+set text_fromsuspended = "(reply from suspended user)";
set text_frozen = "(frozen) ";
set text_poster_anonymous = "(Anonymous)";
set text_openid_from = "from";
@@ -5292,12 +5305,16 @@ function EntryPage::print_comment (Comme
function EntryPage::print_comment_partial (Comment c) {
$c->print_wrapper_start();
- var string poster = defined $c.poster ? $c.poster->as_string() :
"<i>$*text_poster_anonymous</i>";
- $c->print_subject();
- print safe " - $poster";
- var Link expand_link = $c->get_link("expand_comments");
- if (defined $expand_link) {
- " "; $c->print_expand_link();
+ if ($c.deleted) { print $*text_deleted; }
+ elseif ($c.fromsuspended) { print $*text_fromsuspended; }
+ else {
+ var string poster = defined $c.poster ? $c.poster->as_string() :
"<i>$*text_poster_anonymous</i>";
+ $c->print_subject();
+ print safe " - $poster";
+ var Link expand_link = $c->get_link("expand_comments");
+ if (defined $expand_link) {
+ " "; $c->print_expand_link();
+ }
}
$c->print_wrapper_end();
}
diff -r 64de350ea481 -r a8493c11bfce bin/upgrading/s2layers/core2base/layout.s2
--- a/bin/upgrading/s2layers/core2base/layout.s2 Fri Jun 11 13:52:12
2010 +0800
+++ b/bin/upgrading/s2layers/core2base/layout.s2 Sun Jun 13 22:44:34
2010 +0800
@@ -357,6 +357,9 @@ q { font-style: italic; }
.three-columns-right #content {
border-right: $*sidebar_width_doubled solid transparent;
}
+.column-right #content {
+ min-width: $*sidebar_width; /* prevents sidebar overlap of entry, when
entry becomes narrower than sidebar */
+}
#content-footer {
height: 0;
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/DW/User/Edges/CommMembership.pm
--- a/cgi-bin/DW/User/Edges/CommMembership.pm Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/DW/User/Edges/CommMembership.pm Sun Jun 13 22:44:34 2010 +0800
@@ -47,7 +47,13 @@ sub _add_m_edge {
return 0 unless $from_u->can_join( $to_u, moderated_add =>
$member_edge->{moderated_add} ? 1 : 0 );
# simply add the reluser edge
- LJ::set_rel( $to_u, $from_u, 'E' );
+ my $rv = LJ::set_rel( $to_u, $from_u, 'E' );
+
+ # delete memcache key for community reading pages
+ LJ::memcache_kill( $to_u, 'c_wt_list' );
+
+ # success?
+ return $rv;
}
# internal method to delete an edge
@@ -63,6 +69,9 @@ sub _del_m_edge {
# now remove it; note we don't do any extraneous checking. if the user
# wants to remove an edge that doesn't exist? more power to them.
LJ::clear_rel( $to_u, $from_u, 'E' );
+
+ # delete memcache key for community reading pages
+ LJ::memcache_kill( $to_u, 'c_wt_list' );
# success!
return 1;
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/LJ/MemCache.pm
--- a/cgi-bin/LJ/MemCache.pm Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/LJ/MemCache.pm Sun Jun 13 22:44:34 2010 +0800
@@ -123,9 +123,12 @@ sub delete {
$memc->delete(@_, 4) || $memc->delete(@_);
}
-sub add { $memc->add(@_); }
-sub replace { $memc->replace(@_); }
-sub set { $memc->set(@_); }
+sub add { ( defined $_[1] ) ? $memc->add( @_ )
+ : $memc->add( $_[0], '', $_[2] ); }
+sub replace { ( defined $_[1] ) ? $memc->replace( @_ )
+ : $memc->replace( $_[0], '', $_[2] ); }
+sub set { ( defined $_[1] ) ? $memc->set( @_ )
+ : $memc->set( $_[0], '', $_[2] ); }
sub incr { $memc->incr(@_); }
sub decr { $memc->decr(@_); }
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/LJ/S2/EntryPage.pm
--- a/cgi-bin/LJ/S2/EntryPage.pm Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/LJ/S2/EntryPage.pm Sun Jun 13 22:44:34 2010 +0800
@@ -1,3 +1,4 @@
+#!/usr/bin/perl
#!/usr/bin/perl
#
# This code was forked from the LiveJournal project owned and operated
@@ -261,7 +262,8 @@ sub EntryPage
threadroot_url => $threadroot_url,
'screened' => $com->{'state'} eq "S" ? 1 : 0,
'frozen' => $com->{'state'} eq "F" ? 1 : 0,
- 'deleted' => $com->{'state'} eq "D" ? 1 : 0,
+ 'deleted' => 0,
+ 'fromsuspended' => 0,
'link_keyseq' => [ 'delete_comment' ],
'anchor' => LJ::Talk::comment_htmlid( $dtalkid ),
'dom_id' => LJ::Talk::comment_htmlid( $dtalkid ),
@@ -280,11 +282,26 @@ sub EntryPage
# FIXME: ideally the load_comments should only return these
# items if there are children, otherwise they should be hidden
entirely
if ($pu && $pu->is_suspended && !$viewsome) {
+ $s2com->{'fromsuspended'} = 1;
+ $s2com->{'full'} = 0;
+ $s2com->{'poster'} = undef;
+ $s2com->{'userpic'} = undef;
+ $s2com->{'subject'} = "";
+ $s2com->{'subject_icon'} = undef;
$s2com->{'text'} = "";
+ $s2com->{'screened'} = undef;
+ }
+
+ # don't show info for deleted comments
+ if ($com->{'state'} eq "D") {
+ $s2com->{'deleted'} = 1;
+ $s2com->{'full'} = 0;
+ $s2com->{'poster'} = undef;
+ $s2com->{'userpic'} = undef;
$s2com->{'subject'} = "";
- $s2com->{'full'} = 0;
$s2com->{'subject_icon'} = undef;
- $s2com->{'userpic'} = undef;
+ $s2com->{'text'} = "";
+ $s2com->{'screened'} = undef;
}
# Conditionally add more links to the keyseq
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/LJ/Talk.pm
--- a/cgi-bin/LJ/Talk.pm Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/LJ/Talk.pm Sun Jun 13 22:44:34 2010 +0800
@@ -2904,15 +2904,15 @@ sub init {
push @$errret, $error;
return undef;
};
- my $bmlerr = sub {
- return $err->($BML::ML{$_[0]});
+ my $mlerr = sub {
+ return $err->( LJ::Lang::ml( $_[0] ) );
};
my $init = LJ::Talk::init($form);
return $err->($init->{error}) if $init->{error};
my $journalu = $init->{'journalu'};
- return $bmlerr->('talk.error.nojournal') unless $journalu;
+ return $mlerr->('talk.error.nojournal') unless $journalu;
return $err->($LJ::MSG_READONLY_USER) if $journalu->is_readonly;
return $err->("Account is locked, unable to post or edit a comment.") if
$journalu->is_locked;
@@ -2922,7 +2922,7 @@ sub init {
if $r;
my $dbcr = LJ::get_cluster_def_reader($journalu);
- return $bmlerr->('error.nodb') unless $dbcr;
+ return $mlerr->('error.nodb') unless $dbcr;
my $itemid = $init->{'itemid'}+0;
@@ -2934,7 +2934,7 @@ sub init {
}
unless ($item && $item->{'anum'} == $init->{'anum'}) {
- return $bmlerr->('talk.error.noentry');
+ return $mlerr->('talk.error.noentry');
}
my $iprops = $item->{'props'};
@@ -2951,7 +2951,7 @@ sub init {
if ($form->{'userpost'} && $form->{'usertype'} ne "user") {
unless ($form->{'usertype'} eq "cookieuser" &&
$form->{'userpost'} eq $form->{'cookieuser'}) {
- $bmlerr->("$SC.error.confused_identity");
+ $mlerr->("$SC.error.confused_identity");
}
}
@@ -2967,7 +2967,7 @@ sub init {
if ( ( $form->{usertype} eq "user" && exists $form->{ecphash} ) ||
($form->{'usertype'} eq "cookieuser")) {
my $userpost = $form->{'userpost'} || $form->{'cookieuser'};
- $bmlerr->("$SC.error.lostcookie")
+ $mlerr->("$SC.error.lostcookie")
unless $remote && $remote->{'user'} eq $userpost;
return undef if @$errret;
@@ -2982,7 +2982,7 @@ sub init {
if ((grep { $form->{'userpost'} eq $_ } @LJ::TESTACCTS) &&
!(grep { $journalu->{'user'} eq $_ } @LJ::TESTACCTS) &&
!$LJ::IS_DEV_SERVER)
{
- $bmlerr->("$SC.error.testacct");
+ $mlerr->("$SC.error.testacct");
}
my $userpost = lc($form->{'userpost'});
@@ -3004,16 +3004,16 @@ sub init {
if ($up) {
### see if the user is banned from posting here
if (LJ::is_banned($up, $journalu)) {
- $bmlerr->("$SC.error.banned");
+ $mlerr->("$SC.error.banned");
}
# TEMP until we have better openid support
if ($up->is_identity && $journalu->{'opt_whocanreply'} eq
"reg") {
- $bmlerr->("$SC.error.noopenid");
+ $mlerr->("$SC.error.noopenid");
}
unless ( $up->is_person || ( $up->is_identity && $cookie_auth
) ) {
- $bmlerr->("$SC.error.postshared");
+ $mlerr->("$SC.error.postshared");
}
# if we're already authenticated via cookie, then userpost was
set
@@ -3065,7 +3065,7 @@ sub init {
$up = $remote;
### see if the user is banned from posting here
- $bmlerr->("$SC.error.banned") if (LJ::is_banned($up, $journalu));
+ $mlerr->("$SC.error.banned") if (LJ::is_banned($up, $journalu));
if ($form->{'oiddo_login'}) {
$up->make_login_session($form->{'exptype'},
$form->{'ipfixed'});
@@ -3166,8 +3166,8 @@ sub init {
my $ent = LJ::Entry->new_from_item_hash( $item )
or die "Unable to create entry object.\n";
unless ( $ent->visible_to( $up ) ) {
- $bmlerr->( "$SC.error.mustlogin" ) unless defined $up;
- $bmlerr->( "$SC.error.noauth" );
+ $mlerr->( "$SC.error.mustlogin" ) unless defined $up;
+ $mlerr->( "$SC.error.noauth" );
return undef;
}
@@ -3179,7 +3179,7 @@ sub init {
if ($partid) {
$parpost = LJ::Talk::get_talk2_row($dbcr, $journalu->{userid},
$partid);
unless ($parpost) {
- $bmlerr->("$SC.error.noparent");
+ $mlerr->("$SC.error.noparent");
}
}
$init->{parpost} = $parpost;
@@ -3192,11 +3192,11 @@ sub init {
if (($form->{'usertype'} ne "user" && $form->{'usertype'} ne 'openid' &&
$form->{'usertype'} ne 'openid_cookie')
&& $journalu->{'opt_whocanreply'} ne "all")
{
- $bmlerr->("$SC.error.noanon");
+ $mlerr->("$SC.error.noanon");
}
if ( $ent->comments_disabled ) {
- $bmlerr->("$SC.error.nocomments");
+ $mlerr->("$SC.error.nocomments");
}
if ($up) {
@@ -3204,9 +3204,9 @@ sub init {
$err->(BML::ml("$SC.error.noverify2", {'aopts' =>
"href='$LJ::SITEROOT/register'"}));
}
- $bmlerr->("$SC.error.purged") if $up->is_expunged;
- $bmlerr->("$SC.error.deleted") if $up->is_deleted;
- $bmlerr->("$SC.error.suspended") if $up->is_suspended;
+ $mlerr->("$SC.error.purged") if $up->is_expunged;
+ $mlerr->("$SC.error.deleted") if $up->is_deleted;
+ $mlerr->("$SC.error.suspended") if $up->is_suspended;
}
if ($journalu->{'opt_whocanreply'} eq "friends") {
@@ -3223,7 +3223,7 @@ sub init {
}
}
- $bmlerr->("$SC.error.blankmessage") unless $form->{'body'} =~ /\S/;
+ $mlerr->("$SC.error.blankmessage") unless $form->{'body'} =~ /\S/;
# in case this post comes directly from the user's mail client, it
# may have an encoding field for us.
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/LJ/User.pm Sun Jun 13 22:44:34 2010 +0800
@@ -776,8 +776,155 @@ sub load_random_user {
}
+# des: Given a user hashref, loads the values of the given named properties
+# into that user hashref.
+# args: u, opts?, propname*
+# des-opts: hashref of opts. set key 'use_master' to use cluster master.
+# des-propname: the name of a property from the [dbtable[userproplist]] table.
+# leave undef to preload all userprops
sub preload_props {
- LJ::load_user_props( @_ );
+ my $u = shift;
+ return unless LJ::isu($u);
+ return if $u->is_expunged;
+
+ my $opts = ref $_[0] ? shift : {};
+ my (@props) = @_;
+
+ my ($sql, $sth);
+ LJ::load_props("user");
+
+ ## user reference
+ my $uid = $u->userid + 0;
+ $uid = LJ::get_userid( $u->user ) unless $uid;
+
+ my $mem = {};
+ my $use_master = 0;
+ my $used_slave = 0; # set later if we ended up using a slave
+
+ if (@LJ::MEMCACHE_SERVERS) {
+ my @keys;
+ foreach (@props) {
+ next if exists $u->{$_};
+ my $p = LJ::get_prop("user", $_);
+ die "Invalid userprop $_ passed to preload_props." unless $p;
+ push @keys, [$uid,"uprop:$uid:$p->{'id'}"];
+ }
+ $mem = LJ::MemCache::get_multi(@keys) || {};
+ $use_master = 1;
+ }
+
+ $use_master = 1 if $opts->{'use_master'};
+
+ my @needwrite; # [propid, propname] entries we need to save to memcache
later
+
+ my %loadfrom;
+ my %multihomed; # ( $propid => 0/1 ) # 0 if we haven't loaded it, 1 if we
have
+ unless (@props) {
+ # case 1: load all props for a given user.
+ # multihomed props are stored on userprop and userproplite2, but since
they
+ # should always be in sync, it doesn't matter which gets loaded first,
the
+ # net results should be the same. see
doc/server/lj.int.multihomed_userprops.html
+ # for more information.
+ $loadfrom{'userprop'} = 1;
+ $loadfrom{'userproplite'} = 1;
+ $loadfrom{'userproplite2'} = 1;
+ $loadfrom{'userpropblob'} = 1;
+ } else {
+ # case 2: load only certain things
+ foreach (@props) {
+ next if exists $u->{$_};
+ my $p = LJ::get_prop("user", $_);
+ die "Invalid userprop $_ passed to preload_props." unless $p;
+ if (defined $mem->{"uprop:$uid:$p->{'id'}"}) {
+ $u->{$_} = $mem->{"uprop:$uid:$p->{'id'}"};
+ next;
+ }
+ push @needwrite, [ $p->{'id'}, $_ ];
+ my $source = $p->{'indexed'} ? "userprop" : "userproplite";
+ if ($p->{datatype} eq 'blobchar') {
+ $source = "userpropblob"; # clustered blob
+ }
+ elsif ( $p->{'cldversion'} && $u->dversion >= $p->{'cldversion'} )
{
+ $source = "userproplite2"; # clustered
+ }
+ elsif ($p->{multihomed}) {
+ $multihomed{$p->{id}} = 0;
+ $source = "userproplite2";
+ }
+ push @{$loadfrom{$source}}, $p->{'id'};
+ }
+ }
+
+ foreach my $table (qw{userproplite userproplite2 userpropblob userprop}) {
+ next unless exists $loadfrom{$table};
+ my $db;
+ if ($use_master) {
+ $db = ($table =~ m{userprop(lite2|blob)}) ?
+ LJ::get_cluster_master($u) :
+ LJ::get_db_writer();
+ }
+ unless ($db) {
+ $db = ($table =~ m{userprop(lite2|blob)}) ?
+ LJ::get_cluster_reader($u) :
+ LJ::get_db_reader();
+ $used_slave = 1;
+ }
+ $sql = "SELECT upropid, value FROM $table WHERE userid=$uid";
+ if (ref $loadfrom{$table}) {
+ $sql .= " AND upropid IN (" . join(",", @{$loadfrom{$table}}) .
")";
+ }
+ $sth = $db->prepare($sql);
+ $sth->execute;
+ while (my ($id, $v) = $sth->fetchrow_array) {
+ delete $multihomed{$id} if $table eq 'userproplite2';
+ $u->{$LJ::CACHE_PROPID{'user'}->{$id}->{'name'}} = $v;
+ }
+
+ # push back multihomed if necessary
+ if ($table eq 'userproplite2') {
+ push @{$loadfrom{userprop}}, $_ foreach keys %multihomed;
+ }
+ }
+
+ # see if we failed to get anything above and need to hit the master.
+ # this usually happens the first time a multihomed prop is hit. this
+ # code will propagate that prop down to the cluster.
+ if (%multihomed) {
+
+ # verify that we got the database handle before we try propagating data
+ if ($u->writer) {
+ my @values;
+ foreach my $id (keys %multihomed) {
+ my $pname = $LJ::CACHE_PROPID{user}{$id}{name};
+ if (defined $u->{$pname} && $u->{$pname}) {
+ push @values, "($uid, $id, " . $u->quote($u->{$pname}) .
")";
+ } else {
+ push @values, "($uid, $id, '')";
+ }
+ }
+ $u->do("REPLACE INTO userproplite2 VALUES " . join ',', @values);
+ }
+ }
+
+ # Add defaults to user object.
+
+ # If this was called with no @props, then the function tried
+ # to load all metadata. but we don't know what's missing, so
+ # try to apply all defaults.
+ unless (@props) { @props = keys %LJ::USERPROP_DEF; }
+
+ foreach my $prop (@props) {
+ next if (defined $u->{$prop});
+ $u->{$prop} = $LJ::USERPROP_DEF{$prop};
+ }
+
+ unless ($used_slave) {
+ my $expire = time() + 3600*24;
+ foreach my $wr (@needwrite) {
+ my ($id, $name) = ($wr->[0], $wr->[1]);
+ LJ::MemCache::set([$uid,"uprop:$uid:$id"], $u->{$name} || "",
$expire);
+ }
+ }
}
@@ -1095,6 +1242,16 @@ sub record_login {
return $u->do("INSERT INTO loginlog SET userid=?, sessid=?,
logintime=UNIX_TIMESTAMP(), ".
"ip=?, ua=?", undef, $u->userid, $sessid, $ip, $ua);
+}
+
+
+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 );
}
@@ -7145,163 +7302,6 @@ sub get_bio {
# <LJFUNC>
-# name: LJ::load_user_props
-# des: Given a user hashref, loads the values of the given named properties
-# into that user hashref.
-# args: dbarg?, u, opts?, propname*
-# des-opts: hashref of opts. set key 'cache' to use memcache.
-# des-propname: the name of a property from the [dbtable[userproplist]] table.
-# </LJFUNC>
-sub load_user_props
-{
- &nodb;
-
- my $u = shift;
- return unless isu($u);
- return if $u->is_expunged;
-
- my $opts = ref $_[0] ? shift : {};
- my (@props) = @_;
-
- my ($sql, $sth);
- LJ::load_props("user");
-
- ## user reference
- my $uid = $u->userid + 0;
- $uid = LJ::get_userid( $u->user ) unless $uid;
-
- my $mem = {};
- my $use_master = 0;
- my $used_slave = 0; # set later if we ended up using a slave
-
- if (@LJ::MEMCACHE_SERVERS) {
- my @keys;
- foreach (@props) {
- next if exists $u->{$_};
- my $p = LJ::get_prop("user", $_);
- die "Invalid userprop $_ passed to LJ::load_user_props." unless $p;
- push @keys, [$uid,"uprop:$uid:$p->{'id'}"];
- }
- $mem = LJ::MemCache::get_multi(@keys) || {};
- $use_master = 1;
- }
-
- $use_master = 1 if $opts->{'use_master'};
-
- my @needwrite; # [propid, propname] entries we need to save to memcache
later
-
- my %loadfrom;
- my %multihomed; # ( $propid => 0/1 ) # 0 if we haven't loaded it, 1 if we
have
- unless (@props) {
- # case 1: load all props for a given user.
- # multihomed props are stored on userprop and userproplite2, but since
they
- # should always be in sync, it doesn't matter which gets loaded first,
the
- # net results should be the same. see
doc/server/lj.int.multihomed_userprops.html
- # for more information.
- $loadfrom{'userprop'} = 1;
- $loadfrom{'userproplite'} = 1;
- $loadfrom{'userproplite2'} = 1;
- $loadfrom{'userpropblob'} = 1;
- } else {
- # case 2: load only certain things
- foreach (@props) {
- next if exists $u->{$_};
- my $p = LJ::get_prop("user", $_);
- die "Invalid userprop $_ passed to LJ::load_user_props." unless $p;
- if (defined $mem->{"uprop:$uid:$p->{'id'}"}) {
- $u->{$_} = $mem->{"uprop:$uid:$p->{'id'}"};
- next;
- }
- push @needwrite, [ $p->{'id'}, $_ ];
- my $source = $p->{'indexed'} ? "userprop" : "userproplite";
- if ($p->{datatype} eq 'blobchar') {
- $source = "userpropblob"; # clustered blob
- }
- elsif ( $p->{'cldversion'} && $u->dversion >= $p->{'cldversion'} )
{
- $source = "userproplite2"; # clustered
- }
- elsif ($p->{multihomed}) {
- $multihomed{$p->{id}} = 0;
- $source = "userproplite2";
- }
- push @{$loadfrom{$source}}, $p->{'id'};
- }
- }
-
- foreach my $table (qw{userproplite userproplite2 userpropblob userprop}) {
- next unless exists $loadfrom{$table};
- my $db;
- if ($use_master) {
- $db = ($table =~ m{userprop(lite2|blob)}) ?
- LJ::get_cluster_master($u) :
- LJ::get_db_writer();
- }
- unless ($db) {
- $db = ($table =~ m{userprop(lite2|blob)}) ?
- LJ::get_cluster_reader($u) :
- LJ::get_db_reader();
- $used_slave = 1;
- }
- $sql = "SELECT upropid, value FROM $table WHERE userid=$uid";
- if (ref $loadfrom{$table}) {
- $sql .= " AND upropid IN (" . join(",", @{$loadfrom{$table}}) .
")";
- }
- $sth = $db->prepare($sql);
- $sth->execute;
- while (my ($id, $v) = $sth->fetchrow_array) {
- delete $multihomed{$id} if $table eq 'userproplite2';
- $u->{$LJ::CACHE_PROPID{'user'}->{$id}->{'name'}} = $v;
- }
-
- # push back multihomed if necessary
- if ($table eq 'userproplite2') {
- push @{$loadfrom{userprop}}, $_ foreach keys %multihomed;
- }
- }
-
- # see if we failed to get anything above and need to hit the master.
- # this usually happens the first time a multihomed prop is hit. this
- # code will propagate that prop down to the cluster.
- if (%multihomed) {
-
- # verify that we got the database handle before we try propagating data
- if ($u->writer) {
- my @values;
- foreach my $id (keys %multihomed) {
- my $pname = $LJ::CACHE_PROPID{user}{$id}{name};
- if (defined $u->{$pname} && $u->{$pname}) {
- push @values, "($uid, $id, " . $u->quote($u->{$pname}) .
")";
- } else {
- push @values, "($uid, $id, '')";
- }
- }
- $u->do("REPLACE INTO userproplite2 VALUES " . join ',', @values);
- }
- }
-
- # Add defaults to user object.
-
- # If this was called with no @props, then the function tried
- # to load all metadata. but we don't know what's missing, so
- # try to apply all defaults.
- unless (@props) { @props = keys %LJ::USERPROP_DEF; }
-
- foreach my $prop (@props) {
- next if (defined $u->{$prop});
- $u->{$prop} = $LJ::USERPROP_DEF{$prop};
- }
-
- unless ($used_slave) {
- my $expire = time() + 3600*24;
- foreach my $wr (@needwrite) {
- my ($id, $name) = ($wr->[0], $wr->[1]);
- LJ::MemCache::set([$uid,"uprop:$uid:$id"], $u->{$name} || "",
$expire);
- }
- }
-}
-
-
-# <LJFUNC>
# name: LJ::modify_caps
# des: Given a list of caps to add and caps to remove, updates a user's caps.
# args: uuid, cap_add, cap_del, res
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/bml/scheme/blueshift.look
--- a/cgi-bin/bml/scheme/blueshift.look Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/bml/scheme/blueshift.look Sun Jun 13 22:44:34 2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/blueshift/blueshift.css" );
+ LJ::need_res( "stc/lj_base-app.css" );
+ LJ::need_res( "stc/blueshift/blueshift.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/bml/scheme/celerity.look
--- a/cgi-bin/bml/scheme/celerity.look Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/bml/scheme/celerity.look Sun Jun 13 22:44:34 2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/celerity/celerity.css" );
+ LJ::need_res( "stc/lj_base-app.css" );
+ LJ::need_res( "stc/celerity/celerity.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r 64de350ea481 -r a8493c11bfce
cgi-bin/bml/scheme/gradation-horizontal.look
--- a/cgi-bin/bml/scheme/gradation-horizontal.look Fri Jun 11 13:52:12
2010 +0800
+++ b/cgi-bin/bml/scheme/gradation-horizontal.look Sun Jun 13 22:44:34
2010 +0800
@@ -40,11 +40,11 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/gradation/gradation.css" );
+ LJ::need_res( "stc/lj_base-app.css" );
+ LJ::need_res( "stc/gradation/gradation.css" );
- LJ::need_res( { group => 'jquery', priority =>
$LJ::SCHEME_RES_PRIORITY }, "js/nav-jquery.js" );
- LJ::need_res( { group => 'default', priority =>
$LJ::SCHEME_RES_PRIORITY }, "js/nav.js" );
+ LJ::need_res( {group=>'jquery'}, "js/nav-jquery.js" );
+ LJ::need_res( {group=>'default'}, "js/nav.js" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/bml/scheme/gradation-vertical.look
--- a/cgi-bin/bml/scheme/gradation-vertical.look Fri Jun 11 13:52:12
2010 +0800
+++ b/cgi-bin/bml/scheme/gradation-vertical.look Sun Jun 13 22:44:34
2010 +0800
@@ -40,8 +40,8 @@ head<=
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<?_code
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/gradation/gradation.css" );
+ LJ::need_res( "stc/lj_base-app.css" );
+ LJ::need_res( "stc/gradation/gradation.css" );
_code?>
<?_code LJ::res_includes(); _code?>
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/bml/scheme/lynx.look
--- a/cgi-bin/bml/scheme/lynx.look Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/bml/scheme/lynx.look Sun Jun 13 22:44:34 2010 +0800
@@ -32,7 +32,7 @@ page<=
<link rel="help" title="<?_ml lynx.nav.help _ml?>"
href="<?siteroot?>/support/" />
<?_code
use strict;
- LJ::need_res( { priority => $LJ::SCHEME_RES_PRIORITY },
"stc/lj_base-app.css" );
+ LJ::need_res("stc/lj_base-app.css");
my $crumb_up;
if (LJ::get_active_crumb() ne '') {
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/ljdefaults.pl
--- a/cgi-bin/ljdefaults.pl Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/ljdefaults.pl Sun Jun 13 22:44:34 2010 +0800
@@ -327,11 +327,6 @@
# default to limit to 50,000 watch or trust edges to load
$LJ::MAX_WT_EDGES_LOAD ||= 50_000;
-
- # the default priority for resources in a sitescheme,
- # so that they come before any stylesheets declared by the page itself
- # not really expected to change
- $LJ::SCHEME_RES_PRIORITY = 2;
}
return 1;
diff -r 64de350ea481 -r a8493c11bfce cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Fri Jun 11 13:52:12 2010 +0800
+++ b/cgi-bin/weblib.pl Sun Jun 13 22:44:34 2010 +0800
@@ -2399,9 +2399,6 @@ sub need_res {
my $group = $opts{group};
- # higher priority means it comes first in the ordering
- my $priority = $opts{priority} || 0;
-
foreach my $reskey (@_) {
die "Bogus reskey $reskey" unless $reskey =~ m!^(js|stc)/!;
@@ -2409,9 +2406,7 @@ sub need_res {
# since we need CSS everywhere and we are switching JS groups
my $lgroup = $group || ( $reskey =~ /^js/ ? 'default' : 'all' );
unless ($LJ::NEEDED_RES{$lgroup}->{$reskey}++) {
- $LJ::NEEDED_RES[$priority] ||= [];
-
- push @{$LJ::NEEDED_RES[$priority]}, [ $lgroup, $reskey ];
+ push @LJ::NEEDED_RES, [ $lgroup, $reskey ];
}
}
}
@@ -2520,42 +2515,39 @@ sub res_includes {
$oldest{$type} = $modtime if $modtime > $oldest{$type};
};
- foreach my $by_priority ( reverse @LJ::NEEDED_RES ) {
- next unless $by_priority;
+ foreach my $resrow (@LJ::NEEDED_RES) {
- foreach my $resrow ( @$by_priority ) {
- # determine if this resource is part of the resource group that is
active;
- # or 'default' if no group explicitly active
- my ( $group, $key ) = @$resrow;
- next if
- $group ne 'all' &&
- ( ( defined $LJ::ACTIVE_RES_GROUP && $group ne
$LJ::ACTIVE_RES_GROUP ) ||
- ( ! defined $LJ::ACTIVE_RES_GROUP && $group ne 'default' ) );
-
- my $path;
- my $mtime = _file_modtime($key, $now);
- if ($key =~ m!^stc/fck/! || $LJ::FORCE_WSTAT{$key}) {
- $path = "w$key"; # wstc/ instead of stc/
- } else {
- $path = $key;
+ # determine if this resource is part of the resource group that is
active;
+ # or 'default' if no group explicitly active
+ my ( $group, $key ) = @$resrow;
+ next if
+ $group ne 'all' &&
+ ( ( defined $LJ::ACTIVE_RES_GROUP && $group ne
$LJ::ACTIVE_RES_GROUP ) ||
+ ( ! defined $LJ::ACTIVE_RES_GROUP && $group ne 'default' ) );
+
+ my $path;
+ my $mtime = _file_modtime($key, $now);
+ if ($key =~ m!^stc/fck/! || $LJ::FORCE_WSTAT{$key}) {
+ $path = "w$key"; # wstc/ instead of stc/
+ } else {
+ $path = $key;
+ }
+
+ # if we want to also include a local version of this file, include
that too
+ if (@LJ::USE_LOCAL_RES) {
+ if (grep { lc $_ eq lc $key } @LJ::USE_LOCAL_RES) {
+ my $inc = $key;
+ $inc =~ s/(\w+)\.(\w+)$/$1-local.$2/;
+ LJ::need_res($inc);
}
-
- # if we want to also include a local version of this file, include
that too
- if (@LJ::USE_LOCAL_RES) {
- if (grep { lc $_ eq lc $key } @LJ::USE_LOCAL_RES) {
- my $inc = $key;
- $inc =~ s/(\w+)\.(\w+)$/$1-local.$2/;
- LJ::need_res($inc);
- }
- }
-
- if ($path =~ m!^js/(.+)!) {
- $add->('js', $1, $mtime);
- } elsif ($path =~ /\.css$/ && $path =~ m!^(w?)stc/(.+)!) {
- $add->("${1}stccss", $2, $mtime);
- } elsif ($path =~ /\.js$/ && $path =~ m!^(w?)stc/(.+)!) {
- $add->("${1}stcjs", $2, $mtime);
- }
+ }
+
+ if ($path =~ m!^js/(.+)!) {
+ $add->('js', $1, $mtime);
+ } elsif ($path =~ /\.css$/ && $path =~ m!^(w?)stc/(.+)!) {
+ $add->("${1}stccss", $2, $mtime);
+ } elsif ($path =~ /\.js$/ && $path =~ m!^(w?)stc/(.+)!) {
+ $add->("${1}stcjs", $2, $mtime);
}
}
diff -r 64de350ea481 -r a8493c11bfce htdocs/moodlist.bml
--- a/htdocs/moodlist.bml Fri Jun 11 13:52:12 2010 +0800
+++ b/htdocs/moodlist.bml Sun Jun 13 22:44:34 2010 +0800
@@ -73,6 +73,8 @@ body<=
}
@themes = sort { lc($a->{name}) cmp lc($b->{name}) } @themes;
my @special_themes = LJ::Hooks::run_hook('modify_mood_theme_list',
\...@themes, user => $u);
+ # validate the list (should only contain hashrefs)
+ @special_themes = grep { ref $_ } @special_themes;
my $do_mood_list = sub {
# Setup the paging bar
diff -r 64de350ea481 -r a8493c11bfce htdocs/talkpost.bml
--- a/htdocs/talkpost.bml Fri Jun 11 13:52:12 2010 +0800
+++ b/htdocs/talkpost.bml Sun Jun 13 22:44:34 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 64de350ea481 -r a8493c11bfce htdocs/talkread.bml
--- a/htdocs/talkread.bml Fri Jun 11 13:52:12 2010 +0800
+++ b/htdocs/talkread.bml Sun Jun 13 22:44:34 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 64de350ea481 -r a8493c11bfce htdocs/view/index.bml
--- a/htdocs/view/index.bml Fri Jun 11 13:52:12 2010 +0800
+++ b/htdocs/view/index.bml Sun Jun 13 22:44:34 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();
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog