mirror of
https://github.com/friendica/friendica
synced 2025-04-27 21:50:11 +00:00
"item" is replaced by "post-view" / postupdate check added
This commit is contained in:
parent
d29bad0cb2
commit
4157db5473
28 changed files with 104 additions and 782 deletions
|
@ -513,15 +513,13 @@ class Event
|
|||
}
|
||||
|
||||
// Query for the event by event id
|
||||
$r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event`
|
||||
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
|
||||
$events = DBA::toArray(DBA::p("SELECT `event`.*, `post-view`.`id` AS `itemid` FROM `event`
|
||||
LEFT JOIN `post-view` ON `post-view`.`event-id` = `event`.`id` AND `post-view`.`uid` = `event`.`uid`
|
||||
WHERE `event`.`uid` = %d AND `event`.`id` = %d $sql_extra",
|
||||
intval($owner_uid),
|
||||
intval($event_id)
|
||||
);
|
||||
$owner_uid, $event_id));
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$return = self::removeDuplicates($r);
|
||||
if (DBA::isResult($events)) {
|
||||
$return = self::removeDuplicates($events);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
@ -554,24 +552,17 @@ class Event
|
|||
|
||||
// Query for the event by date.
|
||||
// @todo Slow query (518 seconds to run), to be optimzed
|
||||
$r = q("SELECT `event`.*, `item`.`id` AS `itemid` FROM `event`
|
||||
LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` AND `item`.`uid` = `event`.`uid`
|
||||
WHERE `event`.`uid` = %d AND event.ignore = %d
|
||||
AND ((`adjust` = 0 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s')
|
||||
OR (`adjust` = 1 AND (`finish` >= '%s' OR (nofinish AND start >= '%s')) AND `start` <= '%s'))
|
||||
$sql_extra ",
|
||||
intval($owner_uid),
|
||||
intval($event_params["ignore"]),
|
||||
DBA::escape($event_params["start"]),
|
||||
DBA::escape($event_params["start"]),
|
||||
DBA::escape($event_params["finish"]),
|
||||
DBA::escape($event_params["adjust_start"]),
|
||||
DBA::escape($event_params["adjust_start"]),
|
||||
DBA::escape($event_params["adjust_finish"])
|
||||
);
|
||||
$events = DBA::toArray(DBA::p("SELECT `event`.*, `post-view`.`id` AS `itemid` FROM `event`
|
||||
LEFT JOIN `post-view` ON `post-view`.`event-id` = `event`.`id` AND `post-view`.`uid` = `event`.`uid`
|
||||
WHERE `event`.`uid` = ? AND `event`.`ignore` = ?
|
||||
AND ((NOT `adjust` AND (`finish` >= ? OR (`nofinish` AND `start` >= ?)) AND `start` <= ?)
|
||||
OR (`adjust` AND (`finish` >= ? OR (`nofinish` AND `start` >= ?)) AND `start` <= ?))" . $sql_extra,
|
||||
$owner_uid, $event_params["ignore"],
|
||||
$event_params["start"], $event_params["start"], $event_params["finish"],
|
||||
$event_params["adjust_start"], $event_params["adjust_start"], $event_params["adjust_finish"]));
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$return = self::removeDuplicates($r);
|
||||
if (DBA::isResult($events)) {
|
||||
$return = self::removeDuplicates($events);
|
||||
}
|
||||
|
||||
return $return;
|
||||
|
|
|
@ -160,7 +160,7 @@ class Group
|
|||
public static function countUnseen()
|
||||
{
|
||||
$stmt = DBA::p("SELECT `group`.`id`, `group`.`name`,
|
||||
(SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`)
|
||||
(SELECT COUNT(*) FROM `post-view`
|
||||
WHERE `uid` = ?
|
||||
AND `unseen`
|
||||
AND `contact-id` IN
|
||||
|
|
|
@ -148,15 +148,6 @@ class Item
|
|||
return $postfields;
|
||||
}
|
||||
|
||||
public static function isLegacyMode()
|
||||
{
|
||||
if (is_null(self::$legacy_mode)) {
|
||||
self::$legacy_mode = (DI::config()->get("system", "post_update_version") < 1279);
|
||||
}
|
||||
|
||||
return self::$legacy_mode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pinned state of an item
|
||||
*
|
||||
|
@ -226,7 +217,7 @@ class Item
|
|||
* @return array|false current row or false
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function fetch($stmt)
|
||||
private static function fetch($stmt)
|
||||
{
|
||||
$row = DBA::fetch($stmt);
|
||||
|
||||
|
@ -267,17 +258,6 @@ class Item
|
|||
|
||||
// ---------------------- Transform item content data ----------------------
|
||||
|
||||
// Fetch data from the item-content table whenever there is content there
|
||||
if (self::isLegacyMode()) {
|
||||
$legacy_fields = array_merge(Post\DeliveryData::LEGACY_FIELD_LIST, self::MIXED_CONTENT_FIELDLIST);
|
||||
foreach ($legacy_fields as $field) {
|
||||
if (empty($row[$field]) && !empty($row['internal-item-' . $field])) {
|
||||
$row[$field] = $row['internal-item-' . $field];
|
||||
}
|
||||
unset($row['internal-item-' . $field]);
|
||||
}
|
||||
}
|
||||
|
||||
if (array_key_exists('verb', $row)) {
|
||||
if (!is_null($row['internal-verb'])) {
|
||||
$row['verb'] = $row['internal-verb'];
|
||||
|
@ -390,28 +370,6 @@ class Item
|
|||
return $retval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Select rows from the item table for a given user
|
||||
*
|
||||
* @param integer $uid User ID
|
||||
* @param array $selected Array of selected fields, empty for all
|
||||
* @param array $condition Array of fields for condition
|
||||
* @param array $params Array of several parameters
|
||||
*
|
||||
* @return boolean|object
|
||||
* @throws \Exception
|
||||
*/
|
||||
public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['uid'] = $uid;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = self::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
return self::select($selected, $condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single record from the item table and returns it in an associative array
|
||||
*
|
||||
|
@ -830,9 +788,6 @@ class Item
|
|||
foreach ($fields as $table => $table_fields) {
|
||||
foreach ($table_fields as $field => $select) {
|
||||
if (empty($selected) || in_array($select, $selected)) {
|
||||
if (self::isLegacyMode() && in_array($select, $legacy_fields)) {
|
||||
$selection[] = "`item`.`".$select."` AS `internal-item-" . $select . "`";
|
||||
}
|
||||
if (is_int($field)) {
|
||||
$selection[] = "`" . $table . "`.`" . $select . "`";
|
||||
} else {
|
||||
|
@ -904,7 +859,7 @@ class Item
|
|||
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) || !self::isLegacyMode()) {
|
||||
if (in_array($field, self::CONTENT_FIELDLIST)) {
|
||||
unset($fields[$field]);
|
||||
} else {
|
||||
$fields[$field] = null;
|
||||
|
@ -965,14 +920,6 @@ class Item
|
|||
$item_content = DBA::selectFirst('item-content', [], ['uri-id' => $item['uri-id']]);
|
||||
if (DBA::isResult($item_content)) {
|
||||
$item_fields = ['icid' => $item_content['id']];
|
||||
// Clear all fields in the item table that have a content in the item-content table
|
||||
if (self::isLegacyMode()) {
|
||||
foreach ($item_content as $field => $content) {
|
||||
if (in_array($field, self::MIXED_CONTENT_FIELDLIST) && !empty($content)) {
|
||||
$item_fields[$field] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
DBA::update('item', $item_fields, ['id' => $item['id']]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ class ItemContent
|
|||
{
|
||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `item-content` WHERE MATCH (`title`, `content-warning`, `body`) AGAINST (? IN BOOLEAN MODE))
|
||||
AND (NOT `private` OR (`private` AND `uid` = ?))
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
|
||||
$search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
|
||||
if (!empty($last_uriid)) {
|
||||
|
@ -71,7 +71,7 @@ class ItemContent
|
|||
{
|
||||
$condition = ["`uri-id` IN (SELECT `uri-id` FROM `item-content` WHERE MATCH (`title`, `content-warning`, `body`) AGAINST (? IN BOOLEAN MODE))
|
||||
AND (NOT `private` OR (`private` AND `uid` = ?))
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
|
||||
$search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
return Post::count($condition);
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ class Nodeinfo
|
|||
|
||||
$logger->debug('user statistics', $userStats);
|
||||
|
||||
$items = DBA::p("SELECT COUNT(*) AS `total`, `gravity` FROM `item` WHERE `origin` AND NOT `deleted` AND `uid` != 0 AND `gravity` IN (?, ?) GROUP BY `gravity`",
|
||||
$items = DBA::p("SELECT COUNT(*) AS `total`, `gravity` FROM `post-view` WHERE `origin` AND NOT `deleted` AND `uid` != 0 AND `gravity` IN (?, ?) GROUP BY `gravity`",
|
||||
GRAVITY_PARENT, GRAVITY_COMMENT);
|
||||
while ($item = DBA::fetch($items)) {
|
||||
if ($item['gravity'] == GRAVITY_PARENT) {
|
||||
|
|
|
@ -43,7 +43,7 @@ use Psr\Log\LoggerInterface;
|
|||
* @property integer parent Parent Item Id
|
||||
* @property boolean seen Whether the notification was read or not.
|
||||
* @property string verb Verb URL (@see http://activitystrea.ms)
|
||||
* @property string otype Subject type (`item`, `intro` or `mail`)
|
||||
* @property string otype Subject type ('item', 'intro' or 'mail')
|
||||
*
|
||||
* @property-read string name_cache Full name of the contact subject
|
||||
* @property-read string msg_cache Plaintext version of the notification text with a placeholder (`{0}`) for the subject contact's name.
|
||||
|
|
|
@ -452,7 +452,7 @@ class Tag
|
|||
public static function countByTag(string $search, int $uid = 0)
|
||||
{
|
||||
$condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
|
||||
$search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
$params = ['group_by' => ['uri-id']];
|
||||
|
||||
|
@ -472,7 +472,7 @@ class Tag
|
|||
public static function getURIIdListByTag(string $search, int $uid = 0, int $start = 0, int $limit = 100, int $last_uriid = 0)
|
||||
{
|
||||
$condition = ["`name` = ? AND (NOT `private` OR (`private` AND `uid` = ?))
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `item` WHERE `network` IN (?, ?, ?, ?))",
|
||||
AND `uri-id` IN (SELECT `uri-id` FROM `post-view` WHERE `network` IN (?, ?, ?, ?))",
|
||||
$search, $uid, Protocol::ACTIVITYPUB, Protocol::DFRN, Protocol::DIASPORA, Protocol::OSTATUS];
|
||||
|
||||
if (!empty($last_uriid)) {
|
||||
|
|
|
@ -72,9 +72,8 @@ class UserItem
|
|||
|
||||
// Add every user who participated so far in this thread
|
||||
// This can only happen with participations on global items. (means: uid = 0)
|
||||
$users = DBA::p("SELECT DISTINCT(`contact`.`uid`) FROM `item`
|
||||
INNER JOIN `contact` ON `contact`.`id` = `item`.`contact-id` AND `contact`.`uid` != 0
|
||||
WHERE `parent` IN (SELECT `parent` FROM `item` WHERE `id`=?)", $iid);
|
||||
$users = DBA::p("SELECT DISTINCT(`contact-uid`) AS `uid` FROM `post-view`
|
||||
WHERE `contact-uid` != 0 AND `parent` IN (SELECT `parent` FROM `post-view` WHERE `id` = ?)", $iid);
|
||||
while ($user = DBA::fetch($users)) {
|
||||
$uids[] = $user['uid'];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue