summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoroadaeh2017-06-25 00:02:14 (GMT)
committerJason Flatt2017-06-25 00:02:14 (GMT)
commitcaa6a1b93649345fa0cb5644632e32cc275faeb7 (patch)
tree8a02cc5c648922a4ea8c1029663a0e380010e498
parentf129bdc5f638bc65c96f3953aa6ecce2273c5398 (diff)
Issue #2884532 by oadaeh: Check for empty thread before usingHEAD7.x-2.x
-rwxr-xr-xprivatemsg.module14
1 files changed, 11 insertions, 3 deletions
diff --git a/privatemsg.module b/privatemsg.module
index c63b4b1..edc9265 100755
--- a/privatemsg.module
+++ b/privatemsg.module
@@ -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