Hi,

In includes/simplenews.admin.inc, we have this code:

// All conditions are combined with AND
$where = empty($where) ? '' : ' AND '. implode(' AND ', $where);

It seems the value for non-empty $where in the ternary wants to be prefixed with ' WHERE ',
not the ' AND '.

It seems to work fine at the moment because it is appended to the end
of an INNER JOIN condition:

  $query = '
    SELECT DISTINCT ss.snid, ss.*, u.name
    FROM {simplenews_subscriptions} ss
    LEFT JOIN {users} u
      ON ss.uid = u.uid
    INNER JOIN {simplenews_snid_tid} s
      ON ss.snid = s.snid
    ' . $filter['where'];

Attached is a very simple patch for it.

Cheers,

Paul

CommentFileSizeAuthor
prefixed_where_clause.patch518 bytesleebroozlee

Comments

leebroozlee’s picture

Status: Active » Needs review
simon georges’s picture

Hum... It seems you're right! I'll fix it next time I'm on the code. Thanks for the report!

berdir’s picture

Status: Needs review » Reviewed & tested by the community

Yep, looks good.

simon georges’s picture

Status: Reviewed & tested by the community » Fixed

Committed.
The code has been transformed to DBTNG in 7.x, so no need to port it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.