Some code adjustements and performance improvements to the DFRN feed.
This commit is contained in:
parent
501c45def5
commit
a8bef370d3
4 changed files with 43 additions and 47 deletions
|
@ -138,24 +138,20 @@ class Config {
|
|||
dbesc($key)
|
||||
);
|
||||
|
||||
// It would be better to use the dbm class.
|
||||
// But there is an autoloader issue that I don't know how to fix:
|
||||
// "Class 'Friendica\Core\dbm' not found"
|
||||
//if (!dbm::is_result($ret))
|
||||
if (!$ret)
|
||||
if (!$ret) {
|
||||
$ret = q("INSERT INTO `config` (`cat`, `k`, `v`) VALUES ('%s', '%s', '%s') ON DUPLICATE KEY UPDATE `v` = '%s'",
|
||||
dbesc($family),
|
||||
dbesc($key),
|
||||
dbesc($dbvalue),
|
||||
dbesc($dbvalue)
|
||||
);
|
||||
elseif ($ret[0]['v'] != $dbvalue)
|
||||
} elseif ($ret[0]['v'] != $dbvalue) {
|
||||
$ret = q("UPDATE `config` SET `v` = '%s' WHERE `cat` = '%s' AND `k` = '%s'",
|
||||
dbesc($dbvalue),
|
||||
dbesc($family),
|
||||
dbesc($key)
|
||||
);
|
||||
|
||||
}
|
||||
if ($ret)
|
||||
return $value;
|
||||
|
||||
|
|
|
@ -94,8 +94,7 @@ class PConfig {
|
|||
$a->config[$uid][$family][$key] = $val;
|
||||
|
||||
return $val;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$a->config[$uid][$family][$key] = '!<unset>!';
|
||||
}
|
||||
return $default_value;
|
||||
|
@ -156,6 +155,7 @@ class PConfig {
|
|||
|
||||
if ($ret)
|
||||
return $value;
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,8 @@
|
|||
<?php
|
||||
/**
|
||||
* @file include/dbclean.php
|
||||
* @brief The script is called from time to time to clean the database entries and remove orphaned data.
|
||||
*/
|
||||
require_once("boot.php");
|
||||
|
||||
global $a, $db;
|
||||
|
@ -19,6 +23,9 @@ load_config('system');
|
|||
remove_orphans();
|
||||
killme();
|
||||
|
||||
/**
|
||||
* @brief Remove orphaned database entries
|
||||
*/
|
||||
function remove_orphans() {
|
||||
global $db;
|
||||
|
||||
|
|
|
@ -112,7 +112,6 @@ class dfrn {
|
|||
$owner_nick = $owner['nickname'];
|
||||
|
||||
$sql_post_table = "";
|
||||
$visibility = "";
|
||||
|
||||
if(! $public_feed) {
|
||||
|
||||
|
@ -171,9 +170,6 @@ class dfrn {
|
|||
else
|
||||
$sort = 'ASC';
|
||||
|
||||
$date_field = "`changed`";
|
||||
$sql_order = "`item`.`parent` ".$sort.", `item`.`created` ASC";
|
||||
|
||||
if(! strlen($last_update))
|
||||
$last_update = 'now -30 days';
|
||||
|
||||
|
@ -190,22 +186,19 @@ class dfrn {
|
|||
|
||||
$check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s');
|
||||
|
||||
// AND ( `item`.`edited` > '%s' OR `item`.`changed` > '%s' )
|
||||
// dbesc($check_date),
|
||||
|
||||
$r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
|
||||
`contact`.`name`, `contact`.`network`, `contact`.`photo`, `contact`.`url`,
|
||||
`contact`.`name-date`, `contact`.`uri-date`, `contact`.`avatar-date`,
|
||||
`contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`,
|
||||
`sign`.`signed_text`, `sign`.`signature`, `sign`.`signer`
|
||||
FROM `item` $sql_post_table
|
||||
FROM `item` USE INDEX (`uid_wall_changed`, `uid_type_changed`) $sql_post_table
|
||||
STRAIGHT_JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
AND NOT `contact`.`blocked`
|
||||
LEFT JOIN `sign` ON `sign`.`iid` = `item`.`id`
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` = 1 and `item`.`moderated` = 0 AND `item`.`parent` != 0
|
||||
AND ((`item`.`wall` = 1) $visibility) AND `item`.$date_field > '%s'
|
||||
WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`moderated` AND `item`.`parent` != 0
|
||||
AND `item`.`wall` AND `item`.`changed` > '%s'
|
||||
$sql_extra
|
||||
ORDER BY $sql_order LIMIT 0, 300",
|
||||
ORDER BY `item`.`parent` ".$sort.", `item`.`created` ASC LIMIT 0, 300",
|
||||
intval($owner_id),
|
||||
dbesc($check_date),
|
||||
dbesc($sort)
|
||||
|
|
Loading…
Reference in a new issue