Андрей (andy) wrote in changelog,
Андрей
andy
changelog

[livejournal] r19036: LJSUP-8762 (comments not posted)

Committer: ailyin
LJSUP-8762 (comments not posted)
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-05-06 06:49:40 UTC (rev 19035)
+++ trunk/cgi-bin/LJ/User.pm	2011-05-06 06:52:12 UTC (rev 19036)
@@ -1263,12 +1263,17 @@
     return $url;
 }
 
-# returns LJ::Identity object
-sub identity {
-    my $u = shift;
-    return $u->{_identity} if $u->{_identity};
-    return undef unless $u->{'journaltype'} eq "I";
+# there are two procedures for finding an LJ::Identity object for the given
+# user, the difference being that identity() checks for journaltype eq 'I'
+# while find_identity() does not. this is done this way for backwards
+# compatibility: some parts of LJ code use identity() to check what
+# is_identity() checks (suboptimal, yes, but it works that way)
 
+sub find_identity {
+    my ($u) = @_;
+
+    return $u->{'_identity'} if $u->{'_identity'};
+
     my $memkey = [$u->{userid}, "ident:$u->{userid}"];
     my $ident = LJ::MemCache::get($memkey);
     if ($ident) {
@@ -1295,6 +1300,13 @@
     return;
 }
 
+sub identity {
+    my ($u) = @_;
+
+    return unless $u->is_identity;
+    return $u->find_identity;
+}
+
 # returns a URL if account is an OpenID identity.  undef otherwise.
 sub openid_identity {
     my $u = shift;

Tags: andy, livejournal, pm
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