summaryrefslogtreecommitdiff
path: root/classes/Notice.php
diff options
context:
space:
mode:
authorCiaran Gultnieks <ciaran@thurlow.(none)>2009-01-26 21:10:32 +0000
committerCiaran Gultnieks <ciaran@thurlow.(none)>2009-01-30 01:12:58 +0000
commit53274a6d9347c256430187a22347ca4a0910a395 (patch)
treeb7d412f4a75bf918cdebf31f9341f7c25fe96ffe /classes/Notice.php
parenta4291d64cea2c9190ef190d85b4a858e111554e2 (diff)
PostgreSQL - code changes to avoid problems where user table is referenced in ad-hoc queries
Diffstat (limited to 'classes/Notice.php')
-rw-r--r--classes/Notice.php22
1 files changed, 13 insertions, 9 deletions
diff --git a/classes/Notice.php b/classes/Notice.php
index 2cdf80f1c..329988368 100644
--- a/classes/Notice.php
+++ b/classes/Notice.php
@@ -273,8 +273,10 @@ class Notice extends Memcached_DataObject
if ($cache) {
$user = new User();
+ $UT = common_config('db','type')=='pgsql'?'"user"':'user';
$user->query('SELECT id ' .
- 'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
+
+ "FROM $UT JOIN subscription ON $UT.id = subscription.subscriber " .
'WHERE subscription.subscribed = ' . $this->profile_id);
while ($user->fetch()) {
@@ -568,16 +570,17 @@ class Notice extends Memcached_DataObject
if ($enabled === true || $enabled === 'transitional') {
$inbox = new Notice_inbox();
+ $UT = common_config('db','type')=='pgsql'?'"user"':'user';
$qry = 'INSERT INTO notice_inbox (user_id, notice_id, created) ' .
- 'SELECT user.id, ' . $this->id . ', "' . $this->created . '" ' .
- 'FROM user JOIN subscription ON user.id = subscription.subscriber ' .
+ "SELECT $UT.id, " . $this->id . ', "' . $this->created . '" ' .
+ "FROM $UT JOIN subscription ON $UT.id = subscription.subscriber " .
'WHERE subscription.subscribed = ' . $this->profile_id . ' ' .
'AND NOT EXISTS (SELECT user_id, notice_id ' .
'FROM notice_inbox ' .
- 'WHERE user_id = user.id ' .
+ "WHERE user_id = $UT.id " .
'AND notice_id = ' . $this->id . ' )';
if ($enabled === 'transitional') {
- $qry .= ' AND user.inboxed = 1';
+ $qry .= " AND $UT.inboxed = 1";
}
$inbox->query($qry);
}
@@ -628,16 +631,17 @@ class Notice extends Memcached_DataObject
// FIXME: do this in an offline daemon
$inbox = new Notice_inbox();
+ $UT = common_config('db','type')=='pgsql'?'"user"':'user';
$qry = 'INSERT INTO notice_inbox (user_id, notice_id, created, source) ' .
- 'SELECT user.id, ' . $this->id . ', "' . $this->created . '", 2 ' .
- 'FROM user JOIN group_member ON user.id = group_member.profile_id ' .
+ "SELECT $UT.id, " . $this->id . ', "' . $this->created . '", 2 ' .
+ "FROM $UT JOIN group_member ON $UT.id = group_member.profile_id " .
'WHERE group_member.group_id = ' . $group->id . ' ' .
'AND NOT EXISTS (SELECT user_id, notice_id ' .
'FROM notice_inbox ' .
- 'WHERE user_id = user.id ' .
+ "WHERE user_id = $UT.id " .
'AND notice_id = ' . $this->id . ' )';
if ($enabled === 'transitional') {
- $qry .= ' AND user.inboxed = 1';
+ $qry .= " AND $UT.inboxed = 1";
}
$result = $inbox->query($qry);
}