View Issue Details

IDProjectCategoryView StatusLast Update
0016640phplist applicationMessage Send Processpublic04-06-13 22:35
Reporterseanfulton 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Platformphp 5.3.3OSel6OS Version
Product Version2.11.6 
Target Version2.11.7Fixed in Version2.11.10 
Summary0016640: USE_LIST_EXCLUDE not working
DescriptionWe activated the (USE_LIST_EXCLUDE, 1) variable in the config file but:

There is no indication in the message view that an exclude list has been chosen
The number sent matches the original list (no deduction of excluded users)
Users on the exclude list still get the message.

Does this feature work or is it commented out???
Steps To ReproduceSet USE_LIST_EXCLUDE to 1
Create a list
Add e-mail to the list
Create an exclude list
Add the e-mail to the exlude list
Send e-mail to the first list
Message gets to recipient who is on the exclude list.
TagsNo tags attached.

Activities

support

06-06-12 14:28

administrator   ~0051665


it's supposed to work, but I'll do a review of the functionality for the next dev-version.

seanfulton

08-06-12 15:48

reporter   ~0051669

The code to select the exclude lists appears to have been commented out in 2.11.6, but exists and appears to have been working in 2.11.3.

Here is what we did to fix:

Comment out or remove lines 561 to 586:

  if (USE_LIST_EXCLUDE) {
    if (VERBOSE) {
      output($GLOBALS['I18N']->get('looking for users who can be excluded from this mailing'));
    }
    if (count($msgdata['excludelist'])) {
/*
      $query
      = " select userid"
      . " from ". $GLOBALS['tables']['listuser']
      . " where listid in (".join(',',$msgdata['excludelist']).")";
      if (VERBOSE) {
        output('Exclude query '.$query);
      }
      $req = Sql_Query($query);
      while ($row = Sql_Fetch_Row($req)) {
        array_push($skipusers,$row[0]);
      }
*/
      $exclusion = sprintf(' and listuser.listid not in (%s)',join(',',$msgdata['excludelist']));
    }
/*
    if (sizeof($skipusers))
      $exclusion .= " and listuser.userid not in (".join(",",$skipusers).")";
*/
  }

