mirror of
https://github.com/friendica/friendica
synced 2024-11-19 13:03:41 +00:00
"item" is replaced whenever possible at the moment
This commit is contained in:
parent
0fe37b123a
commit
8f27715d8b
9 changed files with 21 additions and 21 deletions
|
@ -478,7 +478,7 @@ class DBA
|
||||||
* @return boolean|object
|
* @return boolean|object
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* $table = "item";
|
* $table = "post";
|
||||||
* $fields = array("id", "uri", "uid", "network");
|
* $fields = array("id", "uri", "uid", "network");
|
||||||
*
|
*
|
||||||
* $condition = array("uid" => 1, "network" => 'dspr');
|
* $condition = array("uid" => 1, "network" => 'dspr');
|
||||||
|
@ -505,7 +505,7 @@ class DBA
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* $table = "item";
|
* $table = "post";
|
||||||
*
|
*
|
||||||
* $condition = ["uid" => 1, "network" => 'dspr'];
|
* $condition = ["uid" => 1, "network" => 'dspr'];
|
||||||
* or:
|
* or:
|
||||||
|
|
|
@ -1512,7 +1512,7 @@ class Database
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* $table = 'item';
|
* $table = 'post';
|
||||||
* or:
|
* or:
|
||||||
* $table = ['schema' => 'table'];
|
* $table = ['schema' => 'table'];
|
||||||
* @see DBA::buildTableString()
|
* @see DBA::buildTableString()
|
||||||
|
@ -1575,7 +1575,7 @@ class Database
|
||||||
* @return int
|
* @return int
|
||||||
*
|
*
|
||||||
* Example:
|
* Example:
|
||||||
* $table = "item";
|
* $table = "post";
|
||||||
*
|
*
|
||||||
* $condition = ["uid" => 1, "network" => 'dspr'];
|
* $condition = ["uid" => 1, "network" => 'dspr'];
|
||||||
* or:
|
* or:
|
||||||
|
|
|
@ -319,7 +319,7 @@ class Item
|
||||||
|
|
||||||
// Set the item to "deleted"
|
// Set the item to "deleted"
|
||||||
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
$item_fields = ['deleted' => true, 'edited' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()];
|
||||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
Post::update($item_fields, ['id' => $item['id']]);
|
||||||
|
|
||||||
Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], '');
|
Post\Category::storeTextByURIId($item['uri-id'], $item['uid'], '');
|
||||||
self::deleteThread($item['id'], $item['parent-uri-id']);
|
self::deleteThread($item['id'], $item['parent-uri-id']);
|
||||||
|
@ -919,7 +919,7 @@ class Item
|
||||||
$item["global"] = true;
|
$item["global"] = true;
|
||||||
|
|
||||||
// Set the global flag on all items if this was a global item entry
|
// Set the global flag on all items if this was a global item entry
|
||||||
DBA::update('item', ['global' => true], ['uri-id' => $item['uri-id']]);
|
Post::update(['global' => true], ['uri-id' => $item['uri-id']]);
|
||||||
} else {
|
} else {
|
||||||
$item['global'] = Post::exists(['uid' => 0, 'uri-id' => $item['uri-id']]);
|
$item['global'] = Post::exists(['uid' => 0, 'uri-id' => $item['uri-id']]);
|
||||||
}
|
}
|
||||||
|
@ -1068,9 +1068,9 @@ class Item
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update_commented) {
|
if ($update_commented) {
|
||||||
DBA::update('item', ['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
Post::update(['commented' => DateTimeFormat::utcNow(), 'changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||||
} else {
|
} else {
|
||||||
DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item['gravity'] === GRAVITY_PARENT) {
|
if ($item['gravity'] === GRAVITY_PARENT) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ class Site extends BaseAdmin
|
||||||
// update profile links in the format "http://server.tld"
|
// update profile links in the format "http://server.tld"
|
||||||
update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
|
update_table($a, "profile", ['photo', 'thumb'], $old_url, $new_url);
|
||||||
update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
|
update_table($a, "contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
|
||||||
update_table($a, "item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
|
update_table($a, "post-content", ['body'], $old_url, $new_url);
|
||||||
|
|
||||||
// update profile addresses in the format "user@server.tld"
|
// update profile addresses in the format "user@server.tld"
|
||||||
update_table($a, "contact", ['addr'], $old_host, $new_host);
|
update_table($a, "contact", ['addr'], $old_host, $new_host);
|
||||||
|
|
|
@ -242,7 +242,7 @@ class UserExport extends BaseSettings
|
||||||
self::exportAccount($a);
|
self::exportAccount($a);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
|
|
||||||
$total = DBA::count('item', ['uid' => local_user()]);
|
$total = Post::count(['uid' => local_user()]);
|
||||||
// chunk the output to avoid exhausting memory
|
// chunk the output to avoid exhausting memory
|
||||||
|
|
||||||
for ($x = 0; $x < $total; $x += 500) {
|
for ($x = 0; $x < $total; $x += 500) {
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\Post;
|
||||||
|
|
||||||
class CleanItemUri
|
class CleanItemUri
|
||||||
{
|
{
|
||||||
|
@ -33,7 +34,7 @@ class CleanItemUri
|
||||||
{
|
{
|
||||||
// We have to avoid deleting newly created "item-uri" entries.
|
// We have to avoid deleting newly created "item-uri" entries.
|
||||||
// So we fetch a post that had been stored yesterday and only delete older ones.
|
// So we fetch a post that had been stored yesterday and only delete older ones.
|
||||||
$item = DBA::selectFirst('item', ['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
|
$item = Post::selectFirst(['uri-id'], ["`uid` = ? AND `received` < UTC_TIMESTAMP() - INTERVAL ? DAY", 0, 1],
|
||||||
['order' => ['received' => true]]);
|
['order' => ['received' => true]]);
|
||||||
if (empty($item['uri-id'])) {
|
if (empty($item['uri-id'])) {
|
||||||
Logger::warning('No item with uri-id found - we better quit here');
|
Logger::warning('No item with uri-id found - we better quit here');
|
||||||
|
|
|
@ -44,11 +44,12 @@ class Expire
|
||||||
Logger::log('Delete expired items', Logger::DEBUG);
|
Logger::log('Delete expired items', Logger::DEBUG);
|
||||||
// physically remove anything that has been deleted for more than two months
|
// physically remove anything that has been deleted for more than two months
|
||||||
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
|
||||||
$rows = DBA::select('item', ['id', 'guid', 'uri-id', 'uid'], $condition);
|
$rows = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition);
|
||||||
while ($row = DBA::fetch($rows)) {
|
while ($row = Post::fetch($rows)) {
|
||||||
Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
|
Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
|
||||||
DBA::delete('item', ['id' => $row['id']]);
|
DBA::delete('item', ['id' => $row['id']]);
|
||||||
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
Post\User::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||||
|
Post\ThreadUser::delete(['uri-id' => $row['uri-id'], 'uid' => $row['uid']]);
|
||||||
}
|
}
|
||||||
DBA::close($rows);
|
DBA::close($rows);
|
||||||
|
|
||||||
|
|
|
@ -23,6 +23,7 @@ namespace Friendica\Worker;
|
||||||
|
|
||||||
use Friendica\Core\Logger;
|
use Friendica\Core\Logger;
|
||||||
use Friendica\Database\DBA;
|
use Friendica\Database\DBA;
|
||||||
|
use Friendica\Model\Post;
|
||||||
|
|
||||||
class MergeContact
|
class MergeContact
|
||||||
{
|
{
|
||||||
|
@ -43,8 +44,7 @@ class MergeContact
|
||||||
Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]);
|
Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]);
|
||||||
|
|
||||||
// Search and replace
|
// Search and replace
|
||||||
DBA::update('item', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
Post::update(['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||||
DBA::update('thread', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
|
||||||
DBA::update('mail', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
DBA::update('mail', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||||
DBA::update('photo', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
DBA::update('photo', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
|
||||||
DBA::update('event', ['cid' => $new_cid], ['cid' => $old_cid]);
|
DBA::update('event', ['cid' => $new_cid], ['cid' => $old_cid]);
|
||||||
|
@ -53,11 +53,9 @@ class MergeContact
|
||||||
if ($uid == 0) {
|
if ($uid == 0) {
|
||||||
DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]);
|
DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]);
|
||||||
DBA::delete('post-tag', ['cid' => $old_cid]);
|
DBA::delete('post-tag', ['cid' => $old_cid]);
|
||||||
DBA::update('item', ['author-id' => $new_cid], ['author-id' => $old_cid]);
|
Post::update(['author-id' => $new_cid], ['author-id' => $old_cid]);
|
||||||
DBA::update('item', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
Post::update(['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
||||||
DBA::update('item', ['causer-id' => $new_cid], ['causer-id' => $old_cid]);
|
Post::update(['causer-id' => $new_cid], ['causer-id' => $old_cid]);
|
||||||
DBA::update('thread', ['author-id' => $new_cid], ['author-id' => $old_cid]);
|
|
||||||
DBA::update('thread', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
|
|
||||||
} else {
|
} else {
|
||||||
/// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
|
/// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,7 +26,7 @@ use Friendica\Model\ItemURI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do some repairs in database entries
|
* Do some repairs in database entries
|
||||||
*
|
* @todo This class can be deleted without replacement when the item table is removed
|
||||||
*/
|
*/
|
||||||
class RepairDatabase
|
class RepairDatabase
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue