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

[livejournal] r17821: LJSUP-7462 (refactor userprops): pick up...

Committer: ailyin
LJSUP-7462 (refactor userprops): pick up default props correctly
U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2010-11-30 03:17:46 UTC (rev 17820)
+++ trunk/cgi-bin/LJ/User.pm	2010-11-30 03:44:48 UTC (rev 17821)
@@ -5742,6 +5742,26 @@
     $u->{'packed_props'} = 1;
 }
 
+sub init_userprop_def {
+    my ($class) = @_;
+
+    # defaults for S1 style IDs in config file are magic: really
+    # uniq strings representing style IDs, so on first use, we need
+    # to map them
+    unless ($LJ::CACHED_S1IDMAP) {
+        my $pubsty = LJ::S1::get_public_styles();
+        foreach (values %$pubsty) {
+            my $k = "s1_$_->{'type'}_style";
+            my $needval = "$_->{'type'}/$_->{'styledes'}";
+            next unless $LJ::USERPROP_DEF{$k} eq $needval;
+
+            $LJ::USERPROP_DEF{$k} = $_->{'styleid'};
+        }
+
+        $LJ::CACHED_S1IDMAP = 1;
+    }
+}
+
 sub reset_cache {
     my $u = shift;
 
@@ -6098,6 +6118,13 @@
             $handler->store_props_memcache( $u, $propmap_db );
         }
     }
+
+    LJ::User->init_userprop_def;
+    foreach my $propname (@props) {
+        next if defined $u->{$propname};
+        next unless defined $LJ::USERPROP_DEF{$propname};
+        $u->{$propname} = $LJ::USERPROP_DEF{$propname};
+    }
 }
 
 # <LJFUNC>

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