* @return boolean|object
*
* Example:
- * $table = "item";
+ * $table = "post";
* $fields = array("id", "uri", "uid", "network");
*
* $condition = array("uid" => 1, "network" => 'dspr');
* @return int
*
* Example:
- * $table = "item";
+ * $table = "post";
*
* $condition = ["uid" => 1, "network" => 'dspr'];
* or:
*
*
* Example:
- * $table = 'item';
+ * $table = 'post';
* or:
* $table = ['schema' => 'table'];
* @see DBA::buildTableString()
* @return int
*
* Example:
- * $table = "item";
+ * $table = "post";
*
* $condition = ["uid" => 1, "network" => 'dspr'];
* or:
// Set the item to "deleted"
$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'], '');
self::deleteThread($item['id'], $item['parent-uri-id']);
$item["global"] = true;
// 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 {
$item['global'] = Post::exists(['uid' => 0, 'uri-id' => $item['uri-id']]);
}
}
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 {
- DBA::update('item', ['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
+ Post::update(['changed' => DateTimeFormat::utcNow()], ['id' => $parent_id]);
}
if ($item['gravity'] === GRAVITY_PARENT) {
// update profile links in the format "http://server.tld"
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, "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_table($a, "contact", ['addr'], $old_host, $new_host);
self::exportAccount($a);
echo "\n";
- $total = DBA::count('item', ['uid' => local_user()]);
+ $total = Post::count(['uid' => local_user()]);
// chunk the output to avoid exhausting memory
for ($x = 0; $x < $total; $x += 500) {
use Friendica\Core\Logger;
use Friendica\Database\DBA;
+use Friendica\Model\Post;
class CleanItemUri
{
{
// 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.
- $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]]);
if (empty($item['uri-id'])) {
Logger::warning('No item with uri-id found - we better quit here');
Logger::log('Delete expired items', Logger::DEBUG);
// physically remove anything that has been deleted for more than two months
$condition = ["`deleted` AND `changed` < UTC_TIMESTAMP() - INTERVAL 60 DAY"];
- $rows = DBA::select('item', ['id', 'guid', 'uri-id', 'uid'], $condition);
- while ($row = DBA::fetch($rows)) {
+ $rows = Post::select(['id', 'guid', 'uri-id', 'uid'], $condition);
+ while ($row = Post::fetch($rows)) {
Logger::info('Delete expired item', ['id' => $row['id'], 'guid' => $row['guid']]);
DBA::delete('item', ['id' => $row['id']]);
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);
use Friendica\Core\Logger;
use Friendica\Database\DBA;
+use Friendica\Model\Post;
class MergeContact
{
Logger::info('Handling duplicate', ['search' => $old_cid, 'replace' => $new_cid]);
// Search and replace
- DBA::update('item', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
- DBA::update('thread', ['contact-id' => $new_cid], ['contact-id' => $old_cid]);
+ Post::update(['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('event', ['cid' => $new_cid], ['cid' => $old_cid]);
if ($uid == 0) {
DBA::update('post-tag', ['cid' => $new_cid], ['cid' => $old_cid]);
DBA::delete('post-tag', ['cid' => $old_cid]);
- DBA::update('item', ['author-id' => $new_cid], ['author-id' => $old_cid]);
- DBA::update('item', ['owner-id' => $new_cid], ['owner-id' => $old_cid]);
- DBA::update('item', ['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]);
+ Post::update(['author-id' => $new_cid], ['author-id' => $old_cid]);
+ Post::update(['owner-id' => $new_cid], ['owner-id' => $old_cid]);
+ Post::update(['causer-id' => $new_cid], ['causer-id' => $old_cid]);
} else {
/// @todo Check if some other data needs to be adjusted as well, possibly the "rel" status?
}
/**
* Do some repairs in database entries
- *
+ * @todo This class can be deleted without replacement when the item table is removed
*/
class RepairDatabase
{