move hidewall to user table - queries are getting too complicated and servers falling over
This commit is contained in:
parent
c221d5ea59
commit
84d12c3e08
2
boot.php
2
boot.php
|
@ -6,7 +6,7 @@ ini_set('pcre.backtrack_limit', 250000);
|
|||
|
||||
define ( 'FRIENDIKA_VERSION', '2.2.1032' );
|
||||
define ( 'DFRN_PROTOCOL_VERSION', '2.21' );
|
||||
define ( 'DB_UPDATE_VERSION', 1074 );
|
||||
define ( 'DB_UPDATE_VERSION', 1075 );
|
||||
|
||||
define ( 'EOL', "<br />\r\n" );
|
||||
define ( 'ATOM_TIME', 'Y-m-d\TH:i:s\Z' );
|
||||
|
|
|
@ -301,7 +301,6 @@ CREATE TABLE IF NOT EXISTS `profile` (
|
|||
`profile-name` char(255) NOT NULL,
|
||||
`is-default` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`hide-friends` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`hidewall` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`name` char(255) NOT NULL,
|
||||
`pdesc` char(255) NOT NULL,
|
||||
`dob` char(32) NOT NULL DEFAULT '0000-00-00',
|
||||
|
@ -399,6 +398,7 @@ CREATE TABLE IF NOT EXISTS `user` (
|
|||
`verified` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`blocked` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`blockwall` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`hidewall` tinyint(1) unsigned NOT NULL DEFAULT '0',
|
||||
`notify-flags` int(11) unsigned NOT NULL DEFAULT '65535',
|
||||
`page-flags` int(11) unsigned NOT NULL DEFAULT '0',
|
||||
`prvnets` tinyint(1) NOT NULL DEFAULT '0',
|
||||
|
|
|
@ -42,11 +42,11 @@ function community_content(&$a, $update = 0) {
|
|||
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `profile` ON `profile`.`uid` = `item`.`uid`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `profile`.`hidewall` = 0
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `profile`.`is-default` = 1 "
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 "
|
||||
);
|
||||
|
||||
if(count($r))
|
||||
|
@ -61,14 +61,13 @@ function community_content(&$a, $update = 0) {
|
|||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
|
||||
`user`.`nickname`, `profile`.`hidewall`
|
||||
`user`.`nickname`, `user`.`hidewall`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
LEFT JOIN `profile` ON `profile`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = ''
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `profile`.`hidewall` = 0
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `profile`.`is-default` = 1
|
||||
AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
ORDER BY `received` DESC LIMIT %d, %d ",
|
||||
intval($a->pager['start']),
|
||||
intval($a->pager['itemspage'])
|
||||
|
|
|
@ -31,7 +31,7 @@ function dfrn_poll_init(&$a) {
|
|||
killme();
|
||||
}
|
||||
|
||||
$r = q("SELECT `hidewall` FROM `profile` LEFT JOIN `user` ON `profile`.`uid` = `user`.`uid` WHERE `user`.`nickname` = '%s' AND `profile`.`is-default` = 1 LIMIT 1",
|
||||
$r = q("SELECT `hidewall` FROM `user` WHERE `user`.`nickname` = '%s' LIMIT 1",
|
||||
dbesc($a->argv[1])
|
||||
);
|
||||
if(count($r) && $r[0]['hidewall'])
|
||||
|
|
|
@ -10,13 +10,13 @@ function msearch_post(&$a) {
|
|||
if(! strlen($search))
|
||||
killme();
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
|
||||
$r = q("SELECT COUNT(*) AS `total` FROM `profile` LEFT JOIN `user` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') ",
|
||||
dbesc($search)
|
||||
);
|
||||
if(count($r))
|
||||
$total = $r[0]['total'];
|
||||
|
||||
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
|
||||
$r = q("SELECT `pub_keywords`, `username`, `nickname`, `user`.`uid` FROM `user` LEFT JOIN `profile` ON `user`.`uid` = `profile`.`uid` WHERE `is-default` = 1 AND `user`.`hidewall` = 0 AND MATCH `pub_keywords` AGAINST ('%s') LIMIT %d , %d ",
|
||||
dbesc($search),
|
||||
intval($startrec),
|
||||
intval($perpage)
|
||||
|
|
|
@ -816,11 +816,7 @@ function photos_content(&$a) {
|
|||
}
|
||||
}
|
||||
|
||||
$r = q("SELECT `hidewall` FROM `profile` WHERE `uid` = %d AND `is-default` = 1 LIMIT 1",
|
||||
intval($owner_uid)
|
||||
);
|
||||
|
||||
if(count($r) && $r[0]['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
|
||||
if($a->data['user']['hidewall'] && (local_user() != $owner_uid) && (! $remote_contact)) {
|
||||
notice( t('Access to this item is restricted.') . EOL);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -48,11 +48,11 @@ function search_content(&$a) {
|
|||
$search_alg = $s_regx;
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `total`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `profile` ON `profile`.`uid` = `item`.`uid`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `profile`.`hidewall` = 0)
|
||||
AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0)
|
||||
OR `item`.`uid` = %d )
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `profile`.`is-default` = 1
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$search_alg ",
|
||||
intval(local_user()),
|
||||
dbesc($search)
|
||||
|
@ -70,14 +70,13 @@ function search_content(&$a) {
|
|||
`contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
|
||||
`contact`.`network`, `contact`.`thumb`, `contact`.`self`, `contact`.`writable`,
|
||||
`contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
|
||||
`user`.`nickname`, `profile`.`hidewall`
|
||||
`user`.`nickname`
|
||||
FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
|
||||
LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
|
||||
LEFT JOIN `profile` ON `profile`.`uid` = `item`.`uid`
|
||||
WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
|
||||
AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `profile`.`hidewall` = 0 )
|
||||
AND (( `wall` = 1 AND `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `user`.`hidewall` = 0 )
|
||||
OR `item`.`uid` = %d )
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `profile`.`is-default` = 1
|
||||
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
|
||||
$search_alg
|
||||
ORDER BY `received` DESC LIMIT %d , %d ",
|
||||
intval(local_user()),
|
||||
|
|
|
@ -230,7 +230,7 @@ function settings_post(&$a) {
|
|||
$openidserver = '';
|
||||
}
|
||||
|
||||
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d WHERE `uid` = %d LIMIT 1",
|
||||
$r = q("UPDATE `user` SET `username` = '%s', `email` = '%s', `openid` = '%s', `timezone` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `notify-flags` = %d, `page-flags` = %d, `default-location` = '%s', `allow_location` = %d, `theme` = '%s', `maxreq` = %d, `expire` = %d, `openidserver` = '%s', `blockwall` = %d, `hidewall` = %d WHERE `uid` = %d LIMIT 1",
|
||||
dbesc($username),
|
||||
dbesc($email),
|
||||
dbesc($openid),
|
||||
|
@ -248,6 +248,7 @@ function settings_post(&$a) {
|
|||
intval($expire),
|
||||
dbesc($openidserver),
|
||||
intval($blockwall),
|
||||
intval($hidewall),
|
||||
intval(local_user())
|
||||
);
|
||||
if($r)
|
||||
|
@ -257,12 +258,10 @@ function settings_post(&$a) {
|
|||
SET `publish` = %d,
|
||||
`net-publish` = %d,
|
||||
`hide-friends` = %d,
|
||||
`hidewall` = %d
|
||||
WHERE `is-default` = 1 AND `uid` = %d LIMIT 1",
|
||||
intval($publish),
|
||||
intval($net_publish),
|
||||
intval($hide_friends),
|
||||
intval($hidewall),
|
||||
intval(local_user())
|
||||
);
|
||||
|
||||
|
@ -436,8 +435,8 @@ function settings_content(&$a) {
|
|||
'$desc' => t('Hide profile details and all your messages from unknown viewers?'),
|
||||
'$yes_str' => t('Yes'),
|
||||
'$no_str' => t('No'),
|
||||
'$yes_selected' => (($profile['hidewall']) ? " checked=\"checked\" " : ""),
|
||||
'$no_selected' => (($profile['hidewall'] == 0) ? " checked=\"checked\" " : "")
|
||||
'$yes_selected' => (($a->user['hidewall']) ? " checked=\"checked\" " : ""),
|
||||
'$no_selected' => (($a->user['hidewall'] == 0) ? " checked=\"checked\" " : "")
|
||||
));
|
||||
|
||||
|
||||
|
|
13
update.php
13
update.php
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
define( 'UPDATE_VERSION' , 1074 );
|
||||
define( 'UPDATE_VERSION' , 1075 );
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -590,3 +590,14 @@ function update_1073() {
|
|||
q("ALTER TABLE `contact` ADD `remote_self` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `self` ");
|
||||
}
|
||||
|
||||
function update_1074() {
|
||||
q("ALTER TABLE `user` ADD `hidewall` TINYINT( 1) NOT NULL DEFAULT '0' AFTER `blockwall` ");
|
||||
$r = q("SELECT `uid` FROM `profile` WHERE `is-default` = 1 AND `hidewall` = 1");
|
||||
if(count($r)) {
|
||||
foreach($r as $rr)
|
||||
q("UPDATE `user` SET `hidewall` = 1 WHERE `uid` = %d LIMIT 1",
|
||||
intval($rr['uid'])
|
||||
);
|
||||
}
|
||||
q("ALTER TABLE `profile` DROP `hidewall`");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue