Skip to content

Commit

Permalink
Bugfix for posts with many replies:
Browse files Browse the repository at this point in the history
If a post has more than 350 replies, Smarty would run out of memory and become unable to render the page; this change caps the reply list at 350.
  • Loading branch information
ginatrapani committed Apr 26, 2010
1 parent ac43c0f commit 2bf9285
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions webapp/common/class.Post.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ function getStandaloneReplies($username, $limit) {
return $strays;
}

function getRepliesToPost($post_id, $public = false) {
function getRepliesToPost($post_id, $public = false, $count=350) {
$condition = "";
if ($public)
$condition = "AND u.is_protected = 0";
Expand All @@ -117,7 +117,9 @@ function getRepliesToPost($post_id, $public = false) {
$q .= " LEFT JOIN #prefix#links AS l ON l.post_id = t.post_id ";
$q .= " INNER JOIN #prefix#users AS u ON t.author_user_id = u.user_id ";
$q .= " WHERE in_reply_to_post_id=".$post_id." ".$condition;
$q .= " ORDER BY follower_count desc;";
$q .= " ORDER BY follower_count desc ";
$q .= " LIMIT $count; ";

$sql_result = $this->executeSQL($q);
$posts_stored = array();
while ($row = mysql_fetch_assoc($sql_result)) {
Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/post.index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<div class="grid_23 omega append_20">
{if $replies}
<h2 class="subhead">
{if $reply_count eq 1}Reply{else}{$reply_count} Replies{/if}
{if $post->mention_count_cache eq 1}Reply{else}{$post->mention_count_cache} Replies{/if}
({$private_reply_count} private)
</h2>
{/if}
Expand Down
2 changes: 1 addition & 1 deletion webapp/templates/public.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div class="grid_7 center big-number omega">
<div class="bl">
<div class="key-stat">
<h1>{$replies|@count|number_format}</h1>
<h1>{$post->mention_count_cache|number_format}</h1>
<h3>replies in {$post->adj_pub_date|relative_datetime}</h3>
</div>
</div>
Expand Down

0 comments on commit 2bf9285

Please sign in to comment.