From 53c48211438c45b38bbd54f9290a8fb1c9da8e8f Mon Sep 17 00:00:00 2001 From: Marco Antonio Villegas Vega Date: Fri, 21 Aug 2009 19:10:17 -0500 Subject: [PATCH] Add try/catch to avoid SimpleXMLelement exception on constructor. This is the only place where we create a SimpleXMLElement object, so the problem should be resolved. --- twitter.inc | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/twitter.inc b/twitter.inc index 5c6fc65..a7c908a 100644 --- a/twitter.inc +++ b/twitter.inc @@ -474,7 +474,13 @@ function twitter_user_delete($uid, $screen_name = NULL) { function _twitter_convert_xml_to_array($data) { $results = array(); - $xml = new SimpleXMLElement($data); + try { + $xml = new SimpleXMLElement($data); + } + catch (Exception $e) { + watchdog('twitter', 'Convering xml to array failed. One possible reason is that twitter is down now. The convert failed with exception !exception.', array('!exception' => $e)); + return $results; + } if (!empty($xml->name)) { // Top-level user information. $results[] = _twitter_convert_user($xml); -- 1.5.6.5