}
// Build the tag string out of the term entries
- if (isset($row['id']) && isset($row['tag'])) {
+ if (isset($row['id']) && array_key_exists('tag', $row)) {
$row['tag'] = Term::tagTextFromItemId($row['id']);
}
}
}
+ if (array_key_exists('tag', $fields)) {
+ $tags = $fields['tag'];
+ unset($fields['tag']);
+ } else {
+ $tags = '';
+ }
+
if (!empty($fields)) {
$success = dba::update('item', $fields, $condition);
}
self::updateContent($content_fields, ['uri' => $item['uri']]);
- if (array_key_exists('tag', $fields)) {
- Term::insertFromTagFieldByItemId($item['id']);
+ if (!empty($tags)) {
+ Term::insertFromTagFieldByItemId($item['id'], $tags);
}
if (array_key_exists('file', $fields)) {
'object' => '', 'target' => '', 'tag' => '', 'postopts' => '', 'attach' => '', 'file' => ''];
dba::update('item', $item_fields, ['id' => $item['id']]);
- Term::insertFromTagFieldByItemId($item['id']);
+ Term::insertFromTagFieldByItemId($item['id'], '');
Term::insertFromFileFieldByItemId($item['id']);
self::deleteThread($item['id'], $item['parent-uri']);
logger('' . print_r($item,true), LOGGER_DATA);
+ if (array_key_exists('tag', $item)) {
+ $tags = $item['tag'];
+ unset($item['tag']);
+ } else {
+ $tags = '';
+ }
+
// We are doing this outside of the transaction to avoid timing problems
self::insertContent($item);
* Due to deadlock issues with the "term" table we are doing these steps after the commit.
* This is not perfect - but a workable solution until we found the reason for the problem.
*/
- if (array_key_exists('tag', $item)) {
- Term::insertFromTagFieldByItemId($current_post);
+ if (!empty($tags)) {
+ Term::insertFromTagFieldByItemId($current_post, $tags);
}
if (array_key_exists('file', $item)) {
return $tag_text;
}
- public static function insertFromTagFieldByItemId($itemid)
+ public static function insertFromTagFieldByItemId($itemid, $tags)
{
$profile_base = System::baseUrl();
$profile_data = parse_url($profile_base);
$profile_base_friendica = $profile_data['host'] . $profile_path . '/profile/';
$profile_base_diaspora = $profile_data['host'] . $profile_path . '/u/';
- $fields = ['guid', 'uid', 'id', 'edited', 'deleted', 'created', 'received', 'title', 'body', 'tag', 'parent'];
+ $fields = ['guid', 'uid', 'id', 'edited', 'deleted', 'created', 'received', 'title', 'body', 'parent'];
$message = Item::selectFirst($fields, ['id' => $itemid]);
if (!DBM::is_result($message)) {
return;
}
+ $message['tag'] = $tags;
+
// Clean up all tags
dba::delete('term', ['otype' => TERM_OBJ_POST, 'oid' => $itemid, 'type' => [TERM_HASHTAG, TERM_MENTION]]);