Add the following (this is mostly stuff from 2.11.3, re-written to handle the serialized exluce list array:

 if (USE_LIST_EXCLUDE == 1) {
    $excluded_lists = Sql_Fetch_Row_Query(sprintf('select data from %s where name = "excludelist" and id = %d',
      $GLOBALS["tables"]["messagedata"],$messageid));
    if (strlen($excluded_lists[0])) {

    // Modified by GCN 06/07/12 to fix the strange arrays created by the front-end
    $parseValWithoutSER = ltrim($excluded_lists[0], "SER:") ;
    //echo "Searilize:".$parseValWithoutSER."\r\n";
    $unserializeDataArr = array() ;
    $unserializeDataArr = unserialize($parseValWithoutSER) ;
    //print_r($unserializeDataArr);
    
    $cleaned_excludeCSV = implode(",",$unserializeDataArr);
    
       // output('User excluded Lists '.$cleaned_excludeCSV);
    $req = Sql_Query(sprintf('select listuser.userid from %s as listuser where listid in (%s)',
            $GLOBALS["tables"]["listuser"],$cleaned_excludeCSV));

      /* replaced by above
    $req = Sql_Query(sprintf('select listuser.userid from %s as listuser where listid in (%s)',
        $GLOBALS["tables"]["listuser"],$excluded_lists[0]));
       */
    $skipusers = array();
            
      while ($row = Sql_Fetch_Row($req)) {
        array_push($skipusers,$row[0]);
      }
       // output('User skipped users Lists '.$skipusers[0]);
     $query .= sprintf(' and listuser.listid not in (%s)',$cleaned_excludeCSV);

      if (sizeof($skipusers))
      $exclusion .= " and listuser.userid not in (".join(",",$skipusers).")";
 
    // $query .= sprintf(' and listuser.listid not in (%s)',$excluded_lists[0]);
    } // if strlen
  } // exclude

  $userconfirmed = ' and user.confirmed and !user.blacklisted ';

Down below, there is a section that looks like it changed as well. I took out lines 602-618:
 if (USE_LIST_EXCLUDE == 1) {
    $excluded_lists = Sql_Fetch_Row_Query(sprintf('select data from %s where name = "excludelist" and id = %d',
      $GLOBALS["tables"]["messagedata"],$messageid));
    if (strlen($excluded_lists[0])) {

    // Modified by sean 06/07/12 to fix the strange arrays created by the front-end
    $parseValWithoutSER = ltrim($excluded_lists[0], "SER:") ;
    //echo "Searilize:".$parseValWithoutSER."\r\n";
    $unserializeDataArr = array() ;
    $unserializeDataArr = unserialize($parseValWithoutSER) ;
    //print_r($unserializeDataArr);
    
    $cleaned_excludeCSV = implode(",",$unserializeDataArr);
    
       // output('User excluded Lists '.$cleaned_excludeCSV);
    $req = Sql_Query(sprintf('select listuser.userid from %s as listuser where listid in (%s)',
            $GLOBALS["tables"]["listuser"],$cleaned_excludeCSV));

      /* replaced by above
    $req = Sql_Query(sprintf('select listuser.userid from %s as listuser where listid in (%s)',
        $GLOBALS["tables"]["listuser"],$excluded_lists[0]));
       */
    $skipusers = array();
            
      while ($row = Sql_Fetch_Row($req)) {
        array_push($skipusers,$row[0]);
      }
       // output('User skipped users Lists '.$skipusers[0]);
     $query .= sprintf(' and listuser.listid not in (%s)',$cleaned_excludeCSV);

      if (sizeof($skipusers))
      $exclusion .= " and listuser.userid not in (".join(",",$skipusers).")";
 
    // $query .= sprintf(' and listuser.listid not in (%s)',$excluded_lists[0]);
    } // if strlen
  } // exclude

  $userconfirmed = ' and user.confirmed and !user.blacklisted ';

And replaced it with this from 2.11.3:

  $query = sprintf('select distinct user.id from
  (%s as listuser,
  %s as user,
  %s as listmessage)
  left join %s as usermessage
  on (usermessage.messageid = %d and usermessage.userid = listuser.userid)
  where
  listmessage.messageid = %d and
  listmessage.listid = listuser.listid and
  user.id = listuser.userid and
  usermessage.userid IS NULL
  %s %s %s',
  $tables['listuser'], $tables['user'], $tables['listmessage'], $tables['usermessage'],
  $messageid, $messageid,
  $userconfirmed, $exclusion, $user_attribute_query);

###

support

08-06-12 20:54

administrator   ~0051670

thanks, that's great. No idea why the code was commented out on the 2.11.6 version, it may be because it needed a review. There were some issues about the queries taking too long, or the DB tables being too small to fit the query or something. Maybe searching mantis, or checking the commit entries will shine some light on that.

Let me know if you find any issues with it, and then we can make sure they get resolved as well.

seanfulton

08-06-12 21:06

reporter   ~0051671

Well, this part which is commented out in 2.11.6 is *shorter* than what was in 2.11.3, but it doesn't work because in 2.11.3, $msgdata['excludelist'] was an array of list IDs, but in 2.11.6, it is a serialized array.

So it seemed to us that it might have been commented out for testing and no one went back and fixed the array issue. But I wasn't sure so I just grabbed everything from 2.11.3. I suppose I could un-comment your original code and fix the array and see if that works ...


sean


    if (count($msgdata['excludelist'])) {
/*
      $query
      = " select userid"
      . " from ". $GLOBALS['tables']['listuser']
      . " where listid in (".join(',',$msgdata['excludelist']).")";
      if (VERBOSE) {
        output('Exclude query '.$query);
      }
      $req = Sql_Query($query);
      while ($row = Sql_Fetch_Row($req)) {
        array_push($skipusers,$row[0]);
      }
*/
      $exclusion = sprintf(' and listuser.listid not in
(%s)',join(',',$msgdata['excludelist']));

seanfulton

21-06-12 16:38

reporter   ~0051677

Michiel, do you think this:

https://mantis.phplist.com/view.php?id=11732

Needs to be applied to the fix above??

sean

michiel

22-06-12 16:11

manager   ~0051684

not sure, but it's unlikely. That issue is too old.