Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
in Q2A Core by

How to have "close as duplicate" as default behaviour on closing a question?

What do I have to change in qa-page-question-view.php? Or somewhere else?

What about the javascript that displays the duplicate (default) after clicking on "duplicate".


Q2A version: 1.5.3

1 Answer

+1 vote
edited by
Best answer

In function qa_page_q_close_q_form(...) in qa-page-question-post.php, change this line:

'value' => @$in['duplicate'],

... to ...

'value' => @array_key_exists('duplicate', $in) ? $in['duplicate'] : true,


Is it demanded too much if we add this 'tiny thing' as an admin option? Or is it indeed too tiny? ... ah, just leave the q2a core code untouched ;)
Got a php warning for the hack:
PHP Warning:  array_key_exists() [<a href='function.array-key-exists'>function.array-key-exists</a>]: The second argument should be either an array or an object in /qa-include/qa-page-question-post.php on line 489
I edited the answer and hopefully that should solve the problem.
Did not solve it, I am still getting the php error message "The second argument should be either an array or an object".
As I see, from qa-page-question.php line 254 you are calling the function:

$qa_content['q_view']['c_form']=qa_page_q_close_q_form($qa_content, $question, 'close', @$closein, @$closeerrors);

However, nowhere $closein is defined? (which gets $in in qa-page-question-post.php, above.
OK, try adding an @ sign to before array_key_exists(...).

On your other point, $closein is defined in qa-page-question-post.php which is included by qa-page-question.php when appropriate.
ah okay, that was invisible to my text search :)

Thanks, that worked:
'value' => @array_key_exists('duplicate', $in) ? $in['duplicate'] : true,

(just edit your answer in case others change that too, thanks gid!)