]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Only populate attachments array element if there are attachments
authorZach Copley <zach@controlyourself.ca>
Fri, 17 Jul 2009 19:39:54 +0000 (12:39 -0700)
committerZach Copley <zach@controlyourself.ca>
Fri, 17 Jul 2009 19:42:16 +0000 (12:42 -0700)
lib/twitterapi.php

index 66664334c85930207e4412ee720c8c124aff1c92..ab6c0d62c8a5ec409d6e222e5020d48be41afef3 100644 (file)
@@ -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;
                 }
             }
         }