diff --git a/public_html/lists/admin/actions/bounces.php b/public_html/lists/admin/actions/bounces.php
index 665d0ae5b..b8ca2695b 100644
--- a/public_html/lists/admin/actions/bounces.php
+++ b/public_html/lists/admin/actions/bounces.php
@@ -35,7 +35,7 @@
from
%s as message_bounce
where
-user = %d', $GLOBALS['tables']['user_message_bounce'], $user['id']));
+userid = %d', $GLOBALS['tables']['user_message_bounce'], $user['id']));
if (Sql_Affected_Rows()) {
while ($row = Sql_Fetch_Array($req)) {
diff --git a/public_html/lists/admin/actions/campaigns.php b/public_html/lists/admin/actions/campaigns.php
index ea3515762..1adfa387e 100644
--- a/public_html/lists/admin/actions/campaigns.php
+++ b/public_html/lists/admin/actions/campaigns.php
@@ -31,10 +31,10 @@
abs(unix_timestamp(entered) - unix_timestamp(viewed)) as responsetime,
(select max(time)
from %s umb
- where umb.message = messageid and umb.user = userid
+ where umb.message = messageid and umb.userid = um.userid
) as bouncetime
- from %s
- where userid = %d and status = "sent"
+ from %s um
+ where um.userid = %d and status = "sent"
order by entered desc',
$GLOBALS['tables']['user_message_bounce'],
$GLOBALS['tables']['usermessage'],
diff --git a/public_html/lists/admin/actions/domainstats.php b/public_html/lists/admin/actions/domainstats.php
index 4d55a4a56..28287ce33 100644
--- a/public_html/lists/admin/actions/domainstats.php
+++ b/public_html/lists/admin/actions/domainstats.php
@@ -211,7 +211,7 @@
SELECT COUNT(lcase(substring_index(u.email, "@", -1))) num,
lcase(substring_index(u.email, "@", -1)) domain
FROM %s AS u
-RIGHT JOIN %s AS b ON u.id = b.user
+RIGHT JOIN %s AS umb ON u.id = umb.userid
GROUP BY domain
ORDER BY num DESC
LIMIT 25;
diff --git a/public_html/lists/admin/actions/listbounces.php b/public_html/lists/admin/actions/listbounces.php
index 97e631f3d..e43bfb37f 100644
--- a/public_html/lists/admin/actions/listbounces.php
+++ b/public_html/lists/admin/actions/listbounces.php
@@ -42,7 +42,7 @@
sleep($_SESSION['LoadDelay']);
}
$req = Sql_Query(sprintf('select listuser.listid,count(distinct userid) as numusers from %s list, %s listuser,
- %s umb, %s lm where %s list.id = listuser.listid and listuser.listid = lm.listid and listuser.userid = umb.user group by listuser.listid
+ %s umb, %s lm where %s list.id = listuser.listid and listuser.listid = lm.listid and listuser.userid = umb.userid group by listuser.listid
order by listuser.listid limit 250', $GLOBALS['tables']['list'], $GLOBALS['tables']['listuser'],
$GLOBALS['tables']['user_message_bounce'], $GLOBALS['tables']['listmessage'], $isowner_and));
$ls = new WebblerListing(s('Choose a list'));
diff --git a/public_html/lists/admin/actions/reconcileusers.php b/public_html/lists/admin/actions/reconcileusers.php
index 07ef8c9ba..162bd18d8 100644
--- a/public_html/lists/admin/actions/reconcileusers.php
+++ b/public_html/lists/admin/actions/reconcileusers.php
@@ -81,9 +81,9 @@
++$cnt;
set_time_limit(60);
if (preg_match('/([\d]+) marked unconfirmed/',$row['comment'],$regs)) {
- $exists = Sql_Fetch_Row_Query(sprintf('select count(*) from %s where user = %d and message = -1 and bounce = %d',$tables['user_message_bounce'],$regs[1],$row['id']));
+ $exists = Sql_Fetch_Row_Query(sprintf('select count(*) from %s where userid = %d and message = -1 and bounce = %d',$tables['user_message_bounce'],$regs[1],$row['id']));
if (empty($exists[0])) {
- Sql_Query(sprintf('insert into %s (user,message,bounce,time) values(%d,-1,%d,"%s")',$tables['user_message_bounce'],$regs[1],$row['id'],$row['date']));
+ Sql_Query(sprintf('insert into %s (userid,message,bounce,time) values(%d,-1,%d,"%s")',$tables['user_message_bounce'],$regs[1],$row['id'],$row['date']));
++$done;
}
}
diff --git a/public_html/lists/admin/exportuserdata.php b/public_html/lists/admin/exportuserdata.php
index d5357e41a..809c4cbb3 100644
--- a/public_html/lists/admin/exportuserdata.php
+++ b/public_html/lists/admin/exportuserdata.php
@@ -92,7 +92,7 @@
from
%s as message_bounce
where
- user = %d', $GLOBALS['tables']['user_message_bounce'], $user['id']));
+ userid = %d', $GLOBALS['tables']['user_message_bounce'], $user['id']));
while ($row = Sql_Fetch_Assoc($bouncesrows))
fputcsv($output, $row, $csvColumnDelimiter);
diff --git a/public_html/lists/admin/inc/userlib.php b/public_html/lists/admin/inc/userlib.php
index da8eb273c..2e3d79d96 100644
--- a/public_html/lists/admin/inc/userlib.php
+++ b/public_html/lists/admin/inc/userlib.php
@@ -135,7 +135,7 @@ function deleteUserRecordsLeaveBlacklistRecords($id)
Sql_Query('delete from '.$tables['usermessage'].' where userid = '.$id);
Sql_Query('delete from '.$tables['user_attribute'].' where userid = '.$id);
Sql_Query('delete from '.$tables['user_history'].' where userid = '.$id);
- Sql_Query('delete from '.$tables['user_message_bounce'].' where user = '.$id);
+ Sql_Query('delete from '.$tables['user_message_bounce'].' where userid = '.$id);
Sql_Query('delete from '.$tables['user_message_forward'].' where user = '.$id);
Sql_Query('delete from '.$tables['user'].' where id = '.$id);
Sql_Query('delete from '.$tables['user_message_view'].' where userid = '.$id);
diff --git a/public_html/lists/admin/listbounces.php b/public_html/lists/admin/listbounces.php
index bc890deb2..6ee0cf14c 100644
--- a/public_html/lists/admin/listbounces.php
+++ b/public_html/lists/admin/listbounces.php
@@ -48,7 +48,7 @@
return;
}
-$query = sprintf('select lu.userid, count(umb.bounce) as numbounces from %s lu join %s umb on lu.userid = umb.user
+$query = sprintf('select lu.userid, count(umb.bounce) as numbounces from %s lu join %s umb on lu.userid = umb.userid
where ' .
// now() < date_add(umb.time,interval 6 month) and
' lu.listid = %d
diff --git a/public_html/lists/admin/mclicks.php b/public_html/lists/admin/mclicks.php
index d3444ce9a..68283c065 100644
--- a/public_html/lists/admin/mclicks.php
+++ b/public_html/lists/admin/mclicks.php
@@ -62,7 +62,7 @@
$messagedata = Sql_Fetch_Array_query("SELECT * FROM {$tables['message']} where id = $id $subselect");
$totalusers = Sql_Fetch_Row_Query(sprintf('select count(userid) from %s where messageid = %d and status = "sent"',
$GLOBALS['tables']['usermessage'], $id));
-$totalbounced = Sql_Fetch_Row_Query(sprintf('select count(user) from %s where message = %d',
+$totalbounced = Sql_Fetch_Row_Query(sprintf('select count(userid) from %s where message = %d',
$GLOBALS['tables']['user_message_bounce'], $id));
//unique clicks
$totalclicked = Sql_Fetch_Row_Query(sprintf('select count(distinct userid) from %s where messageid = %d',
diff --git a/public_html/lists/admin/mergeduplicates.php b/public_html/lists/admin/mergeduplicates.php
index d83fa5648..1fe099a50 100644
--- a/public_html/lists/admin/mergeduplicates.php
+++ b/public_html/lists/admin/mergeduplicates.php
@@ -17,10 +17,10 @@ function mergeUsers($original, $duplicate)
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"',
$GLOBALS['tables']['usermessage'], $original, $um['entered'], $duplicate, $um['entered']), 1);
}
- $bncreq = Sql_Query(sprintf('select * from %s where user = %d', $GLOBALS['tables']['user_message_bounce'],
+ $bncreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS['tables']['user_message_bounce'],
$duplicate));
while ($bnc = Sql_Fetch_Array($bncreq)) {
- Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"',
+ Sql_Query(sprintf('update %s set userid = %d, time = "%s" where userid = %d and time = "%s"',
$GLOBALS['tables']['user_message_bounce'], $original, $bnc['time'], $duplicate, $bnc['time']), 1);
}
$listreq = Sql_Query(sprintf('select * from %s where userid = %d', $GLOBALS['tables']['listuser'], $duplicate));
@@ -30,7 +30,7 @@ function mergeUsers($original, $duplicate)
1);
}
Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS['tables']['listuser'], $duplicate));
- Sql_Query(sprintf('delete from %s where user = %d', $GLOBALS['tables']['user_message_bounce'], $duplicate));
+ Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS['tables']['user_message_bounce'], $duplicate));
Sql_Query(sprintf('delete from %s where userid = %d', $GLOBALS['tables']['usermessage'], $duplicate));
// if (MERGE_DUPLICATES_DELETE_DUPLICATE) {
deleteUser($duplicate);
diff --git a/public_html/lists/admin/msgbounces.php b/public_html/lists/admin/msgbounces.php
index 4e104582d..ee620af36 100644
--- a/public_html/lists/admin/msgbounces.php
+++ b/public_html/lists/admin/msgbounces.php
@@ -52,7 +52,7 @@
mb.bounce,
mb.time
from {$tables['user_message_bounce']} mb
- join {$tables['user']} u on u.id = mb.user
+ join {$tables['user']} u on u.id = mb.userid
where mb.message = $messageid
END;
$req = Sql_Query($query);
diff --git a/public_html/lists/admin/processbounces.php b/public_html/lists/admin/processbounces.php
index 457ac7ec0..9ae24126d 100644
--- a/public_html/lists/admin/processbounces.php
+++ b/public_html/lists/admin/processbounces.php
@@ -242,7 +242,7 @@ function processBounceData($bounceid, $msgid, $userid, $bounceDate = null)
#Use the date of the bounce, instead of "now" as processing may be different
Sql_Query(sprintf('INSERT INTO %s
(
- user,
+ userid,
message,
bounce,
time
@@ -271,11 +271,11 @@ function processBounceData($bounceid, $msgid, $userid, $bounceDate = null)
} elseif (!empty($msgid) && !empty($userid)) {
//# check if we already have this um as a bounce
//# so that we don't double count "delayed" like bounces
- $exists = Sql_Fetch_Row_Query(sprintf('select count(*) from %s where user = %d and message = %d',
+ $exists = Sql_Fetch_Row_Query(sprintf('select count(*) from %s where userid = %d and message = %d',
$tables['user_message_bounce'], $userid, $msgid));
if (empty($exists[0])) {
Sql_Query(sprintf('insert into %s
- set user = %d, message = %d, bounce = %d',
+ set userid = %d, message = %d, bounce = %d',
$tables['user_message_bounce'],
$userid, $msgid, $bounceid));
Sql_Query(sprintf('update %s
@@ -298,7 +298,7 @@ function processBounceData($bounceid, $msgid, $userid, $bounceDate = null)
} else {
//# we create the relationship, but don't increase counters
Sql_Query(sprintf('insert into %s
- set user = %d, message = %d, bounce = %d',
+ set userid = %d, message = %d, bounce = %d',
$tables['user_message_bounce'],
$userid, $msgid, $bounceid));
@@ -582,14 +582,14 @@ function processMessages($link, $max)
}
// cl_output(memory_get_usage());
- // outputProcessBounce('User '.$row['user']);
+ // outputProcessBounce('User '.$row['userid']);
$rule = matchBounceRules($row['header']."\n\n".$row['data'], $bouncerules);
// outputProcessBounce('Action '.$rule['action']);
// outputProcessBounce('Rule'.$rule['id']);
$userdata = array();
if ($rule && is_array($rule)) {
- if ($row['user']) {
- $userdata = Sql_Fetch_Array_Query("select * from {$tables['user']} where id = ".$row['user']);
+ if ($row['userid']) {
+ $userdata = Sql_Fetch_Array_Query("select * from {$tables['user']} where id = ".$row['userid']);
}
$report_linkroot = $GLOBALS['admin_scheme'].'://'.$GLOBALS['website'].$GLOBALS['adminpages'];
@@ -599,7 +599,7 @@ function processMessages($link, $max)
$GLOBALS['tables']['bounceregex_bounce'], $rule['id'], $row['bounce']));
//17860 - check the current status to avoid doing it over and over
- $currentStatus = Sql_Fetch_Assoc_Query(sprintf('select confirmed,blacklisted from %s where id = %d', $GLOBALS['tables']['user'],$row['user']));
+ $currentStatus = Sql_Fetch_Assoc_Query(sprintf('select confirmed,blacklisted from %s where id = %d', $GLOBALS['tables']['user'],$row['userid']));
$confirmed = !empty($currentStatus['confirmed']);
$blacklisted = !empty($currentStatus['blacklisted']);
@@ -609,14 +609,14 @@ function processMessages($link, $max)
$rule['id']));
$advanced_report .= 'User '.$userdata['email'].' Id '.$userdata['id'].' deleted by bounce rule '.$rule['id'].PHP_EOL;
$advanced_report .= 'Rule: '.$report_linkroot.'/?page=bouncerule&id='.$rule['id'].PHP_EOL;
- deleteUser($row['user']);
+ deleteUser($row['userid']);
break;
case 'unconfirmuser':
if ($confirmed) {
logEvent('User ' . $userdata['email'] . ' unconfirmed by bounce rule ' . PageLink2('bouncerule&id=' . $rule['id'],
$rule['id']));
Sql_Query(sprintf('update %s set confirmed = 0 where id = %d', $GLOBALS['tables']['user'],
- $row['user']));
+ $row['userid']));
$advanced_report .= 'User ' . $userdata['email'] . ' made unconfirmed by bounce rule ' . $rule['id'] . PHP_EOL;
$advanced_report .= 'User: ' . $report_linkroot . '/?page=user&id=' . $userdata['id'] . PHP_EOL;
$advanced_report .= 'Rule: ' . $report_linkroot . '/?page=bouncerule&id=' . $rule['id'] . PHP_EOL;
@@ -630,7 +630,7 @@ function processMessages($link, $max)
$rule['id']));
$advanced_report .= 'User '.$userdata['email'].' Id '.$userdata['id'].' deleted by bounce rule '.$rule['id'].PHP_EOL;
$advanced_report .= 'Rule: '.$report_linkroot.'/?page=bouncerule&id='.$rule['id'].PHP_EOL;
- deleteUser($row['user']);
+ deleteUser($row['userid']);
deleteBounce($row['bounce']);
break;
case 'unconfirmuseranddeletebounce':
@@ -638,7 +638,7 @@ function processMessages($link, $max)
logEvent('User ' . $userdata['email'] . ' unconfirmed by bounce rule ' . PageLink2('bouncerule&id=' . $rule['id'],
$rule['id']));
Sql_Query(sprintf('update %s set confirmed = 0 where id = %d', $GLOBALS['tables']['user'],
- $row['user']));
+ $row['userid']));
$advanced_report .= 'User ' . $userdata['email'] . ' made unconfirmed by bounce rule ' . $rule['id'] . PHP_EOL;
$advanced_report .= 'User: ' . $report_linkroot . '/?page=user&id=' . $userdata['id'] . PHP_EOL;
$advanced_report .= 'Rule: ' . $report_linkroot . '/?page=bouncerule&id=' . $rule['id'] . PHP_EOL;
@@ -724,8 +724,8 @@ function processMessages($link, $max)
outputProcessBounce($GLOBALS['I18N']->get('Identifying consecutive bounces'));
// we only need users who are confirmed at the moment
-$userid_req = Sql_query(sprintf('select distinct umb.user from %s umb, %s u
- where u.id = umb.user and u.confirmed and !u.blacklisted',
+$userid_req = Sql_query(sprintf('select distinct umb.userid from %s umb, %s u
+ where u.id = umb.userid and u.confirmed and !u.blacklisted',
$tables['user_message_bounce'],
$tables['user']
));
@@ -739,17 +739,9 @@ function processMessages($link, $max)
while ($user = Sql_Fetch_Row($userid_req)) {
keepLock($process_id);
set_time_limit(600);
- //$msg_req = Sql_Query(sprintf('select * from
- //%s um left join %s umb on (um.messageid = umb.message and userid = user)
- //where userid = %d and um.status = "sent"
- //order by entered desc',
- //$tables["usermessage"],$tables["user_message_bounce"],
- //$user[0]));
-
- //# 17361 - update of the above query, to include the bounce table and to exclude duplicate bounces
- $msg_req = Sql_Query(sprintf('select umb.*,um.*,b.status,b.comment from %s um left join %s umb on (um.messageid = umb.message and userid = user)
+ $msg_req = Sql_Query(sprintf('select umb.*,um.*,b.status,b.comment from %s um left join %s umb on (um.messageid = umb.message and um.userid = umb.userid)
left join %s b on umb.bounce = b.id
- where userid = %d and um.status = "sent"
+ where um.userid = %d and um.status = "sent"
order by entered desc',
$tables['usermessage'], $tables['user_message_bounce'], $tables['bounce'],
$user[0]));
diff --git a/public_html/lists/admin/reconcileusers.php b/public_html/lists/admin/reconcileusers.php
index 95f1c5cb4..890558a47 100644
--- a/public_html/lists/admin/reconcileusers.php
+++ b/public_html/lists/admin/reconcileusers.php
@@ -109,14 +109,14 @@ function mergeUser($userid)
Sql_Query(sprintf('update %s set userid = %d, entered = "%s" where userid = %d and entered = "%s"',
$GLOBALS['tables']['usermessage'], $orig[0], $um['entered'], $duplicate['id'], $um['entered']), 1);
}
- $bncreq = Sql_Query("select * from {$GLOBALS['tables']['user_message_bounce']} where user = ".$duplicate['id']);
+ $bncreq = Sql_Query("select * from {$GLOBALS['tables']['user_message_bounce']} where userid = ".$duplicate['id']);
while ($bnc = Sql_Fetch_Array($bncreq)) {
- Sql_Query(sprintf('update %s set user = %d, time = "%s" where user = %d and time = "%s"',
+ Sql_Query(sprintf('update %s set userid = %d, time = "%s" where userid = %d and time = "%s"',
$GLOBALS['tables']['user_message_bounce'], $orig[0], $bnc['time'], $duplicate['id'], $bnc['time']),
1);
}
Sql_Query("delete from {$GLOBALS['tables']['listuser']} where userid = ".$duplicate['id']);
- Sql_Query("delete from {$GLOBALS['tables']['user_message_bounce']} where user = ".$duplicate['id']);
+ Sql_Query("delete from {$GLOBALS['tables']['user_message_bounce']} where userid = ".$duplicate['id']);
Sql_Query("delete from {$GLOBALS['tables']['usermessage']} where userid = ".$duplicate['id']);
if (MERGE_DUPLICATES_DELETE_DUPLICATE) {
deleteUser($duplicate['id']);
@@ -370,12 +370,12 @@ function addUniqID($userid)
while ($row = Sql_Fetch_Row($req)) {
Sql_Query("delete from {$tables['usermessage']} where userid = $row[0]");
}
- $req = Sql_Verbose_Query("select {$tables['user_message_bounce']}.user
- from {$tables['user_message_bounce']} left join {$tables['user']} on {$tables['user_message_bounce']}.user = {$tables['user']}.id
- where {$tables['user']}.id IS NULL group by {$tables['user_message_bounce']}.user");
+ $req = Sql_Verbose_Query("select {$tables['user_message_bounce']}.userid
+ from {$tables['user_message_bounce']} left join {$tables['user']} on {$tables['user_message_bounce']}.userid = {$tables['user']}.id
+ where {$tables['user']}.id IS NULL group by {$tables['user_message_bounce']}.userid");
echo Sql_Affected_Rows().' '.s('entries apply').'
';
while ($row = Sql_Fetch_Row($req)) {
- Sql_Query("delete from {$tables['user_message_bounce']} where user = $row[0]");
+ Sql_Query("delete from {$tables['user_message_bounce']} where userid = $row[0]");
}
}
diff --git a/public_html/lists/admin/statsoverview.php b/public_html/lists/admin/statsoverview.php
index ef58725e6..84a860180 100644
--- a/public_html/lists/admin/statsoverview.php
+++ b/public_html/lists/admin/statsoverview.php
@@ -131,7 +131,7 @@
$ls->addColumn($element,' ',$messagedata['bouncecount']);
*/
//Bounced
-$bounced = Sql_Fetch_Row_Query(sprintf('select count(distinct user) from %s where message = %d',
+$bounced = Sql_Fetch_Row_Query(sprintf('select count(distinct userid) from %s where message = %d',
$tables['user_message_bounce'], $id));
$element = ucfirst(s('Bounced'));
$ls->addElement($element);
diff --git a/public_html/lists/admin/structure.php b/public_html/lists/admin/structure.php
index 703f3e9c1..b1fe1ba24 100644
--- a/public_html/lists/admin/structure.php
+++ b/public_html/lists/admin/structure.php
@@ -258,18 +258,18 @@
),
'user_message_bounce' => array( // bounce. We can have one usermessage bounce multiple times
'id' => array('integer not null primary key auto_increment', 'ID'),
- 'user' => array('integer not null', 'subscriber ID'),
+ 'userid' => array('integer not null', 'subscriber ID'),
'message' => array('integer not null', 'Message ID'),
'bounce' => array('integer not null', 'Bounce ID'),
'time' => array('timestamp', 'When did it bounce'),
- 'index_1' => array('umbindex (user,message,bounce)', 'index'),
- 'index_2' => array('useridx (user)', 'index'),
+ 'index_1' => array('umbindex (userid,message,bounce)', 'index'),
+ 'index_2' => array('useridx (userid)', 'index'),
'index_3' => array('msgidx (message)', 'index'),
'index_4' => array('bounceidx (bounce)', 'index'),
),
'user_message_forward' => array(
'id' => array('integer not null primary key auto_increment', 'ID'),
- 'user' => array('integer not null', 'subscriber ID'),
+ 'user' => array('integer not null', 'subscriber ID'),
'message' => array('integer not null', 'Message ID'),
'forward' => array('varchar(255)', 'Forward email'),
'status' => array('varchar(255)', 'Status of forward'),
diff --git a/public_html/lists/admin/upgrade.php b/public_html/lists/admin/upgrade.php
index b10e9697b..0ffa222a1 100644
--- a/public_html/lists/admin/upgrade.php
+++ b/public_html/lists/admin/upgrade.php
@@ -468,6 +468,14 @@ function output($message)
Sql_Query("alter table {$GLOBALS['tables']['admin']} modify modifiedby varchar(66) default ''");
}
+ if (Sql_Table_column_exists($GLOBALS['tables']['user_message_bounce'],'user')) {
+ Sql_Query('drop index umbindex on '.$GLOBALS['tables']['user_message_bounce']);
+ Sql_Query('drop index useridx on '.$GLOBALS['tables']['user_message_bounce']);
+ Sql_Query('alter table '.$GLOBALS['tables']['user_message_bounce'].' change column user userid integer not null');
+ Sql_Query('alter table '.$GLOBALS['tables']['user_message_bounce'].' add index umbindex (userid,message,bounce)' );
+ Sql_Query('alter table '.$GLOBALS['tables']['user_message_bounce'].' add index useridx (userid)' );
+ }
+
//# longblobs are better at mixing character encoding. We don't know the encoding of anything we may want to store in cache
//# before converting, it's quickest to clear the cache
clearPageCache();