Commit 6d9b66f7 authored by Nigel McNie's avatar Nigel McNie
Browse files

Fix problem where only the first reply to any post was being shown for me. Now...

Fix problem where only the first reply to any post was being shown for me. Now all posts in a thread are shown.

The symptoms I saw only happened because I replied in succession to the last post.

The problem was caused by looping over a reference variable that was then passed to a recursive function. I think internally PHP moved the array pointer for it to the very end when it reached the first time there were no children, then when it was coming back up through the recursion all the loops were being finished.
parent bdb2c734
...@@ -161,6 +161,7 @@ $smarty->display('interaction:forum:topic.tpl'); ...@@ -161,6 +161,7 @@ $smarty->display('interaction:forum:topic.tpl');
function buildthread($parent, $parentsubject, &$posts){ function buildthread($parent, $parentsubject, &$posts){
global $moderator; global $moderator;
global $topic; global $topic;
$localposts = $posts;
if ($posts[$parent]->subject) { if ($posts[$parent]->subject) {
$parentsubject = $posts[$parent]->subject; $parentsubject = $posts[$parent]->subject;
} }
...@@ -168,7 +169,7 @@ function buildthread($parent, $parentsubject, &$posts){ ...@@ -168,7 +169,7 @@ function buildthread($parent, $parentsubject, &$posts){
$posts[$parent]->subject = get_string('re', 'interaction.forum', $parentsubject); $posts[$parent]->subject = get_string('re', 'interaction.forum', $parentsubject);
} }
$children = array(); $children = array();
foreach ($posts as $index => $post) { foreach ($localposts as $index => $post) {
if ($posts[$index]->parent == $posts[$parent]->id) { if ($posts[$index]->parent == $posts[$parent]->id) {
$children[] = buildthread($index, $parentsubject, $posts); $children[] = buildthread($index, $parentsubject, $posts);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment