From b46c1746f2cc5260d9786fd7b3bf395b1623d4bb Mon Sep 17 00:00:00 2001
From: Mikael Nordfeldth <mmn@hethane.se>
Date: Tue, 22 Oct 2013 15:34:22 +0200
Subject: [PATCH] Daisychaining bug with exceptions in PHP

---
 lib/apiaction.php | 5 ++++-
 lib/implugin.php  | 3 ++-
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/lib/apiaction.php b/lib/apiaction.php
index 354e1887bb..481dcf1b95 100644
--- a/lib/apiaction.php
+++ b/lib/apiaction.php
@@ -315,7 +315,10 @@ class ApiAction extends Action
         $twitter_status['truncated'] = false; # Not possible on StatusNet
         $twitter_status['created_at'] = $this->dateTwitter($notice->created);
         try {
-            $in_reply_to = $notice->getParent()->id;
+            // We could just do $notice->reply_to but maybe the future holds a
+            // different story for parenting.
+            $parent = $notice->getParent();
+            $in_reply_to = $parent->id;
         } catch (Exception $e) {
             $in_reply_to = null;
         }
diff --git a/lib/implugin.php b/lib/implugin.php
index def9a942c9..4ee9d85466 100644
--- a/lib/implugin.php
+++ b/lib/implugin.php
@@ -375,7 +375,8 @@ abstract class ImPlugin extends Plugin
         $profile = $notice->getProfile();
 
         try {
-            $orig_profile = $notice->getParent()->getProfile();
+            $parent = $notice->getParent();
+            $orig_profile = $parent->getProfile();
             $nicknames = sprintf('%1$s => %2$s', $profile->nickname, $orig_profile->nickname);
         } catch (Exception $e) {
             $nicknames = $profile->nickname;
-- 
2.39.5