Commit caa6a1b9 authored by oadaeh's avatar oadaeh Committed by oadaeh

Issue #2884532 by oadaeh: Check for empty thread before using

parent f129bdc5
......@@ -1782,14 +1782,22 @@ function privatemsg_reply($thread_id, $body, $options = array()) {
$first_message = privatemsg_message_load($thread_id, $message->author);
if (!$first_message) {
return array(
'success' => FALSE,
'messages' => array('error' => array(t('Thread %thread_id not found, unable to answer', array('%thread_id' => $thread_id)))),
'success' => FALSE,
'messages' => array('error' => array(t('Thread %thread_id not found, unable to answer.', array('%thread_id' => $thread_id)))),
);
}
// Add the reply_to_mid, so we can mark that message as replied
$thread = privatemsg_thread_load($thread_id);
$message->reply_to_mid = end($thread['messages'])->mid;
if (empty($thread)) {
return array(
'success' => FALSE,
'messages' => array('error' => array(t('A thread was not returned for ID %thread_id. The user might not be allowed to participate in it.', array('%thread_id' => $thread_id)))),
);
}
else {
$message->reply_to_mid = end($thread['messages'])->mid;
}
$message->thread_id = $thread_id;
// Load participants
......
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