madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r23145: LJSUP-13883: Journal pages optimizaiton ...

Committer: sbelyaev
LJSUP-13883: Journal pages optimizaiton : stage 1
U   trunk/cgi-bin/LJ/RelationService.pm
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/RelationService.pm
===================================================================
--- trunk/cgi-bin/LJ/RelationService.pm	2012-10-16 07:55:11 UTC (rev 23144)
+++ trunk/cgi-bin/LJ/RelationService.pm	2012-10-16 08:24:30 UTC (rev 23145)
@@ -183,37 +183,15 @@
     my $type   = shift;
     my %opts   = @_;
 
-    $u = LJ::want_user($u);
-    $friend = LJ::want_user($friend);
-    
     return undef unless $u && $friend && $type;
 
-    return $singletons{$u->{userid}}->{$friend->{userid}}->{$type}
-        if exists $singletons{$u->{userid}}->{$friend->{userid}}->{$type} && !%opts;
+    unless (UNIVERSAL::isa($u, 'LJ::User') && UNIVERSAL::isa($friend, 'LJ::User')) {
+        $u = LJ::want_user($u);
+        $friend = LJ::want_user($friend);
 
-    if ($class->_load_alt_api('read', $type)) {
-        my $alt = $class->alt_api($u);
-        if ($alt) {
-            $alt->is_relation_to($u, $friend, $type, %opts);
-        }
+        return undef unless $u && $friend && $type;
     }
 
-    my $interface = $class->relation_api($u);
-    my $relation = $interface->is_relation_to($u, $friend, $type, %opts);   
-    $singletons{$u->{userid}}->{$friend->{userid}}->{$type} = $relation;
-    return $relation;
-}
-
-sub is_relation_to_v2 {
-    my $class  = shift;
-    my $u      = shift;
-    my $friend = shift;
-    my $type   = shift;
-    my %opts   = @_;
-
-    return undef unless $u && $friend && $type &&
-                            $u->isa('LJ::User') && $friend->isa('LJ::User');
-
     return $singletons{$u->{userid}}->{$friend->{userid}}->{$type}
         if exists $singletons{$u->{userid}}->{$friend->{userid}}->{$type} && !%opts;
 
@@ -225,7 +203,7 @@
     }
 
     my $interface = $class->relation_api($u);
-    my $relation = $interface->is_relation_to($u, $friend, $type, %opts);
+    my $relation = $interface->is_relation_to($u, $friend, $type, %opts);   
     $singletons{$u->{userid}}->{$friend->{userid}}->{$type} = $relation;
     return $relation;
 }

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-10-16 07:55:11 UTC (rev 23144)
+++ trunk/cgi-bin/LJ/User.pm	2012-10-16 08:24:30 UTC (rev 23145)
@@ -5660,7 +5660,7 @@
     return undef if $u->{journaltype} =~ /^[PYR]$/;
 
     # check for supermaintainer access
-    return 1 if LJ::RelationService->is_relation_to_v2($u, $remote, 'S');
+    return 1 if LJ::RelationService->is_relation_to($u, $remote, 'S');
 
     # not passed checks, return false
     return undef;
@@ -5687,7 +5687,7 @@
     return undef if $u->{journaltype} =~ /^[PYR]$/;
 
     # check for moderate access
-    return 1 if LJ::RelationService->is_relation_to_v2($u, $remote, 'M');
+    return 1 if LJ::RelationService->is_relation_to($u, $remote, 'M');
 
     # passed not checks, return false
     return undef;
@@ -5716,7 +5716,7 @@
     # check for supermaintainer
     return 1 if $remote->can_super_manage($u);
 
-    return 0 unless LJ::RelationService->is_relation_to_v2($u, $remote, 'A');
+    return 0 unless LJ::RelationService->is_relation_to($u, $remote, 'A');
 
     # passed checks, return true
     return 1;

Tags: livejournal, madeon, pm, sbelyaev
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments