Several performance improvements.
This commit is contained in:
parent
5eeccd519a
commit
53c06a3625
2
boot.php
2
boot.php
|
@ -14,7 +14,7 @@ require_once('include/features.php');
|
||||||
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
define ( 'FRIENDICA_PLATFORM', 'Friendica');
|
||||||
define ( 'FRIENDICA_VERSION', '3.2.1744' );
|
define ( 'FRIENDICA_VERSION', '3.2.1744' );
|
||||||
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
|
||||||
define ( 'DB_UPDATE_VERSION', 1164 );
|
define ( 'DB_UPDATE_VERSION', 1165 );
|
||||||
define ( 'EOL', "<br />\r\n" );
|
define ( 'EOL', "<br />\r\n" );
|
||||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||||
|
|
||||||
|
|
|
@ -67,7 +67,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
|
|
||||||
// It's ours to deliver. Remove it from the queue.
|
// It's ours to deliver. Remove it from the queue.
|
||||||
|
|
||||||
q("delete from deliverq where cmd = '%s' and item = %d and contact = %d limit 1",
|
q("delete from deliverq where cmd = '%s' and item = %d and contact = %d",
|
||||||
dbesc($cmd),
|
dbesc($cmd),
|
||||||
dbesc($item_id),
|
dbesc($item_id),
|
||||||
dbesc($contact_id)
|
dbesc($contact_id)
|
||||||
|
@ -331,7 +331,7 @@ function delivery_run(&$argv, &$argc){
|
||||||
if($x && count($x)) {
|
if($x && count($x)) {
|
||||||
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
|
$write_flag = ((($x[0]['rel']) && ($x[0]['rel'] != CONTACT_IS_SHARING)) ? true : false);
|
||||||
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
|
if((($owner['page-flags'] == PAGE_COMMUNITY) || ($write_flag)) && (! $x[0]['writable'])) {
|
||||||
q("update contact set writable = 1 where id = %d limit 1",
|
q("update contact set writable = 1 where id = %d",
|
||||||
intval($x[0]['id'])
|
intval($x[0]['id'])
|
||||||
);
|
);
|
||||||
$x[0]['writable'] = 1;
|
$x[0]['writable'] = 1;
|
||||||
|
|
|
@ -983,7 +983,23 @@ function item_store($arr,$force_parent = false) {
|
||||||
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
|
$arr['app'] = ((x($arr,'app')) ? notags(trim($arr['app'])) : '');
|
||||||
$arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 );
|
$arr['origin'] = ((x($arr,'origin')) ? intval($arr['origin']) : 0 );
|
||||||
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid());
|
$arr['guid'] = ((x($arr,'guid')) ? notags(trim($arr['guid'])) : get_guid());
|
||||||
|
$arr['network'] = ((x($arr,'network')) ? trim($arr['network']) : '');
|
||||||
|
|
||||||
|
if ($arr['network'] == "") {
|
||||||
|
$r = q("SELECT `network` FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1",
|
||||||
|
intval($arr['contact-id']),
|
||||||
|
intval($arr['uid'])
|
||||||
|
);
|
||||||
|
|
||||||
|
if(count($r))
|
||||||
|
$arr['network'] = $r[0]["network"];
|
||||||
|
|
||||||
|
// Fallback to friendica (why is it empty in some cases?)
|
||||||
|
if ($arr['network'] == "")
|
||||||
|
$arr['network'] = NETWORK_DFRN;
|
||||||
|
|
||||||
|
logger("item_store: Set network to ".$arr["network"]." for ".$arr["uri"], LOGGER_DEBUG);
|
||||||
|
}
|
||||||
|
|
||||||
$arr['thr-parent'] = $arr['parent-uri'];
|
$arr['thr-parent'] = $arr['parent-uri'];
|
||||||
if($arr['parent-uri'] === $arr['uri']) {
|
if($arr['parent-uri'] === $arr['uri']) {
|
||||||
|
@ -4082,6 +4098,9 @@ function drop_item($id,$interactive = true) {
|
||||||
|
|
||||||
// clean up item_id and sign meta-data tables
|
// clean up item_id and sign meta-data tables
|
||||||
|
|
||||||
|
/*
|
||||||
|
// Old code - caused very long queries and warning entries in the mysql logfiles:
|
||||||
|
|
||||||
$r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)",
|
$r = q("DELETE FROM item_id where iid in (select id from item where parent = %d and uid = %d)",
|
||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
intval($item['uid'])
|
intval($item['uid'])
|
||||||
|
@ -4091,6 +4110,31 @@ function drop_item($id,$interactive = true) {
|
||||||
intval($item['id']),
|
intval($item['id']),
|
||||||
intval($item['uid'])
|
intval($item['uid'])
|
||||||
);
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// The new code splits the queries since the mysql optimizer really has bad problems with subqueries
|
||||||
|
|
||||||
|
// Creating list of parents
|
||||||
|
$r = q("select id from item where parent = %d and uid = %d",
|
||||||
|
intval($item['id']),
|
||||||
|
intval($item['uid'])
|
||||||
|
);
|
||||||
|
|
||||||
|
$parentid = "";
|
||||||
|
|
||||||
|
foreach ($r AS $row) {
|
||||||
|
if ($parentid != "")
|
||||||
|
$parentid .= ", ";
|
||||||
|
|
||||||
|
$parentid .= $row["id"];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now delete them
|
||||||
|
if ($parentid != "") {
|
||||||
|
$r = q("DELETE FROM item_id where iid in (%s)", dbesc($parentid));
|
||||||
|
|
||||||
|
$r = q("DELETE FROM sign where iid in (%s)", dbesc($parentid));
|
||||||
|
}
|
||||||
|
|
||||||
// If it's the parent of a comment thread, kill all the kids
|
// If it's the parent of a comment thread, kill all the kids
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ function ref_session_write ($id,$data) {
|
||||||
if($session_exists)
|
if($session_exists)
|
||||||
$r = q("UPDATE `session`
|
$r = q("UPDATE `session`
|
||||||
SET `data` = '%s', `expire` = '%s'
|
SET `data` = '%s', `expire` = '%s'
|
||||||
WHERE `sid` = '%s' LIMIT 1",
|
WHERE `sid` = '%s'",
|
||||||
dbesc($data), dbesc($expire), dbesc($id));
|
dbesc($data), dbesc($expire), dbesc($id));
|
||||||
else
|
else
|
||||||
$r = q("INSERT INTO `session`
|
$r = q("INSERT INTO `session`
|
||||||
|
|
|
@ -103,7 +103,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
||||||
|
|
||||||
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
|
if($x[0]['name'] != $name || $x[0]['photo'] != $profile_photo) {
|
||||||
q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
|
q("update gcontact set `name` = '%s', `photo` = '%s', `connect` = '%s', `url` = '%s'
|
||||||
where `nurl` = '%s' limit 1",
|
where `nurl` = '%s'",
|
||||||
dbesc($name),
|
dbesc($name),
|
||||||
dbesc($profile_photo),
|
dbesc($profile_photo),
|
||||||
dbesc($connect_url),
|
dbesc($connect_url),
|
||||||
|
@ -146,7 +146,7 @@ function poco_load($cid,$uid = 0,$zcid = 0,$url = null) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d limit 1",
|
q("update glink set updated = '%s' where `cid` = %d and `uid` = %d and `gcid` = %d and zcid = %d",
|
||||||
dbesc(datetime_convert()),
|
dbesc(datetime_convert()),
|
||||||
intval($cid),
|
intval($cid),
|
||||||
intval($uid),
|
intval($uid),
|
||||||
|
|
|
@ -40,7 +40,7 @@ function dfrn_notify_post(&$a) {
|
||||||
xml_status(3);
|
xml_status(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
|
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
|
||||||
dbesc($dfrn_id),
|
dbesc($dfrn_id),
|
||||||
dbesc($challenge)
|
dbesc($challenge)
|
||||||
);
|
);
|
||||||
|
@ -92,7 +92,7 @@ function dfrn_notify_post(&$a) {
|
||||||
$importer = $r[0];
|
$importer = $r[0];
|
||||||
|
|
||||||
if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
|
if((($writable != (-1)) && ($writable != $importer['writable'])) || ($importer['forum'] != $forum) || ($importer['prv'] != $prv)) {
|
||||||
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d LIMIT 1",
|
q("UPDATE `contact` SET `writable` = %d, forum = %d, prv = %d WHERE `id` = %d",
|
||||||
intval(($writable == (-1)) ? $importer['writable'] : $writable),
|
intval(($writable == (-1)) ? $importer['writable'] : $writable),
|
||||||
intval($forum),
|
intval($forum),
|
||||||
intval($prv),
|
intval($prv),
|
||||||
|
|
|
@ -104,7 +104,7 @@ function dfrn_poll_init(&$a) {
|
||||||
// Visitors get 1 day session.
|
// Visitors get 1 day session.
|
||||||
$session_id = session_id();
|
$session_id = session_id();
|
||||||
$expire = time() + 86400;
|
$expire = time() + 86400;
|
||||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1",
|
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
|
||||||
dbesc($expire),
|
dbesc($expire),
|
||||||
dbesc($session_id)
|
dbesc($session_id)
|
||||||
);
|
);
|
||||||
|
@ -289,7 +289,7 @@ function dfrn_poll_post(&$a) {
|
||||||
$type = $r[0]['type'];
|
$type = $r[0]['type'];
|
||||||
$last_update = $r[0]['last_update'];
|
$last_update = $r[0]['last_update'];
|
||||||
|
|
||||||
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1",
|
$r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s'",
|
||||||
dbesc($dfrn_id),
|
dbesc($dfrn_id),
|
||||||
dbesc($challenge)
|
dbesc($challenge)
|
||||||
);
|
);
|
||||||
|
@ -365,7 +365,7 @@ function dfrn_poll_post(&$a) {
|
||||||
$writable = 0;
|
$writable = 0;
|
||||||
|
|
||||||
if($writable != $contact['writable']) {
|
if($writable != $contact['writable']) {
|
||||||
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d LIMIT 1",
|
q("UPDATE `contact` SET `writable` = %d WHERE `id` = %d",
|
||||||
intval($writable),
|
intval($writable),
|
||||||
intval($contact_id)
|
intval($contact_id)
|
||||||
);
|
);
|
||||||
|
@ -537,7 +537,7 @@ function dfrn_poll_content(&$a) {
|
||||||
// Visitors get 1 day session.
|
// Visitors get 1 day session.
|
||||||
$session_id = session_id();
|
$session_id = session_id();
|
||||||
$expire = time() + 86400;
|
$expire = time() + 86400;
|
||||||
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s' LIMIT 1",
|
q("UPDATE `session` SET `expire` = '%s' WHERE `sid` = '%s'",
|
||||||
dbesc($expire),
|
dbesc($expire),
|
||||||
dbesc($session_id)
|
dbesc($session_id)
|
||||||
);
|
);
|
||||||
|
|
|
@ -572,7 +572,8 @@ function network_content(&$a, $update = 0) {
|
||||||
$sql_options = (($star) ? " and starred = 1 " : '');
|
$sql_options = (($star) ? " and starred = 1 " : '');
|
||||||
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
$sql_options .= (($bmark) ? " and bookmark = 1 " : '');
|
||||||
|
|
||||||
$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '');
|
//$sql_nets = (($nets) ? sprintf(" and `contact`.`network` = '%s' ", dbesc($nets)) : '');
|
||||||
|
$sql_nets = (($nets) ? sprintf(" and `item`.`network` = '%s' ", dbesc($nets)) : '');
|
||||||
|
|
||||||
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
|
$sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $sql_options ) ";
|
||||||
|
|
||||||
|
@ -608,7 +609,9 @@ function network_content(&$a, $update = 0) {
|
||||||
intval($cid)
|
intval($cid)
|
||||||
);
|
);
|
||||||
if(count($r)) {
|
if(count($r)) {
|
||||||
$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
|
$sql_table = "`item` INNER JOIN (SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = ".intval($cid)." and deleted = 0 ORDER BY `item`.`received` DESC) AS `temp1` ON item.parent = `temp1`.parent ";
|
||||||
|
$sql_extra = "";
|
||||||
|
//$sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $sql_options AND `contact-id` = " . intval($cid) . " and deleted = 0 ) ";
|
||||||
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
|
$o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o;
|
||||||
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
|
if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) {
|
||||||
notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
|
notice( t('Private messages to this person are at risk of public disclosure.') . EOL);
|
||||||
|
@ -639,6 +642,8 @@ function network_content(&$a, $update = 0) {
|
||||||
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
$sql_extra2 = (($nouveau) ? '' : " AND `item`.`parent` = `item`.`id` ");
|
||||||
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
$sql_extra3 = (($nouveau) ? '' : $sql_extra3);
|
||||||
$sql_order = "`item`.`received`";
|
$sql_order = "`item`.`received`";
|
||||||
|
|
||||||
|
if ($sql_table == "")
|
||||||
$sql_table = "`item`";
|
$sql_table = "`item`";
|
||||||
|
|
||||||
if(x($_GET,'search')) {
|
if(x($_GET,'search')) {
|
||||||
|
@ -890,3 +895,4 @@ function network_content(&$a, $update = 0) {
|
||||||
|
|
||||||
return $o;
|
return $o;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
56
update.php
56
update.php
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
define( 'UPDATE_VERSION' , 1164 );
|
define( 'UPDATE_VERSION' , 1165 );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1440,6 +1440,8 @@ function update_1161() {
|
||||||
function update_1162() {
|
function update_1162() {
|
||||||
require_once('include/tags.php');
|
require_once('include/tags.php');
|
||||||
update_items();
|
update_items();
|
||||||
|
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_1163() {
|
function update_1163() {
|
||||||
|
@ -1455,3 +1457,55 @@ function update_1163() {
|
||||||
|
|
||||||
return UPDATE_SUCCESS;
|
return UPDATE_SUCCESS;
|
||||||
}
|
}
|
||||||
|
function update_1164() {
|
||||||
|
set_config('system', 'maintenance', 1);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_DFRN);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_DFRN, NETWORK_DFRN);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_ZOT, NETWORK_ZOT);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_OSTATUS, NETWORK_OSTATUS);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_FEED, NETWORK_FEED);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_DIASPORA, NETWORK_DIASPORA);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_MAIL, NETWORK_MAIL);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_MAIL2, NETWORK_MAIL2);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_FACEBOOK, NETWORK_FACEBOOK);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_LINKEDIN, NETWORK_LINKEDIN);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_XMPP, NETWORK_XMPP);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_MYSPACE, NETWORK_MYSPACE);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_GPLUS, NETWORK_GPLUS);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_PUMPIO, NETWORK_PUMPIO);
|
||||||
|
|
||||||
|
$r = q("UPDATE `item` SET `network`='%s' WHERE `contact-id` IN (SELECT `id` FROM`contact` WHERE `network` = '%s' AND `contact`.`uid` = `item`.`uid`)",
|
||||||
|
NETWORK_TWITTER, NETWORK_TWITTER);
|
||||||
|
|
||||||
|
set_config('system', 'maintenance', 0);
|
||||||
|
|
||||||
|
return UPDATE_SUCCESS;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user