- Patch #581534 by pwolanin | sun: fix redirecting after submitting a comment on a multi-page comment thread.
parent
4deee69d6e
commit
b7affdab6b
|
@ -2064,16 +2064,21 @@ function comment_form_submit($form, &$form_state) {
|
||||||
else {
|
else {
|
||||||
drupal_set_message(t('Your comment has been posted.'));
|
drupal_set_message(t('Your comment has been posted.'));
|
||||||
}
|
}
|
||||||
$redirect = array('comment/' . $comment->cid, array(), 'comment-' . $comment->cid);
|
$query = array();
|
||||||
|
// Find the current display page for this comment.
|
||||||
|
$page = comment_get_display_page($comment->cid, $node->type);
|
||||||
|
if ($page > 0) {
|
||||||
|
$query['page'] = $page;
|
||||||
|
}
|
||||||
|
// Redirect to the newly posted comment.
|
||||||
|
$redirect = array('node/' . $node->nid, $query, 'comment-' . $comment->cid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
|
watchdog('content', 'Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject), WATCHDOG_WARNING);
|
||||||
drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
|
drupal_set_message(t('Comment: unauthorized comment submitted or comment submitted to a closed post %subject.', array('%subject' => $comment->subject)), 'error');
|
||||||
$page = comment_new_page_count($node->comment_count, 1, $node);
|
// Redirect the user to the node they are commenting on.
|
||||||
$redirect = array('node/' . $node->nid, $page);
|
$redirect = 'node/' . $node->nid;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect the user to the node they're commenting on.
|
|
||||||
unset($form_state['rebuild']);
|
unset($form_state['rebuild']);
|
||||||
$form_state['redirect'] = $redirect;
|
$form_state['redirect'] = $redirect;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,7 +46,7 @@ class CommentHelperCase extends DrupalWebTestCase {
|
||||||
$this->drupalPost(NULL, $edit, t('Save'));
|
$this->drupalPost(NULL, $edit, t('Save'));
|
||||||
$match = array();
|
$match = array();
|
||||||
// Get comment ID
|
// Get comment ID
|
||||||
preg_match('/#comment-([^"]+)/', $this->getURL(), $match);
|
preg_match('/#comment-([0-9]+)/', $this->getURL(), $match);
|
||||||
|
|
||||||
// Get comment.
|
// Get comment.
|
||||||
if ($contact !== TRUE) { // If true then attempting to find error message.
|
if ($contact !== TRUE) { // If true then attempting to find error message.
|
||||||
|
|
Loading…
Reference in New Issue