]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Status_network.php
Fix for ticket 2756 - Calls to OAuth endpoints are redirected to the
[quix0rs-gnu-social.git] / classes / Status_network.php
index d1ca454e227c101f6a4ed61f761ba5821974917a..70c7a58eb7488040b3df886c54ade9e361f770be 100644 (file)
@@ -167,9 +167,8 @@ class Status_network extends Safe_DataObject
             ' WHERE nickname = ' . $this->_quote($this->nickname);
         $orig->decache();
         $result = $this->query($qry);
-        if ($result) {
-            $this->encache();
-        }
+        $this->decache();
+        
         return $result;
     }
     
@@ -308,35 +307,36 @@ class Status_network extends Safe_DataObject
      */
     function getTags()
     {
-        $result = array();
-        
-        $tags = new Status_network_tag();
-        $tags->site_id = $this->site_id;
-        if ($tags->find()) {
-            while ($tags->fetch()) {
-                $result[] = $tags->tag;
-            }
-        }
+        $result = Status_network_tag::getTags($this->site_id);
 
+        // XXX : for backwards compatibility
+        if (empty($result)) {
+            return explode('|', $this->tags);
+        }
+        
         return $result;
     }
 
     /**
      * Save a given set of tags
      * @param array tags
+     * @fixme only add/remove differentials
      */
     function setTags($tags)
     {
         $this->clearTags();
         foreach ($tags as $tag) {
-            $snt = new Status_network_tag();
-            $snt->site_id = $this->site_id;
-            $snt->tag = $tag;
-            $snt->created = common_sql_now();
-
-            $id = $snt->insert();
-            if (!$id) {
-                throw new Exception(_("Unable to save tag."));
+            if (!empty($tag)) {
+                $snt = new Status_network_tag();
+                $snt->site_id = $this->site_id;
+                $snt->tag = $tag;
+                $snt->created = common_sql_now();
+                
+                $id = $snt->insert();
+                if (!$id) {
+                    // TRANS: Exception thrown when a tag cannot be saved.
+                    throw new Exception(_("Unable to save tag."));
+                }
             }
         }