Closed (fixed)
Project:
Mailchimp
Version:
6.x-2.3
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
17 Dec 2010 at 22:32 UTC
Updated:
11 Jan 2011 at 20:20 UTC
When cron runs it only subscribes users in the mailchimp_user table if they are active (status = 1), however it still changes their status in mailchimp_user from pending to current.
This doesn't seem like the best behaviour.
There are two solutions to this in mailchimp_cron()
One, change the initial query to omit inactive users:
$sql = "SELECT m.uid FROM {mailchimp_user} m
LEFT JOIN {users} u ON (m.uid = u.uid)
WHERE m.status = '%s'
AND u.status = 1";
Two, move the db_query that changes the status to "current" beneath the if statement:
From:
while ($row = db_fetch_object($result)) {
if ($account = user_load(array('uid' => $row->uid))) {
db_query('UPDATE {mailchimp_user} SET status = \'%s\' WHERE uid = %d', MAILCHIMP_USERSTATUS_CURRENT, $account->uid);
// We don't update people if their status = 0 (but perhaps we could unsubscribe them?)
if ($account->status) {
foreach ((array)$lists as $key => $list) {
To:
while ($row = db_fetch_object($result)) {
if ($account = user_load(array('uid' => $row->uid))) {
// We don't update people if their status = 0 (but perhaps we could unsubscribe them?)
if ($account->status) {
db_query('UPDATE {mailchimp_user} SET status = \'%s\' WHERE uid = %d', MAILCHIMP_USERSTATUS_CURRENT, $account->uid);
foreach ((array)$lists as $key => $list) {
Comments
Comment #1
levelos commentedThanks Sarenc, I went with #1, which also allows us to remove the conditional block. http://drupal.org/cvs?commit=470464