Skip to content

Commit ef86096

Browse files
committed
Trac: Active Tickets query: Update [14813] to support non-quoted int's as required for Sqlite.
git-svn-id: https://meta.svn.wordpress.org/sites/trunk@14815 74240141-8908-4e6f-9713-ba540dce6ec7
1 parent 9ed8efc commit ef86096

1 file changed

Lines changed: 26 additions & 27 deletions

File tree

wordpress.org/public_html/wp-content/plugins/trac-notifications/trac-notifications-db.php

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -272,38 +272,37 @@ function delete_user_pref( $username, $name ) {
272272
* @return array
273273
*/
274274
function get_active_tickets( $days = 14, $min_participants = 3, $limit = 15 ) {
275-
$days = max( 1, min( 90, (int) $days ) );
276-
$min_participants = max( 2, (int) $min_participants );
277-
$limit = max( 1, min( 50, (int) $limit ) );
275+
$days = (int) max( 1, min( 90, (int) $days ) );
276+
$min_participants = (int) max( 2, (int) $min_participants );
277+
$limit = (int) max( 1, min( 50, (int) $limit ) );
278278

279279
// Trac stores timestamps in microseconds.
280280
$since = ( time() - ( 86400 * $days ) ) * 1000000;
281281

282-
$rows = $this->db->get_results( $this->db->prepare(
282+
// Note: Prepare not used here intentionally, due to lack of unquoted %d support. Variables savely cast above.
283+
$rows = $this->db->get_results(
283284
"SELECT tc.ticket,
284-
t.summary,
285-
t.status,
286-
t.type,
287-
t.component,
288-
t.priority,
289-
t.milestone,
290-
t.owner,
291-
COUNT(*) AS change_count,
292-
COUNT(DISTINCT tc.author) AS participant_count,
293-
MAX(tc.time) AS last_activity
294-
FROM ticket_change tc
295-
INNER JOIN ticket t ON tc.ticket = t.id
296-
WHERE tc.time >= %s
297-
AND tc.field <> 'cc'
298-
AND NOT (tc.field = 'comment' AND tc.newvalue = '')
299-
GROUP BY tc.ticket
300-
HAVING participant_count >= %d
301-
ORDER BY participant_count DESC, change_count DESC
302-
LIMIT %d",
303-
$since,
304-
$min_participants,
305-
$limit
306-
), ARRAY_A );
285+
t.summary,
286+
t.status,
287+
t.type,
288+
t.component,
289+
t.priority,
290+
t.milestone,
291+
t.owner,
292+
COUNT(*) AS change_count,
293+
COUNT(DISTINCT tc.author) AS participant_count,
294+
MAX(tc.time) AS last_activity
295+
FROM ticket_change tc
296+
INNER JOIN ticket t ON tc.ticket = t.id
297+
WHERE tc.time >= $since
298+
AND tc.field <> 'cc'
299+
AND NOT (tc.field = 'comment' AND tc.newvalue = '')
300+
AND tc.author NOT IN ( 'slackbot', 'prbot' )
301+
GROUP BY tc.ticket
302+
HAVING participant_count >= $min_participants
303+
ORDER BY participant_count DESC, change_count DESC
304+
LIMIT $limit"
305+
);
307306

308307
if ( ! $rows ) {
309308
return array();

0 commit comments

Comments
 (0)