[dw-free] Use memcache and process cache for mood themes
[commit: http://hg.dwscoalition.org/dw-free/rev/1fe8edab0500]
http://bugs.dwscoalition.org/show_bug.cgi?id=526
Process cache moodtheme list.
This patch was pulled from the LiveJournal.com repository.
Patch by
denise.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=526
Process cache moodtheme list.
This patch was pulled from the LiveJournal.com repository.
Patch by
![[staff profile]](https://www.dreamwidth.org/img/silk/identity/user_staff.png)
Files modified:
- cgi-bin/LJ/Widget/MoodThemeChooser.pm
- cgi-bin/ljmood.pl
-------------------------------------------------------------------------------- diff -r b069deabc426 -r 1fe8edab0500 cgi-bin/LJ/Widget/MoodThemeChooser.pm --- a/cgi-bin/LJ/Widget/MoodThemeChooser.pm Tue Mar 31 05:22:00 2009 +0000 +++ b/cgi-bin/LJ/Widget/MoodThemeChooser.pm Tue Mar 31 05:29:00 2009 +0000 @@ -78,6 +78,9 @@ sub render_body { } $ret .= "<p><a href='$LJ::SITEROOT/moodlist.bml?moodtheme=$preview_moodthemeid'>" . $class->ml('widget.moodthemechooser.viewtheme') . "</a></p>"; $ret .= "</td></tr></table>"; + my $mood_des = LJ::mood_theme_des($preview_moodthemeid); + LJ::CleanHTML::clean (\$mood_des); + $ret .= "<p>".$mood_des."</p>"; $ret .= "</div>"; } diff -r b069deabc426 -r 1fe8edab0500 cgi-bin/ljmood.pl --- a/cgi-bin/ljmood.pl Tue Mar 31 05:22:00 2009 +0000 +++ b/cgi-bin/ljmood.pl Tue Mar 31 05:29:00 2009 +0000 @@ -32,6 +32,14 @@ sub load_mood_theme while (my ($id, $pic, $w, $h) = $sth->fetchrow_array) { $LJ::CACHE_MOOD_THEME{$themeid}->{$id} = { 'pic' => $pic, 'w' => $w, 'h' => $h }; } + + my $des_sth = $dbh->prepare("SELECT name, des FROM moodthemes WHERE moodthemeid=?"); + $des_sth->execute($themeid); + return 0 if $dbh->err; + + my ($name, $des) = $des_sth->fetchrow_array; + $LJ::CACHE_MOOD_THEME{$themeid}->{name} = $name; + $LJ::CACHE_MOOD_THEME{$themeid}->{des} = $des; # set in memcache LJ::MemCache::set($memkey, $LJ::CACHE_MOOD_THEME{$themeid}, 3600) @@ -107,6 +115,15 @@ sub mood_name return $m ? $m->{'name'} : undef; } +# mood id to desc +sub mood_theme_des +{ + my ($themeid) = @_; + LJ::load_mood_theme($themeid); + my $m = $LJ::CACHE_MOOD_THEME{$themeid}; + return $m ? $m->{'des'} : undef; +} + # mood name to id (or undef) sub mood_id { --------------------------------------------------------------------------------