From 896dbfaf675c4a91f2bc5a22fe2eac6f6461ec0f Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 12 Mar 2009 14:59:36 +1300 Subject: [PATCH 1/4] fixed quoting of the table named "user" --- lib/featureduserssection.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/featureduserssection.php b/lib/featureduserssection.php index aed94b1a55..4b9238d471 100644 --- a/lib/featureduserssection.php +++ b/lib/featureduserssection.php @@ -57,9 +57,14 @@ class FeaturedUsersSection extends ProfileSection $quoted[] = "'$nick'"; } + $table = "user"; + if(common_config('db','quote_identifiers')) { + $table = '"' . $table . '"'; + } + $qry = 'SELECT profile.* ' . - 'FROM profile JOIN user on profile.id = user.id ' . - 'WHERE user.nickname in (' . implode(',', $quoted) . ') ' . + 'FROM profile JOIN '. $table .' on profile.id = '. $table .'.id ' . + 'WHERE '. $table .'.nickname in (' . implode(',', $quoted) . ') ' . 'ORDER BY profile.created DESC '; $limit = PROFILES_PER_SECTION + 1; From ea5e7ed2ff0873655a8399c5001686bea8a4adf7 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Thu, 12 Mar 2009 15:20:50 +1300 Subject: [PATCH 2/4] When deleting a notice, null the reply_to fields that point to notice --- classes/Notice.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/classes/Notice.php b/classes/Notice.php index 3087e39a78..6573c337c5 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -67,6 +67,8 @@ class Notice extends Memcached_DataObject $this->blowSubsCache(true); $this->query('BEGIN'); + //Null any notices that are replies to this notice + $this->query(sprintf("UPDATE notice set reply_to = null WHERE reply_to = %d", $this->id)); $related = array('Reply', 'Fave', 'Notice_tag', From c2e529c72b17b61f2203466b2bfd73f07b8371f0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 17 Mar 2009 10:25:47 +1300 Subject: [PATCH 3/4] quoted the users table --- actions/featured.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/actions/featured.php b/actions/featured.php index f3bade6a5e..14d653cea2 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -107,6 +107,7 @@ class FeaturedAction extends Action $featured_nicks = common_config('nickname', 'featured'); + if (count($featured_nicks) > 0) { $quoted = array(); @@ -115,10 +116,15 @@ class FeaturedAction extends Action $quoted[] = "'$nick'"; } + $table = "user"; + if(common_config('db','quote_identifiers')) { + $table = '"' . $table . '"'; + } + $user = new User; $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted))); $user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1); - $user->orderBy('user.nickname ASC'); + $user->orderBy($table .'.nickname ASC'); $user->find(); @@ -145,4 +151,4 @@ class FeaturedAction extends Action $this->page, 'featured'); } } -} \ No newline at end of file +} From 18c8a55ba61e507f08162149273a9a33b9b73ca0 Mon Sep 17 00:00:00 2001 From: Brenda Wallace Date: Tue, 17 Mar 2009 10:36:12 +1300 Subject: [PATCH 4/4] use common_database_tablename instead of repeating that if structure everywhere --- actions/featured.php | 7 +------ lib/util.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/actions/featured.php b/actions/featured.php index 14d653cea2..86fd3f374a 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -116,15 +116,10 @@ class FeaturedAction extends Action $quoted[] = "'$nick'"; } - $table = "user"; - if(common_config('db','quote_identifiers')) { - $table = '"' . $table . '"'; - } - $user = new User; $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted))); $user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1); - $user->orderBy($table .'.nickname ASC'); + $user->orderBy(common_database_tablename('user') .'.nickname ASC'); $user->find(); diff --git a/lib/util.php b/lib/util.php index 6341438cae..19637d5465 100644 --- a/lib/util.php +++ b/lib/util.php @@ -1300,3 +1300,16 @@ function common_compatible_license($from, $to) // XXX: better compatibility check needed here! return ($from == $to); } + +/** + * returns a quoted table name, if required according to config + */ +function common_database_tablename($tablename) +{ + + if(common_config('db','quote_identifiers')) { + $tablename = '"'. $tablename .'"'; + } + //table prefixes could be added here later + return $tablename; +} \ No newline at end of file