From 64181abc6f46085a3772166cfdaa427fce4722ed Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:34:53 -0800 Subject: fix implicit boolean --- mod/sitelist.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mod/sitelist.php b/mod/sitelist.php index 95a53c9a4..12911cbd4 100644 --- a/mod/sitelist.php +++ b/mod/sitelist.php @@ -28,7 +28,7 @@ function sitelist_init(&$a) { $result = array('success' => false); - $r = q("select count(site_url) as total from site where 1 $sql_extra "); + $r = q("select count(site_url) as total from site where true $sql_extra "); if($r) $result['total'] = intval($r[0]['total']); -- cgit v1.2.3 From 435509f6092e55c7f1d96be23519f67c4db511ad Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:36:24 -0800 Subject: fix improper group by usage --- include/chat.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/chat.php b/include/chat.php index 533c03dde..b19d495bb 100644 --- a/include/chat.php +++ b/include/chat.php @@ -185,7 +185,7 @@ function chatroom_list($uid) { require_once('include/security.php'); $sql_extra = permissions_sql($uid); - $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name order by cr_name", + $r = q("select cr_name, cr_id, count(cp_id) as cr_inroom from chatroom left join chatpresence on cr_id = cp_room where cr_uid = %d $sql_extra group by cr_name, cr_id order by cr_name", intval($uid) ); -- cgit v1.2.3 From 1a537888333afb052e9eb4954091fd163f5b78d1 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:37:34 -0800 Subject: bookmarkedchats: remove extraneous group by, dupes removed on insert suggestedchats: normalize to standard SQL --- include/widgets.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/widgets.php b/include/widgets.php index 9f9268055..3533e2cea 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -642,7 +642,7 @@ function widget_bookmarkedchats($arr) { $h = get_observer_hash(); if(! $h) return; - $r = q("select * from xchat where xchat_xchan = '%s' group by xchat_url order by xchat_desc", + $r = q("select xchat_url, xchat_desc from xchat where xchat_xchan = '%s' order by xchat_desc", dbesc($h) ); if($r) { @@ -664,7 +664,7 @@ function widget_suggestedchats($arr) { $h = get_observer_hash(); if(! $h) return; - $r = q("select *, count(xchat_url) as total from xchat group by xchat_url order by total desc, xchat_desc limit 24"); + $r = q("select xchat_url, xchat_desc, count(xchat_xchan) as total from xchat group by xchat_url, xchat_desc order by total desc, xchat_desc limit 24"); if($r) { for($x = 0; $x < count($r); $x ++) { $r[$x]['xchat_url'] = zid($r[$x]['xchat_url']); -- cgit v1.2.3 From 2039710962db42e0b85a1ab452f923b921bce1b4 Mon Sep 17 00:00:00 2001 From: Habeas Codice Date: Wed, 28 Jan 2015 17:47:31 -0800 Subject: postgres does not support the , syntax. a ; would work, if it weren't statement-locked. FWIW, the exact same queries listed for postgres are perfectly valid and equivalent on mysql. no need for separate statements. --- install/update.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/install/update.php b/install/update.php index 346b2c25a..597da4e3b 100644 --- a/install/update.php +++ b/install/update.php @@ -1540,7 +1540,9 @@ function update_r1133() { function update_r1134() { if(ACTIVE_DBTYPE == DBTYPE_POSTGRES) { - $r = q("ALTER TABLE xlink ADD xlink_static numeric(1) NOT NULL DEFAULT '0', create index xlink_static on xlink ( \"xlink_static\" ) "); + $r1 = q("ALTER TABLE xlink ADD xlink_static numeric(1) NOT NULL DEFAULT '0' "); + $r2 = q("create index xlink_static on xlink ( xlink_static ) "); + $r = $r1 && $r2; } else $r = q("ALTER TABLE xlink ADD xlink_static TINYINT( 1 ) NOT NULL DEFAULT '0', ADD INDEX ( xlink_static ) "); -- cgit v1.2.3