1
0
Fork 0

Some easy to replace "q" calls have been replaced by "DBA" calls (#5632)

* Some easy to replace "q" calls have been replaced by "DBA" calls

* Simplified the GUID creation

* And one in the API ...

* And OStatus has got some DBA calls more

* Just some more replaced database calls

* The event query is now simplified

* Events are now shown again

* subthread is now using the DBA calls as well

* Some more replaced database calls

* And some more replaced database calls and prevented notices

* Better use gravity

* Some more replaced database stuff

* Some more replaced database calls in DFRN.php

* The gcontact class now has got the new DBA functions as well

* The Contact class is now changed to new database functions as well

* Small correction

* We can now delete without cascade

* One more functionality is safe for future changes
This commit is contained in:
Michael Vogel 2018-08-19 14:46:11 +02:00 committed by Hypolite Petovan
commit 7f3fb34c24
21 changed files with 275 additions and 501 deletions

View file

@ -771,7 +771,7 @@ function networkThreadedView(App $a, $update, $parent)
FROM `item` $sql_post_table
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
AND (`item`.`parent-uri` != `item`.`uri`
AND (`item`.`gravity` != %d
OR `contact`.`uid` = `item`.`uid` AND `contact`.`self`
OR `contact`.`rel` IN (%d, %d) AND NOT `contact`.`readonly`)
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = %d
@ -780,6 +780,7 @@ function networkThreadedView(App $a, $update, $parent)
AND NOT `item`.`moderated` AND $sql_extra4
$sql_extra3 $sql_extra $sql_range $sql_nets
ORDER BY `order_date` DESC LIMIT 100",
intval(GRAVITY_PARENT),
intval(Contact::SHARING),
intval(Contact::FRIEND),
intval(local_user()),
@ -791,7 +792,7 @@ function networkThreadedView(App $a, $update, $parent)
STRAIGHT_JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
STRAIGHT_JOIN `item` ON `item`.`id` = `thread`.`iid`
AND (`item`.`parent-uri` != `item`.`uri`
AND (`item`.`gravity` != %d
OR `contact`.`uid` = `item`.`uid` AND `contact`.`self`
OR `contact`.`rel` IN (%d, %d) AND NOT `contact`.`readonly`)
LEFT JOIN `user-item` ON `user-item`.`iid` = `item`.`id` AND `user-item`.`uid` = %d
@ -800,6 +801,7 @@ function networkThreadedView(App $a, $update, $parent)
AND (`user-item`.`hidden` IS NULL OR NOT `user-item`.`hidden`)
$sql_extra2 $sql_extra3 $sql_range $sql_extra $sql_nets
ORDER BY `order_date` DESC $pager_sql",
intval(GRAVITY_PARENT),
intval(Contact::SHARING),
intval(Contact::FRIEND),
intval(local_user()),

View file

@ -40,15 +40,12 @@ function subthread_content(App $a) {
if (!$item['wall']) {
// The top level post may have been written by somebody on another system
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($item['contact-id']),
intval($item['uid'])
);
if (!DBA::isResult($r)) {
$contact = DBA::selectFirst('contact', [], ['id' => $item['contact-id'], 'uid' => $item['uid']]);
if (!DBA::isResult($contact)) {
return;
}
if (!$r[0]['self']) {
$remote_owner = $r[0];
if (!$contact['self']) {
$remote_owner = $contact;
}
}
@ -79,18 +76,11 @@ function subthread_content(App $a) {
if (local_user() && (local_user() == $owner_uid)) {
$contact = $owner;
} else {
$r = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
intval($_SESSION['visitor_id']),
intval($owner_uid)
);
if (DBA::isResult($r)) {
$contact = $r[0];
$contact = DBA::selectFirst('contact', [], ['id' => $_SESSION['visitor_id'], 'uid' => $owner_uid]);
if (!DBA::isResult($contact)) {
return;
}
}
if (!$contact) {
return;
}
$uri = Item::newURI($owner_uid);