Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Posted Comment gets lost if commented answer is converted to comment meanwhile #857

Open
q2apro opened this issue Oct 20, 2020 · 4 comments

Comments

@q2apro
Copy link

q2apro commented Oct 20, 2020

Reproduce:

  1. Write Answer.
  2. Write Comment, but do not submit yet.
  3. New browser window: Convert answer to comment.
  4. Go back to main window: Submit comment.

Result: Submitted comment is not saved. Instead it gets lost.

@q2apro q2apro changed the title Comment Post gets lost if commented answer is converted to comment meanwhile Posted Comment gets lost if commented answer is converted to comment meanwhile Oct 20, 2020
@arjunsuresh
Copy link

What should ideally happen here?

@q2apro
Copy link
Author

q2apro commented Oct 23, 2020

Since it is an AJAX post, it is taking effect in qa-include\ajax\comment.php:

 $parentid = qa_post_text('c_parentid'); 

After the A-to-C-conversion is done, this is providing the wrong parentid. It refers to a comment now (which was the former answer).

I tried to fix it with:

if (@$parent['basetype'] == 'C')
{
	$parentid = $parent['parentid'];
	$parent = qa_db_single_select(qa_db_full_post_selectspec($userid, $parentid));
	$children = qa_db_single_select(qa_db_full_child_posts_selectspec($userid, $parentid));
}

but it does not work.

@arjunsuresh
Copy link

I think Q2A core doesn't make a comment as a parent as of 1.8.5. So, to fix this won't be a straight forward task. Some hacky way might be required.

@q2apro
Copy link
Author

q2apro commented Oct 24, 2020

The fix above would be correct (basetype is C in this exceptional case). But I have found the reason, why it does not work in the further code:

With changing the $parent the basetype is "Q" and the code in the if block is executed. However:

The AJAX call is processed from qa-include/ajax/comment.php and triggers this function:

$commentid = qa_page_q_add_c_submit($question, $parent, $children, $usecaptcha, $in, $errors);

function qa_page_q_add_c_submit() you find in qa-include/pages/question-submit.php. There, the script fails at this line:

	if (!qa_check_form_security_code('comment-' . $parent['postid'], qa_post_text($prefix . 'code')))

Because the form security code is not the same anymore as set fronted with the (former) Answer. Now the $parent is the Q with the hack above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants