Merge pull request #3096 from annando/1701-index-again

Some more index stuff
This commit is contained in:
Tobias Diekershoff 2017-01-27 16:52:12 +01:00 committed by GitHub
commit 722b18ead7
54 changed files with 651 additions and 351 deletions

View file

@ -6,6 +6,7 @@
* @brief Friendica admin
*/
use \Friendica\Core\Config;
require_once("include/enotify.php");
require_once("include/text.php");
@ -948,6 +949,16 @@ function admin_page_site(App $a) {
$diaspora_able = ($a->get_path() == "");
$optimize_max_tablesize = Config::get('system','optimize_max_tablesize', 100);
if ($optimize_max_tablesize < -1) {
$optimize_max_tablesize = -1;
}
if ($optimize_max_tablesize == 0) {
$optimize_max_tablesize = 100;
}
$t = get_markup_template("admin_site.tpl");
return replace_macros($t, array(
'$title' => t('Administration'),
@ -1019,7 +1030,7 @@ function admin_page_site(App $a) {
'$poll_interval' => array('poll_interval', t("Poll interval"), (x(get_config('system','poll_interval'))?get_config('system','poll_interval'):2), t("Delay background polling processes by this many seconds to reduce system load. If 0, use delivery interval.")),
'$maxloadavg' => array('maxloadavg', t("Maximum Load Average"), ((intval(get_config('system','maxloadavg')) > 0)?get_config('system','maxloadavg'):50), t("Maximum system load before delivery and poll processes are deferred - default 50.")),
'$maxloadavg_frontend' => array('maxloadavg_frontend', t("Maximum Load Average (Frontend)"), ((intval(get_config('system','maxloadavg_frontend')) > 0)?get_config('system','maxloadavg_frontend'):50), t("Maximum system load before the frontend quits service - default 50.")),
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), ((intval(get_config('system','optimize_max_tablesize')) > 0)?get_config('system','optimize_max_tablesize'):100), t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
'$optimize_max_tablesize'=> array('optimize_max_tablesize', t("Maximum table size for optimization"), $optimize_max_tablesize, t("Maximum table size (in MB) for the automatic optimization - default 100 MB. Enter -1 to disable it.")),
'$optimize_fragmentation'=> array('optimize_fragmentation', t("Minimum level of fragmentation"), ((intval(get_config('system','optimize_fragmentation')) > 0)?get_config('system','optimize_fragmentation'):30), t("Minimum fragmenation level to start the automatic optimization - default value is 30%.")),
'$poco_completion' => array('poco_completion', t("Periodical check of global contacts"), get_config('system','poco_completion'), t("If enabled, the global contacts are checked periodically for missing or outdated data and the vitality of the contacts and servers.")),

View file

@ -224,9 +224,7 @@ function dfrn_confirm_post(App $a, $handsfree = null) {
*
*/
$a->config['system']['curl_timeout'] = 120;
$res = post_url($dfrn_confirm,$params);
$res = post_url($dfrn_confirm, $params, null, $redirects, 120);
logger(' Confirm: received data: ' . $res, LOGGER_DATA);

View file

@ -42,7 +42,7 @@ function fetch_init(App $a) {
// Fetch some data from the author (We could combine both queries - but I think this is more readable)
$r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE `user`.`uid` = %d", intval($item[0]["uid"]));
if (!$r) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));

View file

@ -1,5 +1,7 @@
<?php
use \Friendica\Core\Config;
function friendica_init(App $a) {
if ($a->argv[1]=="json"){
$register_policy = Array('REGISTER_CLOSED', 'REGISTER_APPROVE', 'REGISTER_OPEN');
@ -29,7 +31,7 @@ function friendica_init(App $a) {
$visible_plugins[] = $rr['name'];
}
load_config('feature_lock');
Config::load('feature_lock');
$locked_features = array();
if(is_array($a->config['feature_lock']) && count($a->config['feature_lock'])) {
foreach($a->config['feature_lock'] as $k => $v) {

View file

@ -762,24 +762,23 @@ function network_content(App $a, $update = 0) {
// on they just get buried deeper. It has happened to me a couple of times also.
if((! $group) && (! $cid) && (! $star)) {
if (!$group && !$cid && !$star) {
$unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d",
$unseen = q("SELECT `id` FROM `item` WHERE `unseen` AND `uid` = %d LIMIT 1",
intval(local_user()));
if ($unseen)
if (dbm::is_result($unseen)) {
$r = q("UPDATE `item` SET `unseen` = 0
WHERE `unseen` = 1 AND `uid` = %d",
intval(local_user())
);
}
else {
if($update_unseen) {
}
} elseif ($update_unseen) {
$unseen = q("SELECT `id` FROM `item` ".$update_unseen);
$unseen = q("SELECT `id` FROM `item` ".$update_unseen. " LIMIT 1");
if ($unseen)
$r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
if (dbm::is_result($unseen)) {
$r = q("UPDATE `item` SET `unseen` = 0 $update_unseen");
}
}
@ -790,10 +789,10 @@ function network_content(App $a, $update = 0) {
$o .= conversation($a,$items,$mode,$update);
if(!$update) {
if(get_pconfig(local_user(),'system','infinite_scroll')) {
if (!$update) {
if (get_pconfig(local_user(),'system','infinite_scroll')) {
$o .= scroll_loader();
} elseif(!get_config('system', 'old_pager')) {
} elseif (!get_config('system', 'old_pager')) {
$o .= alt_pager($a,count($items));
} else {
$o .= paginate($a);

View file

@ -46,7 +46,7 @@ function p_init($a){
// Fetch some data from the author (We could combine both queries - but I think this is more readable)
$r = q("SELECT `user`.`prvkey`, `contact`.`addr`, `user`.`nickname`, `contact`.`nick` FROM `user`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid`
INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
WHERE `user`.`uid` = %d", intval($item[0]["uid"]));
if (!dbm::is_result($r)) {
header($_SERVER["SERVER_PROTOCOL"].' 404 '.t('Not Found'));

View file

@ -10,6 +10,8 @@ require_once('include/tags.php');
require_once('include/threads.php');
require_once('include/Probe.php');
use \Friendica\Core\Config;
function photos_init(App $a) {
if ($a->argc > 1)
@ -1339,35 +1341,38 @@ function photos_content(App $a) {
$prevlink = '';
$nextlink = '';
if ($_GET['order'] === 'posted')
$order = 'ASC';
else
$order = 'DESC';
/// @todo This query is totally bad, the whole functionality has to be changed
// The query leads to a really intense used index.
// By now we hide it if someone wants to.
if (!Config::get('system', 'no_count', false)) {
if ($_GET['order'] === 'posted')
$order = 'ASC';
else
$order = 'DESC';
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
$sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']),
intval($owner_uid)
);
$prvnxt = qu("SELECT `resource-id` FROM `photo` WHERE `album` = '%s' AND `uid` = %d AND `scale` = 0
$sql_extra ORDER BY `created` $order ",
dbesc($ph[0]['album']),
intval($owner_uid)
);
if (count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
$nxt = $z + 1;
if ($prv < 0)
$prv = count($prvnxt) - 1;
if ($nxt >= count($prvnxt))
$nxt = 0;
break;
if (count($prvnxt)) {
for($z = 0; $z < count($prvnxt); $z++) {
if ($prvnxt[$z]['resource-id'] == $ph[0]['resource-id']) {
$prv = $z - 1;
$nxt = $z + 1;
if ($prv < 0)
$prv = count($prvnxt) - 1;
if ($nxt >= count($prvnxt))
$nxt = 0;
break;
}
}
}
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
$edit_suffix = ((($cmd === 'edit') && ($can_post)) ? '/edit' : '');
$prevlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$prv]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
$nextlink = 'photos/' . $a->data['user']['nickname'] . '/image/' . $prvnxt[$nxt]['resource-id'] . $edit_suffix . (($_GET['order'] === 'posted') ? '?f=&order=posted' : '');
}
}
if (count($ph) == 1)
$hires = $lores = $ph[0];

View file

@ -5,6 +5,7 @@ require_once('include/ForumManager.php');
require_once('include/group.php');
require_once('mod/proxy.php');
require_once('include/xml.php');
require_once('include/cache.php');
/**
* @brief Outputs the counts and the lists of various notifications
@ -195,13 +196,20 @@ function ping_init(App $a)
}
}
$ev = qu("SELECT count(`event`.`id`) AS total, type, start, adjust FROM `event`
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
ORDER BY `start` ASC ",
intval(local_user()),
dbesc(datetime_convert('UTC', 'UTC', 'now + 7 days')),
dbesc(datetime_convert('UTC', 'UTC', 'now'))
);
$cachekey = "ping_init:".local_user();
$ev = Cache::get($cachekey);
if (is_null($ev)) {
$ev = qu("SELECT count(`event`.`id`) AS total, type, start, adjust FROM `event`
WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0
ORDER BY `start` ASC ",
intval(local_user()),
dbesc(datetime_convert('UTC', 'UTC', 'now + 7 days')),
dbesc(datetime_convert('UTC', 'UTC', 'now'))
);
if (dbm::is_result($ev)) {
Cache::set($cachekey, $ev, CACHE_HOUR);
}
}
if (dbm::is_result($ev)) {
$all_events = intval($ev[0]['total']);