mirror of
https://github.com/sbrl/Pepperminty-Wiki.git
synced 2024-11-22 04:23:01 +00:00
Fix nasty bug in find_comment
This commit is contained in:
parent
8dbd6abe68
commit
06ddf4c454
3 changed files with 13 additions and 19 deletions
|
@ -2149,21 +2149,18 @@ register_module([
|
||||||
$parent_comment = find_comment($comment_data, $reply_to);
|
$parent_comment = find_comment($comment_data, $reply_to);
|
||||||
if($parent_comment === false) {
|
if($parent_comment === false) {
|
||||||
http_response_code(422);
|
http_response_code(422);
|
||||||
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>$settings->sitename couldn't post your comment because it couldn't find the parent comment you replied to. It's possible that $settings->adamindetails_name, $settings->sitename's administrator, deleted the comment. Here's the comment you tried to post:</p>
|
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>$settings->sitename couldn't post your comment because it couldn't find the parent comment you replied to. It's possible that $settings->admindetails_name, $settings->sitename's administrator, deleted the comment. Here's the comment you tried to post:</p>
|
||||||
<textarea readonly>$message</textarea>"));
|
<textarea readonly>$message</textarea>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent_comment->replies[] = $new_comment;
|
$parent_comment->replies[] = $new_comment;
|
||||||
|
|
||||||
$comment_thread = fetch_comment_thread($comment_data, $new_comment->id);
|
// Get an array of all the parent comments we need to notify
|
||||||
|
$comment_thread = fetch_comment_thread($comment_data, $parent_comment->id);
|
||||||
|
|
||||||
$email_subject = "[Notification] $env->user replied to your comment on $env->page - $settings->sitename";
|
$email_subject = "[Notification] $env->user replied to your comment on $env->page - $settings->sitename";
|
||||||
|
|
||||||
foreach($comment_thread as $thread_comment) {
|
foreach($comment_thread as $thread_comment) {
|
||||||
// Don't notify the comment poster of their own comment :P
|
|
||||||
if($thread_comment->id == $new_comment->id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$email_body = "Hello, {username}!\n" .
|
$email_body = "Hello, {username}!\n" .
|
||||||
"It's $settings->sitename here, letting you know that " .
|
"It's $settings->sitename here, letting you know that " .
|
||||||
"someone replied to your comment (or a reply to your comment) on $env->page.\n" .
|
"someone replied to your comment (or a reply to your comment) on $env->page.\n" .
|
||||||
|
@ -2301,15 +2298,15 @@ function find_comment($comment_data, $comment_id)
|
||||||
return $comment;
|
return $comment;
|
||||||
|
|
||||||
if(count($comment->replies) > 0) {
|
if(count($comment->replies) > 0) {
|
||||||
$subtrees = $comment->replies;
|
$subtrees[] = $comment->replies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($subtrees as $subtree)
|
foreach($subtrees as $subtree)
|
||||||
{
|
{
|
||||||
$subtree_result = find_comment($subtree);
|
$subtree_result = find_comment($subtree, $comment_id);
|
||||||
if($subtree_result !== false)
|
if($subtree_result !== false)
|
||||||
return $subtree;
|
return $subtree_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -50,7 +50,7 @@
|
||||||
"author": "Starbeamrainbowlabs",
|
"author": "Starbeamrainbowlabs",
|
||||||
"description": "Adds threaded comments to the bottom of every page.",
|
"description": "Adds threaded comments to the bottom of every page.",
|
||||||
"id": "feature-comments",
|
"id": "feature-comments",
|
||||||
"lastupdate": 1495278880,
|
"lastupdate": 1495287819,
|
||||||
"optional": false
|
"optional": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,21 +77,18 @@ register_module([
|
||||||
$parent_comment = find_comment($comment_data, $reply_to);
|
$parent_comment = find_comment($comment_data, $reply_to);
|
||||||
if($parent_comment === false) {
|
if($parent_comment === false) {
|
||||||
http_response_code(422);
|
http_response_code(422);
|
||||||
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>$settings->sitename couldn't post your comment because it couldn't find the parent comment you replied to. It's possible that $settings->adamindetails_name, $settings->sitename's administrator, deleted the comment. Here's the comment you tried to post:</p>
|
exit(page_renderer::render_main("Error posting comment - $settings->sitename", "<p>$settings->sitename couldn't post your comment because it couldn't find the parent comment you replied to. It's possible that $settings->admindetails_name, $settings->sitename's administrator, deleted the comment. Here's the comment you tried to post:</p>
|
||||||
<textarea readonly>$message</textarea>"));
|
<textarea readonly>$message</textarea>"));
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent_comment->replies[] = $new_comment;
|
$parent_comment->replies[] = $new_comment;
|
||||||
|
|
||||||
$comment_thread = fetch_comment_thread($comment_data, $new_comment->id);
|
// Get an array of all the parent comments we need to notify
|
||||||
|
$comment_thread = fetch_comment_thread($comment_data, $parent_comment->id);
|
||||||
|
|
||||||
$email_subject = "[Notification] $env->user replied to your comment on $env->page - $settings->sitename";
|
$email_subject = "[Notification] $env->user replied to your comment on $env->page - $settings->sitename";
|
||||||
|
|
||||||
foreach($comment_thread as $thread_comment) {
|
foreach($comment_thread as $thread_comment) {
|
||||||
// Don't notify the comment poster of their own comment :P
|
|
||||||
if($thread_comment->id == $new_comment->id)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
$email_body = "Hello, {username}!\n" .
|
$email_body = "Hello, {username}!\n" .
|
||||||
"It's $settings->sitename here, letting you know that " .
|
"It's $settings->sitename here, letting you know that " .
|
||||||
"someone replied to your comment (or a reply to your comment) on $env->page.\n" .
|
"someone replied to your comment (or a reply to your comment) on $env->page.\n" .
|
||||||
|
@ -229,15 +226,15 @@ function find_comment($comment_data, $comment_id)
|
||||||
return $comment;
|
return $comment;
|
||||||
|
|
||||||
if(count($comment->replies) > 0) {
|
if(count($comment->replies) > 0) {
|
||||||
$subtrees = $comment->replies;
|
$subtrees[] = $comment->replies;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach($subtrees as $subtree)
|
foreach($subtrees as $subtree)
|
||||||
{
|
{
|
||||||
$subtree_result = find_comment($subtree);
|
$subtree_result = find_comment($subtree, $comment_id);
|
||||||
if($subtree_result !== false)
|
if($subtree_result !== false)
|
||||||
return $subtree;
|
return $subtree_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue