1
1
Fork 0

Replace legacy file/category handling

This commit is contained in:
Michael 2021-01-21 07:16:41 +00:00
parent 0668b2dfd5
commit d2ea3eabfb
14 changed files with 103 additions and 253 deletions

View file

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2021.03-dev (Red Hot Poker)
-- DB_UPDATE_VERSION 1393
-- DB_UPDATE_VERSION 1394
-- ------------------------------------------
@ -1494,11 +1494,9 @@ CREATE VIEW `post-view` AS SELECT
`item`.`id` AS `id`,
`item`.`id` AS `item_id`,
`item`.`uid` AS `uid`,
`item`.`uid` AS `internal-uid`,
`item`.`parent` AS `parent`,
`item`.`uri` AS `uri`,
`item`.`uri-id` AS `uri-id`,
`item`.`uri-id` AS `internal-uri-id`,
`item`.`parent-uri` AS `parent-uri`,
`item`.`parent-uri-id` AS `parent-uri-id`,
`item`.`thr-parent` AS `thr-parent`,
@ -1530,9 +1528,6 @@ CREATE VIEW `post-view` AS SELECT
`item`.`network` AS `network`,
`item`.`vid` AS `vid`,
`item`.`psid` AS `psid`,
`item`.`attach` AS `attach`,
(SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
NULL AS `file`,
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
`item-content`.`title` AS `title`,
`item-content`.`content-warning` AS `content-warning`,
@ -1653,11 +1648,9 @@ CREATE VIEW `post-thread-view` AS SELECT
`thread`.`iid` AS `iid`,
`item`.`id` AS `item_id`,
`thread`.`uid` AS `uid`,
`item`.`uid` AS `internal-uid`,
`item`.`parent` AS `parent`,
`item`.`uri` AS `uri`,
`item`.`uri-id` AS `uri-id`,
`item`.`uri-id` AS `internal-uri-id`,
`item`.`parent-uri` AS `parent-uri`,
`item`.`parent-uri-id` AS `parent-uri-id`,
`item`.`thr-parent` AS `thr-parent`,
@ -1690,9 +1683,6 @@ CREATE VIEW `post-thread-view` AS SELECT
`thread`.`network` AS `network`,
`item`.`vid` AS `vid`,
`item`.`psid` AS `psid`,
`item`.`attach` AS `attach`,
(SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`) AS `internal-file-count`,
NULL AS `file`,
IF (`item`.`vid` IS NULL, '', `verb`.`name`) AS `verb`,
`item-content`.`title` AS `title`,
`item-content`.`content-warning` AS `content-warning`,

View file

@ -26,8 +26,6 @@ use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Util\Crypto;
@ -48,7 +46,7 @@ function editpost_content(App $a)
}
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
'type', 'body', 'title', 'uri-id', 'wall', 'post-type', 'guid'];
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
@ -117,7 +115,7 @@ function editpost_content(App $a)
'$jotnets' => $jotnets,
'$title' => $item['title'],
'$placeholdertitle' => DI::l10n()->t('Set title'),
'$category' => FileTag::fileToList($item['file'], 'category'),
'$category' => Post\Category::getCSVByURIId($item['uri-id'], local_user(), Post\Category::CATEGORY),
'$placeholdercategory' => (Feature::isEnabled(local_user(),'categories') ? DI::l10n()->t("Categories \x28comma-separated list\x29") : ''),
'$emtitle' => DI::l10n()->t('Example: bob@example.com, mary@example.com'),
'$lockstate' => $lockstate,

View file

@ -252,7 +252,7 @@ function item_post(App $a) {
$verb = $orig_post['verb'];
$objecttype = $orig_post['object-type'];
$app = $orig_post['app'];
$categories = $orig_post['file'] ?? '';
$categories = Post\Category::getTextByURIId($orig_post['uri-id'], $orig_post['uid']);
$title = trim($_REQUEST['title'] ?? '');
$body = trim($body);
$private = $orig_post['private'];
@ -344,10 +344,7 @@ function item_post(App $a) {
$filedas = FileTag::fileToArray($categories);
}
// save old and new categories, so we can determine what needs to be deleted from pconfig
$categories_old = $categories;
$categories = FileTag::listToFile(trim($_REQUEST['category'] ?? ''), 'category');
$categories_new = $categories;
if (!empty($filedas) && is_array($filedas)) {
// append the fileas stuff to the new categories list
@ -696,9 +693,6 @@ function item_post(App $a) {
Item::update($fields, ['id' => $post_id]);
// update filetags in pconfig
FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category');
if ($return_path) {
DI::baseUrl()->redirect($return_path);
}
@ -745,9 +739,6 @@ function item_post(App $a) {
Tag::createImplicitMentions($datarray['uri-id'], $datarray['thr-parent-id']);
}
// update filetags in pconfig
FileTag::updatePconfig($uid, $categories_old, $categories_new, 'category');
// These notifications are sent if someone else is commenting other your wall
if ($contact_record != $author) {
if ($toplevel_item_id) {

View file

@ -23,8 +23,8 @@ namespace Friendica\Content;
use Friendica\Database\DBA;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
use Friendica\Model\Tag;
use Friendica\Model\Post;
/**
* A content helper class for displaying items
@ -64,7 +64,7 @@ class Item
$folders = [];
$first = true;
foreach (FileTag::fileToArray($item['file'] ?? '', 'category') as $savedFolderName) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::CATEGORY) as $savedFolderName) {
if (!empty($item['author-link'])) {
$url = $item['author-link'] . "?category=" . rawurlencode($savedFolderName);
} else {
@ -85,7 +85,7 @@ class Item
}
if (local_user() == $item['uid']) {
foreach (FileTag::fileToArray($item['file'] ?? '') as $savedFolderName) {
foreach (Post\Category::getArrayByURIId($item['uri-id'], $item['uid'], Post\Category::FILE) as $savedFolderName) {
$folders[] = [
'name' => $savedFolderName,
'url' => "#",

View file

@ -27,9 +27,9 @@ use Friendica\Core\Renderer;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Contact;
use Friendica\Model\FileTag;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
@ -305,19 +305,10 @@ class Widget
return '';
}
$saved = DI::pConfig()->get(local_user(), 'system', 'filetags');
if (!strlen($saved)) {
return;
}
$terms = [];
foreach (FileTag::fileToArray($saved) as $savedFolderName) {
foreach (Post\Category::getArray(local_user(), Post\Category::FILE) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}
usort($terms, function ($a, $b) {
return strcmp($a['name'], $b['name']);
});
return self::filter(
'file',
@ -348,13 +339,8 @@ class Widget
return '';
}
$saved = DI::pConfig()->get($uid, 'system', 'filetags');
if (!strlen($saved)) {
return;
}
$terms = array();
foreach (FileTag::fileToArray($saved, 'category') as $savedFolderName) {
foreach (Post\Category::getArray(local_user(), Post\Category::CATEGORY) as $savedFolderName) {
$terms[] = ['ref' => $savedFolderName, 'name' => $savedFolderName];
}

View file

@ -22,8 +22,6 @@
namespace Friendica\Model;
use Friendica\Database\DBA;
use Friendica\DI;
use Friendica\Model\Post\Category;
/**
* This class handles FileTag related functions
@ -42,7 +40,7 @@ class FileTag
*
* @return string The URL encoded string.
*/
public static function encode($s)
private static function encode($s)
{
return str_replace(['<', '>', '[', ']'], ['%3c', '%3e', '%5b', '%5d'], $s);
}
@ -54,31 +52,11 @@ class FileTag
*
* @return string The decoded string.
*/
public static function decode($s)
private static function decode($s)
{
return str_replace(['%3c', '%3e', '%5b', '%5d'], ['<', '>', '[', ']'], $s);
}
/**
* Query files for tag
*
* @param string $table The table to be queired.
* @param string $s The search term
* @param string $type Optional file type.
*
* @return string Query string.
*/
public static function fileQuery($table, $s, $type = 'file')
{
if ($type == 'file') {
$str = preg_quote('[' . str_replace('%', '%%', self::encode($s)) . ']');
} else {
$str = preg_quote('<' . str_replace('%', '%%', self::encode($s)) . '>');
}
return " AND " . (($table) ? DBA::escape($table) . '.' : '') . "file regexp '" . DBA::escape($str) . "' ";
}
/**
* Get file tags from array
*
@ -156,93 +134,6 @@ class FileTag
return self::arrayToFile($list_array, $type);
}
/**
* Get list from file tags
*
* ex. given <music><video>[friends], return music,video or friends
* @param string $file File tags
* @param string $type Optional file type.
*
* @return string Comma delimited list of tag names.
* @deprecated since 2019.06 use fileToArray() instead
*/
public static function fileToList(string $file, $type = 'file')
{
return implode(',', self::fileToArray($file, $type));
}
/**
* Update file tags in PConfig
*
* @param int $uid Unique Identity.
* @param string $file_old Categories previously associated with an item
* @param string $file_new New list of categories for an item
* @param string $type Optional file type.
*
* @return boolean A value indicating success or failure.
* @throws \Exception
*/
public static function updatePconfig(int $uid, string $file_old, string $file_new, string $type = 'file')
{
if (!intval($uid)) {
return false;
} elseif ($file_old == $file_new) {
return true;
}
$saved = DI::pConfig()->get($uid, 'system', 'filetags');
if (strlen($saved)) {
if ($type == 'file') {
$lbracket = '[';
$rbracket = ']';
$termtype = Category::FILE;
} else {
$lbracket = '<';
$rbracket = '>';
$termtype = Category::CATEGORY;
}
$filetags_updated = $saved;
// check for new tags to be added as filetags in pconfig
$new_tags = [];
foreach (self::fileToArray($file_new, $type) as $tag) {
if (!stristr($saved, $lbracket . self::encode($tag) . $rbracket)) {
$new_tags[] = $tag;
}
}
$filetags_updated .= self::arrayToFile($new_tags, $type);
// check for deleted tags to be removed from filetags in pconfig
$deleted_tags = [];
foreach (self::fileToArray($file_old, $type) as $tag) {
if (!stristr($file_new, $lbracket . self::encode($tag) . $rbracket)) {
$deleted_tags[] = $tag;
}
}
foreach ($deleted_tags as $key => $tag) {
if (DBA::exists('category-view', ['name' => $tag, 'type' => $termtype, 'uid' => $uid])) {
unset($deleted_tags[$key]);
} else {
$filetags_updated = str_replace($lbracket . self::encode($tag) . $rbracket, '', $filetags_updated);
}
}
if ($saved != $filetags_updated) {
DI::pConfig()->set($uid, 'system', 'filetags', $filetags_updated);
}
return true;
} elseif (strlen($file_new)) {
DI::pConfig()->set($uid, 'system', 'filetags', $file_new);
}
return true;
}
/**
* Add tag to file
*
@ -259,17 +150,12 @@ class FileTag
return false;
}
$item = Post::selectFirst(['file'], ['id' => $item_id, 'uid' => $uid]);
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => $uid]);
if (DBA::isResult($item)) {
if (!stristr($item['file'], '[' . self::encode($file) . ']')) {
$fields = ['file' => $item['file'] . '[' . self::encode($file) . ']'];
Item::update($fields, ['id' => $item_id]);
}
$stored_file = Post\Category::getTextByURIId($item['uri-id'], $uid);
$saved = DI::pConfig()->get($uid, 'system', 'filetags');
if (!strlen($saved) || !stristr($saved, '[' . self::encode($file) . ']')) {
DI::pConfig()->set($uid, 'system', 'filetags', $saved . '[' . self::encode($file) . ']');
if (!stristr($stored_file, '[' . self::encode($file) . ']')) {
Post\Category::storeTextByURIId($item['uri-id'], $uid, $stored_file . '[' . self::encode($file) . ']');
}
}
@ -295,26 +181,18 @@ class FileTag
if ($cat == true) {
$pattern = '<' . self::encode($file) . '>';
$termtype = Category::CATEGORY;
} else {
$pattern = '[' . self::encode($file) . ']';
$termtype = Category::FILE;
}
$item = Post::selectFirst(['file'], ['id' => $item_id, 'uid' => $uid]);
$item = Post::selectFirst(['uri-id'], ['id' => $item_id, 'uid' => $uid]);
if (!DBA::isResult($item)) {
return false;
}
$fields = ['file' => str_replace($pattern, '', $item['file'])];
$file = Post\Category::getTextByURIId($item['uri-id'], $uid);
Item::update($fields, ['id' => $item_id]);
if (!DBA::exists('category-view', ['name' => $file, 'type' => $termtype, 'uid' => $uid])) {
$saved = DI::pConfig()->get($uid, 'system', 'filetags');
DI::pConfig()->set($uid, 'system', 'filetags', str_replace($pattern, '', $saved));
}
Post\Category::storeTextByURIId($item['uri-id'], $uid, str_replace($pattern, '', $file));
return true;
}

View file

@ -75,7 +75,7 @@ class Item
const DISPLAY_FIELDLIST = [
'uid', 'id', 'parent', 'uri-id', 'uri', 'thr-parent', 'parent-uri', 'guid', 'network', 'gravity',
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'language',
'wall', 'private', 'starred', 'origin', 'title', 'body', 'language',
'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id',
'author-id', 'author-link', 'author-name', 'author-avatar', 'author-network',
@ -112,7 +112,7 @@ class Item
'contact-id', 'type', 'wall', 'gravity', 'extid', 'psid',
'created', 'edited', 'commented', 'received', 'changed', 'verb',
'postopts', 'plink', 'resource-id', 'event-id', 'inform',
'file', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'post-type',
'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark',
'unseen', 'deleted', 'origin', 'forum_mode', 'mention', 'global', 'network',
'title', 'content-warning', 'body', 'location', 'coord', 'app',
@ -203,17 +203,13 @@ class Item
// We cannot simply expand the condition to check for origin entries
// The condition needn't to be a simple array but could be a complex condition.
// And we have to execute this query before the update to ensure to fetch the same data.
$items = DBA::select('item', ['id', 'origin', 'uri', 'uri-id', 'uid', 'file'], $condition);
$items = DBA::select('item', ['id', 'origin', 'uri', 'uri-id', 'uid'], $condition);
$content_fields = [];
foreach (array_merge(self::CONTENT_FIELDLIST, self::MIXED_CONTENT_FIELDLIST) as $field) {
if (isset($fields[$field])) {
$content_fields[$field] = $fields[$field];
if (in_array($field, self::CONTENT_FIELDLIST)) {
unset($fields[$field]);
} else {
$fields[$field] = null;
}
unset($fields[$field]);
}
}
@ -221,14 +217,12 @@ class Item
$clear_fields = ['bookmark', 'type', 'author-name', 'author-avatar', 'author-link', 'owner-name', 'owner-avatar', 'owner-link', 'postopts', 'inform'];
foreach ($clear_fields as $field) {
if (array_key_exists($field, $fields)) {
$fields[$field] = null;
}
unset($fields[$field]);
}
if (array_key_exists('file', $fields)) {
$files = $fields['file'];
$fields['file'] = null;
unset($fields['file']);
} else {
$files = null;
}
@ -269,9 +263,6 @@ class Item
if (!is_null($files)) {
Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], $files);
if (!empty($item['file'])) {
DBA::update('item', ['file' => ''], ['id' => $item['id']]);
}
}
if (!empty($fields['attach'])) {
@ -358,7 +349,7 @@ class Item
Logger::info('Mark item for deletion by id', ['id' => $item_id, 'callstack' => System::callstack()]);
// locate item to be deleted
$fields = ['id', 'uri', 'uri-id', 'uid', 'parent', 'parent-uri', 'origin',
'deleted', 'file', 'resource-id', 'event-id',
'deleted', 'resource-id', 'event-id',
'verb', 'object-type', 'object', 'target', 'contact-id', 'psid', 'gravity'];
$item = Post::selectFirst($fields, ['id' => $item_id]);
if (!DBA::isResult($item)) {
@ -377,25 +368,7 @@ class Item
}
// clean up categories and tags so they don't end up as orphans
$matches = [];
$cnt = preg_match_all('/<(.*?)>/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
FileTag::unsaveFile($item['uid'], $item['id'], $mtch[1],true);
}
}
$matches = [];
$cnt = preg_match_all('/\[(.*?)\]/', $item['file'], $matches, PREG_SET_ORDER);
if ($cnt) {
foreach ($matches as $mtch) {
FileTag::unsaveFile($item['uid'], $item['id'], $mtch[1],false);
}
}
Post\Category::deleteByURIId($item['uri-id'], $item['uid']);
/*
* If item is a link to a photo resource, nuke all the associated photos
@ -2363,7 +2336,7 @@ class Item
$condition[0] .= " AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY";
$condition[] = $days;
$items = Post::select(['file', 'resource-id', 'starred', 'type', 'id', 'post-type'], $condition);
$items = Post::select(['resource-id', 'starred', 'type', 'id', 'post-type', 'uid', 'uri-id'], $condition);
if (!DBA::isResult($items)) {
return;
@ -2386,8 +2359,7 @@ class Item
while ($item = Post::fetch($items)) {
// don't expire filed items
if (strpos($item['file'], '[') !== false) {
if (DBA::exists('post-category', ['uri-id' => $item['uri-id'], 'uid' => $item['uid'], 'type' => Post\Category::FILE])) {
continue;
}

View file

@ -63,22 +63,6 @@ class Post
}
}
if (!array_key_exists('verb', $row) || in_array($row['verb'], ['', Activity::POST, Activity::SHARE])) {
// Build the file string out of the term entries
if (array_key_exists('file', $row)) {
if ($row['internal-file-count'] > 0) {
$row['file'] = Post\Category::getTextByURIId($row['internal-uri-id'], $row['internal-uid']);
} else {
$row['file'] = '';
}
}
}
// Remove internal fields
unset($row['internal-file-count']);
unset($row['internal-uri-id']);
unset($row['internal-uid']);
return $row;
}
@ -213,7 +197,6 @@ class Post
}
}
$selected = array_merge($selected, ['internal-uri-id', 'internal-uid', 'internal-file-count']);
$selected = array_unique($selected);
return DBA::select($view, $selected, $condition, $params);
@ -267,8 +250,6 @@ class Post
$selected = Item::DISPLAY_FIELDLIST;
}
$selected = array_unique(array_merge($selected, ['internal-uri-id', 'internal-uid', 'internal-file-count']));
$condition = DBA::mergeConditions($condition,
["`visible` AND NOT `deleted` AND NOT `moderated`
AND NOT `author-blocked` AND NOT `owner-blocked`

View file

@ -22,7 +22,6 @@
namespace Friendica\Model\Post;
use Friendica\Database\DBA;
use Friendica\Model\Item;
use Friendica\Model\Post;
use Friendica\Model\Tag;
@ -38,11 +37,25 @@ class Category
const CATEGORY = 3;
const FILE = 5;
/**
* Delete all categories and files from a given uri-id and user
*
* @param int $uri_id
* @param int $uid
* @return boolean success
* @throws \Exception
*/
public static function deleteByURIId(int $uri_id, int $uid)
{
return DBA::delete('post-category', ['uri-id' => $uri_id, 'uid' => $uid]);
}
/**
* Generates the legacy item.file field string from an item ID.
* Includes only file and category terms.
*
* @param int $item_id
* @param int $uri_id
* @param int $uid
* @return string
* @throws \Exception
*/
@ -62,6 +75,58 @@ class Category
return $file_text;
}
/**
* Generates an array of files or categories of a given uri-id
*
* @param int $uid
* @param int $type
* @return array
* @throws \Exception
*/
public static function getArray(int $uid, int $type)
{
$tags = DBA::selectToArray('category-view', ['name'], ['uid' => $uid, 'type' => $type],
['group_by' => ['name'], 'order' => ['name']]);
if (empty($tags)) {
return [];
}
return array_column($tags, 'name');
}
/**
* Generates an array of files or categories of a given uri-id
*
* @param int $uri_id
* @param int $uid
* @param int $type
* @return array
* @throws \Exception
*/
public static function getArrayByURIId(int $uri_id, int $uid, int $type = self::CATEGORY)
{
$tags = DBA::selectToArray('category-view', ['type', 'name'], ['uri-id' => $uri_id, 'uid' => $uid, 'type' => $type]);
if (empty($tags)) {
return [];
}
return array_column($tags, 'name');
}
/**
* Generates a comma separated list of files or categories
*
* @param int $uri_id
* @param int $uid
* @param int $type
* @return string
* @throws \Exception
*/
public static function getCSVByURIId(int $uri_id, int $uid, int $type)
{
return implode(',', self::getArrayByURIId($uri_id, $uid, $type));
}
/**
* Inserts new terms for the provided item ID based on the legacy item.file field BBCode content.
* Deletes all previous file terms for the same item ID.

View file

@ -57,8 +57,7 @@ class SaveTag extends BaseModule
}
// return filer dialog
$filetags = DI::pConfig()->get(local_user(), 'system', 'filetags', '');
$filetags = Model\FileTag::fileToArray($filetags);
$filetags = Model\Post\Category::getArray(local_user(), Model\Post\Category::FILE);
$tpl = Renderer::getMarkupTemplate("filer_dialog.tpl");
echo Renderer::replaceMacros($tpl, [

View file

@ -2508,14 +2508,14 @@ class DFRN
}
$condition = ['uri' => $uri, 'uid' => $importer["importer_uid"]];
$item = Post::selectFirst(['id', 'parent', 'contact-id', 'file', 'deleted', 'gravity'], $condition);
$item = Post::selectFirst(['id', 'parent', 'contact-id', 'uri-id', 'deleted', 'gravity'], $condition);
if (!DBA::isResult($item)) {
Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " wasn't found.", Logger::DEBUG);
return;
}
if (strstr($item['file'], '[')) {
Logger::log("Item with uri " . $uri . " for user " . $importer["importer_uid"] . " is filed. So it won't be deleted.", Logger::DEBUG);
if (DBA::exists('post-category', ['uri-id' => $item['uri-id'], 'uid' => $importer['importer_uid'], 'type' => Post\Category::FILE])) {
Logger::notice("Item is filed. It won't be deleted.", ['uri' => $uri, 'uri-id' => $item['uri_id'], 'uid' => $importer["importer_uid"]]);
return;
}

View file

@ -2526,7 +2526,7 @@ class Diaspora
}
// Fetch items that are about to be deleted
$fields = ['uid', 'id', 'parent', 'author-link', 'file'];
$fields = ['uid', 'id', 'parent', 'author-link', 'uri-id'];
// When we receive a public retraction, we delete every item that we find.
if ($importer['uid'] == 0) {
@ -2542,7 +2542,7 @@ class Diaspora
}
while ($item = Post::fetch($r)) {
if (strstr($item['file'], '[')) {
if (DBA::exists('post-category', ['uri-id' => $item['uri-id'], 'uid' => $item['uid'], 'type' => Post\Category::FILE])) {
Logger::log("Target guid " . $target_guid . " for user " . $item['uid'] . " is filed. So it won't be deleted.", Logger::DEBUG);
continue;
}

View file

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1393);
define('DB_UPDATE_VERSION', 1394);
}
return [

View file

@ -42,11 +42,9 @@
"id" => ["item", "id"],
"item_id" => ["item", "id"],
"uid" => ["item", "uid"],
"internal-uid" => ["item", "uid"],
"parent" => ["item", "parent"],
"uri" => ["item", "uri"],
"uri-id" => ["item", "uri-id"],
"internal-uri-id" => ["item", "uri-id"],
"parent-uri" => ["item", "parent-uri"],
"parent-uri-id" => ["item", "parent-uri-id"],
"thr-parent" => ["item", "thr-parent"],
@ -78,9 +76,6 @@
"network" => ["item", "network"],
"vid" => ["item", "vid"],
"psid" => ["item", "psid"],
"attach" => ["item", "attach"],
"internal-file-count" => "(SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`)",
"file" => "NULL",
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
"title" => ["item-content", "title"],
"content-warning" => ["item-content", "content-warning"],
@ -199,11 +194,9 @@
"iid" => ["thread", "iid"],
"item_id" => ["item", "id"],
"uid" => ["thread", "uid"],
"internal-uid" => ["item", "uid"],
"parent" => ["item", "parent"],
"uri" => ["item", "uri"],
"uri-id" => ["item", "uri-id"],
"internal-uri-id" => ["item", "uri-id"],
"parent-uri" => ["item", "parent-uri"],
"parent-uri-id" => ["item", "parent-uri-id"],
"thr-parent" => ["item", "thr-parent"],
@ -236,9 +229,6 @@
"network" => ["thread", "network"],
"vid" => ["item", "vid"],
"psid" => ["item", "psid"],
"attach" => ["item", "attach"],
"internal-file-count" => "(SELECT COUNT(*) FROM `post-category` WHERE `post-category`.`uri-id` = `item`.`uri-id`)",
"file" => "NULL",
"verb" => "IF (`item`.`vid` IS NULL, '', `verb`.`name`)",
"title" => ["item-content", "title"],
"content-warning" => ["item-content", "content-warning"],