The "term" table is removed

This commit is contained in:
Michael 2020-05-15 06:50:20 +00:00
parent f58d42e317
commit 7a82171bfe
8 changed files with 68 additions and 265 deletions

View file

@ -30,7 +30,6 @@ use Friendica\Model\ItemURI;
use Friendica\Model\PermissionSet;
use Friendica\Model\Post\Category;
use Friendica\Model\Tag;
use Friendica\Model\Term;
use Friendica\Model\UserItem;
use Friendica\Model\Verb;
use Friendica\Util\Strings;
@ -43,6 +42,9 @@ use Friendica\Util\Strings;
*/
class PostUpdate
{
// Needed for the helper function to read from the legacy term table
const OBJECT_TYPE_POST = 1;
/**
* Calls the post update functions
*/
@ -731,6 +733,31 @@ class PostUpdate
return false;
}
/**
* Generates the legacy item.file field string from an item ID.
* Includes only file and category terms.
*
* @param int $item_id
* @return string
* @throws \Exception
*/
private static function fileTextFromItemId($item_id)
{
$file_text = '';
$condition = ['otype' => self::OBJECT_TYPE_POST, 'oid' => $item_id, 'type' => [Category::FILE, Category::CATEGORY]];
$tags = DBA::selectToArray('term', ['type', 'term', 'url'], $condition);
foreach ($tags as $tag) {
if ($tag['type'] == Category::CATEGORY) {
$file_text .= '<' . $tag['term'] . '>';
} else {
$file_text .= '[' . $tag['term'] . ']';
}
}
return $file_text;
}
/**
* Fill the "tag" table with tags and mentions from the "term" table
*
@ -765,7 +792,7 @@ class PostUpdate
continue;
}
$file = Term::fileTextFromItemId($term['oid']);
$file = self::fileTextFromItemId($term['oid']);
if (!empty($file)) {
Category::storeTextByURIId($item['uri-id'], $item['uid'], $file);
}