From: Zach Copley Date: Fri, 17 Jul 2009 19:39:54 +0000 (-0700) Subject: Only populate attachments array element if there are attachments X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=9c670ba695d14068d1d159a91d0699f2677dad91;p=quix0rs-gnu-social.git Only populate attachments array element if there are attachments --- diff --git a/lib/twitterapi.php b/lib/twitterapi.php index 66664334c8..ab6c0d62c8 100644 --- a/lib/twitterapi.php +++ b/lib/twitterapi.php @@ -188,15 +188,18 @@ class TwitterapiAction extends Action # Enclosures $attachments = $notice->attachments(); - $twitter_status['attachments']=array(); - if($attachments){ - foreach($attachments as $attachment){ + + if (!empty($attachments)) { + + $twitter_status['attachments'] = array(); + + foreach ($attachments as $attachment) { if ($attachment->isEnclosure()) { - $enclosure=array(); - $enclosure['url']=$attachment->url; - $enclosure['mimetype']=$attachment->mimetype; - $enclosure['size']=$attachment->size; - $twitter_status['attachments'][]=$enclosure; + $enclosure = array(); + $enclosure['url'] = $attachment->url; + $enclosure['mimetype'] = $attachment->mimetype; + $enclosure['size'] = $attachment->size; + $twitter_status['attachments'][] = $enclosure; } } }