Get rid of unneeded or redundant fields

This commit is contained in:
Michael 2018-06-03 07:42:56 +00:00
parent a720c4f501
commit 3f07d01dd1
9 changed files with 57 additions and 87 deletions

View file

@ -418,7 +418,6 @@ These Fields are not added below (yet). They are here to for bug search.
`item`.`inform`,
`item`.`pubmail`,
`item`.`visible`,
`item`.`spam`,
`item`.`bookmark`,
`item`.`unseen`,
`item`.`deleted`,
@ -426,10 +425,12 @@ These Fields are not added below (yet). They are here to for bug search.
`item`.`mention`,
`item`.`global`,
`item`.`shadow`,
`item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
`item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
*/
return "`item`.`author-id`, `item`.`author-link`, `item`.`author-name`, `item`.`author-avatar`,
`item`.`owner-id`, `item`.`owner-link`, `item`.`owner-name`, `item`.`owner-avatar`,
return "`item`.`author-id`,
`item`.`owner-id`,
`item`.`contact-id`, `item`.`uid`, `item`.`id`, `item`.`parent`,
`item`.`uri`, `item`.`thr-parent`, `item`.`parent-uri`, `item`.`content-warning`,
`item`.`commented`, `item`.`created`, `item`.`edited`, `item`.`received`,
@ -441,7 +442,9 @@ These Fields are not added below (yet). They are here to for bug search.
`item`.`allow_cid`, `item`.`allow_gid`, `item`.`deny_cid`, `item`.`deny_gid`,
`item`.`id` AS `item_id`, `item`.`network` AS `item_network`,
`author`.`thumb` AS `author-thumb`, `owner`.`thumb` AS `owner-thumb`,
`author`.`url` AS `author-link`, `author`.`name` AS `author-name`, `author`.`thumb` AS `author-avatar`,
`owner`.`url` AS `owner-link`, `owner`.`name` AS `owner-name`, `owner`.`thumb` AS `owner-avatar`,
`contact`.`url` AS `contact-link`, `contact`.`name` AS `contact-name`, `contact`.`thumb` AS `contact-avatar`,
`contact`.`network`, `contact`.`url`, `contact`.`name`, `contact`.`writable`,
`contact`.`self`, `contact`.`id` AS `cid`, `contact`.`alias`,
@ -532,7 +535,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
. ((x($_GET, 'bmark')) ? '&bmark=' . $_GET['bmark'] : '')
. ((x($_GET, 'liked')) ? '&liked=' . $_GET['liked'] : '')
. ((x($_GET, 'conv')) ? '&conv=' . $_GET['conv'] : '')
. ((x($_GET, 'spam')) ? '&spam=' . $_GET['spam'] : '')
. ((x($_GET, 'nets')) ? '&nets=' . $_GET['nets'] : '')
. ((x($_GET, 'cmin')) ? '&cmin=' . $_GET['cmin'] : '')
. ((x($_GET, 'cmax')) ? '&cmax=' . $_GET['cmax'] : '')
@ -658,6 +660,13 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
continue;
}
if ($item['network'] == NETWORK_FEED) {
$item['author-avatar'] = $item['contact-avatar'];
$item['author-name'] = $item['contact-name'];
$item['owner-avatar'] = $item['contact-avatar'];
$item['owner-name'] = $item['contact-name'];
}
$profile_name = (strlen($item['author-name']) ? $item['author-name'] : $item['name']);
if ($item['author-link'] && !$item['author-name']) {
$profile_name = $item['author-link'];
@ -671,24 +680,6 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
$sparkle = ' sparkle';
}
if (!x($item, 'author-thumb') || ($item['author-thumb'] == "")) {
$author_contact = Contact::getDetailsByURL($item['author-link'], $profile_owner);
if ($author_contact["thumb"]) {
$item['author-thumb'] = $author_contact["thumb"];
} else {
$item['author-thumb'] = $item['author-avatar'];
}
}
if (!isset($item['owner-thumb']) || ($item['owner-thumb'] == "")) {
$owner_contact = Contact::getDetailsByURL($item['owner-link'], $profile_owner);
if ($owner_contact["thumb"]) {
$item['owner-thumb'] = $owner_contact["thumb"];
} else {
$item['owner-thumb'] = $item['owner-avatar'];
}
}
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
Addon::callHooks('render_location',$locate);
@ -749,7 +740,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
'name' => $profile_name_e,
'sparkle' => $sparkle,
'lock' => $lock,
'thumb' => System::removedBaseUrl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
'thumb' => System::removedBaseUrl(proxy_url($item['author-avatar'], false, PROXY_SIZE_THUMB)),
'title' => $title_e,
'body' => $body_e,
'tags' => $tags_e,
@ -768,7 +759,7 @@ function conversation(App $a, $items, $mode, $update, $preview = false, $order =
'indent' => '',
'owner_name' => $owner_name_e,
'owner_url' => $owner_url,
'owner_photo' => System::removedBaseUrl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
'owner_photo' => System::removedBaseUrl(proxy_url($item['owner-avatar'], false, PROXY_SIZE_THUMB)),
'plink' => get_plink($item),
'edpost' => false,
'isstarred' => $isstarred,

View file

@ -152,7 +152,7 @@ function notification($params)
}
// "your post"
if (DBM::is_result($item) && $item['owner-name'] == $item['author-name'] && $item['wall']) {
if (DBM::is_result($item) && $item['owner-id'] == $item['author-id'] && $item['wall']) {
$dest_str = L10n::t('%1$s commented on [url=%2$s]your %3$s[/url]',
'[url='.$params['source_link'].']'.$params['source_name'].'[/url]',
$itemlink,

View file

@ -928,7 +928,7 @@ function admin_page_site_post(App $a)
update_table("term", ['url'], $old_url, $new_url);
update_table("contact", ['photo', 'thumb', 'micro', 'url', 'nurl', 'alias', 'request', 'notify', 'poll', 'confirm', 'poco', 'avatar'], $old_url, $new_url);
update_table("gcontact", ['url', 'nurl', 'photo', 'server_url', 'notify', 'alias'], $old_url, $new_url);
update_table("item", ['owner-link', 'owner-avatar', 'author-link', 'author-avatar', 'body', 'plink', 'tag'], $old_url, $new_url);
update_table("item", ['owner-link', 'author-link', 'body', 'plink', 'tag'], $old_url, $new_url);
// update profile addresses in the format "user@server.tld"
update_table("contact", ['addr'], $old_host, $new_host);

View file

@ -49,8 +49,7 @@ function display_init(App $a)
// Does the local user have this item?
if (local_user()) {
$r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`,
`author-avatar`, `network`, `body`, `uid`, `owner-link`
$r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid`
FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated`
AND `guid` = ? AND `uid` = ? LIMIT 1", $a->argv[1], local_user());
if (DBM::is_result($r)) {
@ -60,8 +59,7 @@ function display_init(App $a)
// Is it an item with uid=0?
if (!DBM::is_result($r)) {
$r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`,
`author-avatar`, `network`, `body`, `uid`, `owner-link`
$r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid`
FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated`
AND NOT `private` AND `uid` = 0
AND `guid` = ? LIMIT 1", $a->argv[1]);
@ -73,8 +71,7 @@ function display_init(App $a)
return;
}
} elseif (($a->argc == 3) && ($nick == 'feed-item')) {
$r = dba::fetch_first("SELECT `id`, `parent`, `author-name`, `author-link`,
`author-avatar`, `network`, `body`, `uid`, `owner-link`
$r = dba::fetch_first("SELECT `id`, `parent`, `author-id`, `body`, `uid`
FROM `item` WHERE `visible` AND NOT `deleted` AND NOT `moderated`
AND NOT `private` AND `uid` = 0
AND `id` = ? LIMIT 1", $a->argv[2]);
@ -87,7 +84,7 @@ function display_init(App $a)
}
if ($r["id"] != $r["parent"]) {
$r = dba::fetch_first("SELECT `id`, `author-name`, `author-link`, `author-avatar`, `network`, `body`, `uid`, `owner-link` FROM `item`
$r = dba::fetch_first("SELECT `id`, `author-id`, `body`, `uid` FROM `item`
WHERE `item`.`visible` AND NOT `item`.`deleted` AND NOT `item`.`moderated`
AND `id` = ?", $r["parent"]);
}
@ -117,14 +114,16 @@ function display_init(App $a)
}
function display_fetchauthor($a, $item) {
$author = dba::selectFirst('contact', ['name', 'nick', 'photo', 'network', 'url'], ['id' => $item['author-id']]);
$profiledata = [];
$profiledata["uid"] = -1;
$profiledata["nickname"] = $item["author-name"];
$profiledata["name"] = $item["author-name"];
$profiledata["picdate"] = "";
$profiledata["photo"] = $item["author-avatar"];
$profiledata["url"] = $item["author-link"];
$profiledata["network"] = $item["network"];
$profiledata['uid'] = -1;
$profiledata['nickname'] = $author['nick'];
$profiledata['name'] = $author['name'];
$profiledata['picdate'] = '';
$profiledata['photo'] = $author['photo'];
$profiledata['url'] = $author['url'];
$profiledata['network'] = $author['network'];
// Check for a repeated message
$skip = false;

View file

@ -103,7 +103,6 @@ function network_init(App $a)
'/new', //new
'', //starred
'', //bookmarked
'', //spam
];
$tab_args = [
'f=&order=comment', //all
@ -112,7 +111,6 @@ function network_init(App $a)
'', //new
'f=&star=1', //starred
'f=&bmark=1', //bookmarked
'f=&spam=1', //spam
];
$k = array_search('active', $last_sel_tabs);
@ -218,9 +216,8 @@ function saved_searches($search)
* '/network/new', => $new_active = 'active'
* '/network?f=&star=1', => $starred_active = 'active'
* '/network?f=&bmark=1', => $bookmarked_active = 'active'
* '/network?f=&spam=1', => $spam_active = 'active'
*
* @return Array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active);
* @return Array ($no_active, $comment_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active);
*/
function network_query_get_sel_tab(App $a)
{
@ -230,7 +227,6 @@ function network_query_get_sel_tab(App $a)
$bookmarked_active = '';
$all_active = '';
$conv_active = '';
$spam_active = '';
$postord_active = '';
if (($a->argc > 1 && $a->argv[1] === 'new') || ($a->argc > 2 && $a->argv[2] === 'new')) {
@ -249,11 +245,7 @@ function network_query_get_sel_tab(App $a)
$conv_active = 'active';
}
if (x($_GET, 'spam')) {
$spam_active = 'active';
}
if (($new_active == '') && ($starred_active == '') && ($bookmarked_active == '') && ($conv_active == '') && ($spam_active == '')) {
if (($new_active == '') && ($starred_active == '') && ($bookmarked_active == '') && ($conv_active == '')) {
$no_active = 'active';
}
@ -264,7 +256,7 @@ function network_query_get_sel_tab(App $a)
}
}
return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active];
return [$no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active];
}
function network_query_get_sel_group(App $a)
@ -928,7 +920,7 @@ function network_tabs(App $a)
// item filter tabs
/// @TODO fix this logic, reduce duplication
/// $a->page['content'] .= '<div class="tabs-wrapper">';
list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active) = network_query_get_sel_tab($a);
list($no_active, $all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active) = network_query_get_sel_tab($a);
// if no tabs are selected, defaults to comments
if ($no_active == 'active') {
@ -1004,7 +996,7 @@ function network_tabs(App $a)
// save selected tab, but only if not in file mode
if (!x($_GET, 'file')) {
PConfig::set(local_user(), 'network.view', 'tab.selected', [
$all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active, $spam_active
$all_active, $postord_active, $conv_active, $new_active, $starred_active, $bookmarked_active
]);
}

View file

@ -442,7 +442,7 @@ function ping_get_notifications($uid)
do {
$r = q(
"SELECT `notify`.*, `item`.`visible`, `item`.`spam`, `item`.`deleted`
"SELECT `notify`.*, `item`.`visible`, `item`.`deleted`
FROM `notify` LEFT JOIN `item` ON `item`.`id` = `notify`.`iid`
WHERE `notify`.`uid` = %d AND `notify`.`msg` != ''
AND NOT (`notify`.`type` IN (%d, %d))
@ -469,10 +469,6 @@ function ping_get_notifications($uid)
$notification["visible"] = true;
}
if (is_null($notification["spam"])) {
$notification["spam"] = 0;
}
if (is_null($notification["deleted"])) {
$notification["deleted"] = 0;
}
@ -495,7 +491,6 @@ function ping_get_notifications($uid)
$notification["href"] = System::baseUrl() . "/notify/view/" . $notification["id"];
if ($notification["visible"]
&& !$notification["spam"]
&& !$notification["deleted"]
&& !(x($result, $notification["parent"]) && is_array($result[$notification["parent"]]))
) {

View file

@ -1185,7 +1185,6 @@ class DBStructure
"pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been favourited"],
"bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => "item has been bookmarked"],
"unseen" => ["type" => "boolean", "not null" => "1", "default" => "1", "comment" => "item has not been seen"],
@ -1196,7 +1195,6 @@ class DBStructure
"network" => ["type" => "char(4)", "not null" => "1", "default" => "", "comment" => "Network from where the item comes from"],
"rendered-hash" => ["type" => "varchar(32)", "not null" => "1", "default" => "", "comment" => ""],
"rendered-html" => ["type" => "mediumtext", "comment" => "item.body converted to html"],
"global" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
],
"indexes" => [
"PRIMARY" => ["id"],
@ -1681,7 +1679,6 @@ class DBStructure
"pubmail" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"moderated" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"visible" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"spam" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"starred" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"ignored" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],
"bookmark" => ["type" => "boolean", "not null" => "1", "default" => "0", "comment" => ""],

View file

@ -566,6 +566,14 @@ class Item extends BaseObject
return 0;
}
//unset($item['author-link']);
//unset($item['author-name']);
//unset($item['author-avatar']);
//unset($item['owner-link']);
unset($item['owner-name']);
unset($item['owner-avatar']);
if ($item['network'] == NETWORK_PHANTOM) {
logger('Missing network. Called by: '.System::callstack(), LOGGER_DEBUG);
@ -716,16 +724,6 @@ class Item extends BaseObject
}
}
// Is this item available in the global items (with uid=0)?
if ($item["uid"] == 0) {
$item["global"] = true;
// Set the global flag on all items if this was a global item entry
dba::update('item', ['global' => true], ['uri' => $item["uri"]]);
} else {
$item["global"] = dba::exists('item', ['uid' => 0, 'uri' => $item["uri"]]);
}
// ACL settings
if (strlen($allow_cid) || strlen($allow_gid) || strlen($deny_cid) || strlen($deny_gid)) {
$private = 1;
@ -1483,8 +1481,7 @@ class Item extends BaseObject
$forum_mode = ($prvgroup ? 2 : 1);
$fields = ['wall' => true, 'origin' => true, 'forum_mode' => $forum_mode, 'contact-id' => $self['id'],
'owner-id' => $owner_id, 'owner-name' => $self['name'], 'owner-link' => $self['url'],
'owner-avatar' => $self['thumb'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
'owner-id' => $owner_id, 'owner-link' => $self['url'], 'private' => $private, 'allow_cid' => $user['allow_cid'],
'allow_gid' => $user['allow_gid'], 'deny_cid' => $user['deny_cid'], 'deny_gid' => $user['deny_gid']];
dba::update('item', $fields, ['id' => $item_id]);
@ -2075,7 +2072,7 @@ EOT;
private static function addThread($itemid, $onlyshadow = false)
{
$fields = ['uid', 'created', 'edited', 'commented', 'received', 'changed', 'wall', 'private', 'pubmail',
'moderated', 'visible', 'spam', 'starred', 'bookmark', 'contact-id',
'moderated', 'visible', 'starred', 'bookmark', 'contact-id',
'deleted', 'origin', 'forum_mode', 'mention', 'network', 'author-id', 'owner-id'];
$condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid];
$item = dba::selectFirst('item', $fields, $condition);
@ -2096,7 +2093,7 @@ EOT;
private static function updateThread($itemid, $setmention = false)
{
$fields = ['uid', 'guid', 'title', 'body', 'created', 'edited', 'commented', 'received', 'changed',
'wall', 'private', 'pubmail', 'moderated', 'visible', 'spam', 'starred', 'bookmark', 'contact-id',
'wall', 'private', 'pubmail', 'moderated', 'visible', 'starred', 'bookmark', 'contact-id',
'deleted', 'origin', 'forum_mode', 'network', 'author-id', 'owner-id', 'rendered-html', 'rendered-hash'];
$condition = ["`id` = ? AND (`parent` = ? OR `parent` = 0)", $itemid, $itemid];

View file

@ -198,6 +198,13 @@ class Post extends BaseObject
$filer = (($conv->getProfileOwner() == local_user() && ($item['uid'] != 0)) ? L10n::t("save to folder") : false);
if ($item['network'] == NETWORK_FEED) {
$item['author-avatar'] = $item['contact-avatar'];
$item['author-name'] = $item['contact-name'];
$item['owner-avatar'] = $item['contact-avatar'];
$item['owner-name'] = $item['contact-name'];
}
$diff_author = !link_compare($item['url'], $item['author-link']);
$profile_name = htmlentities(((strlen($item['author-name'])) && $diff_author) ? $item['author-name'] : $item['name']);
if ($item['author-link'] && (!$item['author-name'])) {
@ -209,14 +216,6 @@ class Post extends BaseObject
$sparkle = ' sparkle';
}
if (($item['network'] == NETWORK_FEED) || empty($item['author-thumb'])) {
$item['author-thumb'] = $item['author-avatar'];
}
if (($item['network'] == NETWORK_FEED) || empty($item['owner-thumb'])) {
$item['owner-thumb'] = $item['owner-avatar'];
}
$locate = ['location' => $item['location'], 'coord' => $item['coord'], 'html' => ''];
Addon::callHooks('render_location', $locate);
$location = ((strlen($locate['html'])) ? $locate['html'] : render_location_dummy($locate));
@ -369,7 +368,7 @@ class Post extends BaseObject
'profile_url' => $profile_link,
'item_photo_menu' => item_photo_menu($item),
'name' => $name_e,
'thumb' => $a->remove_baseurl(proxy_url($item['author-thumb'], false, PROXY_SIZE_THUMB)),
'thumb' => $a->remove_baseurl(proxy_url($item['author-avatar'], false, PROXY_SIZE_THUMB)),
'osparkle' => $osparkle,
'sparkle' => $sparkle,
'title' => $title_e,
@ -382,7 +381,7 @@ class Post extends BaseObject
'indent' => $indent,
'shiny' => $shiny,
'owner_url' => $this->getOwnerUrl(),
'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-thumb'], false, PROXY_SIZE_THUMB)),
'owner_photo' => $a->remove_baseurl(proxy_url($item['owner-avatar'], false, PROXY_SIZE_THUMB)),
'owner_name' => htmlentities($owner_name_e),
'plink' => get_plink($item),
'edpost' => Feature::isEnabled($conv->getProfileOwner(), 'edit_posts') ? $edpost : '',