fmancardi/mantis-triggerclose

Query in close_issues_matching_criteria is incorrect

Opened this issue · 0 comments

Hi,
In close_issues_matching_criteria the query is incorrect, it should be something like this:

$sql = sprintf("
SELECT
bht.bug_id,
bt.summary
FROM
".db_get_table('mantis_bug_table')." AS bt
INNER JOIN
".db_get_table('mantis_bug_history_table')." AS bht
ON
bht.bug_id = bt.id
INNER JOIN
".db_get_table('mantis_user_table')." AS ut
ON
bt.handler_id = ut.id
AND
ut.access_level IN (%s)
WHERE
bt.status IN (%s)
AND
bt.category_id IN (%s)
GROUP BY
bht.bug_id
HAVING
max(bht.date_modified) < %d

",
"'".implode("', '", $privileges)."'",
"'".implode("', '", $statuses)."'",
"'".implode("', '", $categories)."'",
time() - $after_seconds
);