]> git.mxchange.org Git - friendica.git/blobdiff - src/Model/Tag.php
Use a constant for the avatar base path
[friendica.git] / src / Model / Tag.php
index 0ea19f55d9e11f5e8bc0f11585fd5f287e6480bf..b1c9822191b82777f6de794078b81ed477b1f855 100644 (file)
@@ -224,15 +224,18 @@ class Tag
        {
                $fields = ['name' => substr($name, 0, 96), 'url' => $url];
 
-               if (!empty($type)) {
-                       $fields['type'] = $type;
-               }
-
-               $tag = DBA::selectFirst('tag', ['id'], $fields);
+               $tag = DBA::selectFirst('tag', ['id', 'type'], $fields);
                if (DBA::isResult($tag)) {
+                       if (empty($tag['type']) && !empty($type)) {
+                               DBA::update('tag', ['type' => $type], $fields);
+                       }
                        return $tag['id'];
                }
 
+               if (!empty($type)) {
+                       $fields['type'] = $type;
+               }
+
                DBA::insert('tag', $fields, Database::INSERT_IGNORE);
                $tid = DBA::lastInsertId();
                if (!empty($tid)) {