[livejournal] r17411: LJM-1447: added special mode to sup-rpc ...
Committer: vsukhanov
LJM-1447: added special mode to sup-rpc command "comment_tree" that allows m.livejournal.com to load only needed for mobile version comments.U trunk/cgi-bin/LJ/Talk.pm
Modified: trunk/cgi-bin/LJ/Talk.pm
===================================================================
--- trunk/cgi-bin/LJ/Talk.pm 2010-09-20 07:19:49 UTC (rev 17410)
+++ trunk/cgi-bin/LJ/Talk.pm 2010-09-20 09:44:05 UTC (rev 17411)
@@ -742,7 +742,7 @@
}
sub get_talk_data {
- my ($u, $nodetype, $nodeid) = @_;
+ my ($u, $nodetype, $nodeid, $opts) = @_;
return undef unless LJ::isu($u);
return undef unless $nodetype =~ /^\w$/;
return undef unless $nodeid =~ /^\d+$/;
@@ -750,12 +750,12 @@
# call normally if no gearman/not wanted
my $gc = LJ::gearman_client();
- return get_talk_data_do($uid, $nodetype, $nodeid)
+ return get_talk_data_do($uid, $nodetype, $nodeid, $opts)
unless $gc && LJ::conf_test($LJ::LOADCOMMENTS_USING_GEARMAN, $u->id);
# invoke gearman
my $result;
- my @a = ($uid, $nodetype, $nodeid);
+ my @a = ($uid, $nodetype, $nodeid, $opts);
my $args = Storable::nfreeze(\@a);
my $task = Gearman::Task->new("get_talk_data", \$args,
{
@@ -779,12 +779,15 @@
# 'parenttalkid', 'state' } , or undef on failure
sub get_talk_data_do
{
- my ($uid, $nodetype, $nodeid) = @_;
+ my ($uid, $nodetype, $nodeid, $opts) = @_;
my $u = LJ::want_user($uid);
return undef unless LJ::isu($u);
return undef unless $nodetype =~ /^\w$/;
return undef unless $nodeid =~ /^\d+$/;
+ my $init_comobj = 1;
+ $init_comobj = $opts->{init_comobj} if exists $opts->{init_comobj};
+
my $ret = {};
# check for data in memcache
@@ -826,8 +829,8 @@
my $make_comment_singleton = sub {
my ($jtalkid, $row) = @_;
+ return 1 unless $init_comobj;
return 1 unless $nodetype eq 'L';
-
# at this point we have data for this comment loaded in memory
# -- instantiate an LJ::Comment object as a singleton and absorb
# that data into the object
@@ -1095,7 +1098,8 @@
my $n = $u->{'clusterid'};
my $viewall = $opts->{viewall};
- my $posts = get_talk_data($u, $nodetype, $nodeid); # hashref, talkid -> talk2 row, or undef
+ my $gtd_opts = {init_comobj => $opts->{init_comobj}};
+ my $posts = get_talk_data($u, $nodetype, $nodeid, $gtd_opts); # hashref, talkid -> talk2 row, or undef
unless ($posts) {
$opts->{'out_error'} = "nodb";
return;
