Replaced queries
This commit is contained in:
parent
88353ce56f
commit
f99af007ae
|
@ -2747,32 +2747,30 @@ class Diaspora
|
||||||
public static function originalItem($guid, $orig_author)
|
public static function originalItem($guid, $orig_author)
|
||||||
{
|
{
|
||||||
// Do we already have this item?
|
// Do we already have this item?
|
||||||
$r = q(
|
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
|
||||||
"SELECT `body`, `tag`, `app`, `created`, `object-type`, `uri`, `guid`,
|
'author-name', 'author-link', 'author-avatar'];
|
||||||
`author-name`, `author-link`, `author-avatar`
|
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false];
|
||||||
FROM `item` WHERE `guid` = '%s' AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
|
$item = dba::selectfirst('item', $fields, $condition);
|
||||||
dbesc($guid)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($item)) {
|
||||||
logger("reshared message ".$guid." already exists on system.");
|
logger("reshared message ".$guid." already exists on system.");
|
||||||
|
|
||||||
// Maybe it is already a reshared item?
|
// Maybe it is already a reshared item?
|
||||||
// Then refetch the content, if it is a reshare from a reshare.
|
// Then refetch the content, if it is a reshare from a reshare.
|
||||||
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
||||||
if (self::isReshare($r[0]["body"], true)) {
|
if (self::isReshare($item["body"], true)) {
|
||||||
$r = [];
|
$r = [];
|
||||||
} elseif (self::isReshare($r[0]["body"], false) || strstr($r[0]["body"], "[share")) {
|
} elseif (self::isReshare($item["body"], false) || strstr($item["body"], "[share")) {
|
||||||
$r[0]["body"] = Markdown::toBBCode(BBCode::toMarkdown($r[0]["body"]));
|
$item["body"] = Markdown::toBBCode(BBCode::toMarkdown($item["body"]));
|
||||||
|
|
||||||
$r[0]["body"] = self::replacePeopleGuid($r[0]["body"], $r[0]["author-link"]);
|
$item["body"] = self::replacePeopleGuid($item["body"], $item["author-link"]);
|
||||||
|
|
||||||
// Add OEmbed and other information to the body
|
// Add OEmbed and other information to the body
|
||||||
$r[0]["body"] = add_page_info_to_body($r[0]["body"], false, true);
|
$item["body"] = add_page_info_to_body($item["body"], false, true);
|
||||||
|
|
||||||
return $r[0];
|
return $item;
|
||||||
} else {
|
} else {
|
||||||
return $r[0];
|
return $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2788,21 +2786,19 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($item_id) {
|
if ($item_id) {
|
||||||
$r = q(
|
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
|
||||||
"SELECT `body`, `tag`, `app`, `created`, `object-type`, `uri`, `guid`,
|
'author-name', 'author-link', 'author-avatar'];
|
||||||
`author-name`, `author-link`, `author-avatar`
|
$condition = ['id' => $item_id, 'visible' => true, 'deleted' => false];
|
||||||
FROM `item` WHERE `id` = %d AND `visible` AND NOT `deleted` AND `body` != '' LIMIT 1",
|
$item = dba::selectfirst('item', $fields, $condition);
|
||||||
intval($item_id)
|
|
||||||
);
|
|
||||||
|
|
||||||
if (DBM::is_result($r)) {
|
if (DBM::is_result($item)) {
|
||||||
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
||||||
if (self::isReshare($r[0]["body"], false)) {
|
if (self::isReshare($item["body"], false)) {
|
||||||
$r[0]["body"] = Markdown::toBBCode(BBCode::toMarkdown($r[0]["body"]));
|
$item["body"] = Markdown::toBBCode(BBCode::toMarkdown($item["body"]));
|
||||||
$r[0]["body"] = self::replacePeopleGuid($r[0]["body"], $r[0]["author-link"]);
|
$item["body"] = self::replacePeopleGuid($item["body"], $item["author-link"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $r[0];
|
return $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3584,15 +3580,11 @@ class Diaspora
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($guid != "") && $complete) {
|
if (($guid != "") && $complete) {
|
||||||
$r = q(
|
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
|
||||||
"SELECT `contact-id` FROM `item` WHERE `guid` = '%s' AND `network` IN ('%s', '%s') LIMIT 1",
|
$item = dba::selectFirst('item', ['contact-id'], $condition);
|
||||||
dbesc($guid),
|
if (DBM::is_result($item)) {
|
||||||
NETWORK_DFRN,
|
|
||||||
NETWORK_DIASPORA
|
|
||||||
);
|
|
||||||
if ($r) {
|
|
||||||
$ret= [];
|
$ret= [];
|
||||||
$ret["root_handle"] = self::handleFromContact($r[0]["contact-id"]);
|
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
|
||||||
$ret["root_guid"] = $guid;
|
$ret["root_guid"] = $guid;
|
||||||
return $ret;
|
return $ret;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue