diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 639707bce286119361f45ff718c03aa82b540d04..c8f4278e26209081bbac43272852c46a4a43b0e5 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,7 +1,9 @@
-Node Revision Delete 7.x-2.8, 2017-XX-XX
+Node Revision Delete 7.x-2.8, 2019-XX-XX
 ----------------------------------------
 Changes since 7.x-2.7:
 
+- #2905912 by kalabro, slydevil, adriancid, mmjvb: Allow to alter node
+  candidates.
 - #2881584 by adriancid: Implement the hook_drush_help() hook.
 
 Node Revision Delete 7.x-2.7, 2017-05-25
diff --git a/node_revision_delete.module b/node_revision_delete.module
index a390e49dd134b508798fd68575d991cc0ed43d51..1d9c00e28b2c70071a8b5bcdf75e671a932f5484 100755
--- a/node_revision_delete.module
+++ b/node_revision_delete.module
@@ -242,18 +242,20 @@ function node_revision_delete_content_types() {
  *   Array of nids.
  */
 function node_revision_delete_candidates($content_type, $max_revisions) {
-  $params = array(
-    ':content_type' => $content_type,
-    ':max_revisions' => $max_revisions,
-  );
-  $result = db_query('SELECT r.nid, count(*) as total
-                     FROM {node} n
-                     INNER JOIN {node_revision} r ON r.nid = n.nid
-                     WHERE n.type = :content_type
-                     GROUP BY r.nid
-                     HAVING count(*) > :max_revisions
-                     ORDER BY total DESC', $params);
-  return $result->fetchCol();
+  $query = db_select('node', 'n');
+  $query->join('node_revision', 'r', 'r.nid = n.nid');
+  $query->condition('n.type', $content_type);
+  $query->fields('n', ['nid']);
+  $query->addExpression('COUNT(*)', 'total');
+  $query->groupBy('r.nid');
+  $query->having('COUNT(*) > :max_revisions', [':max_revisions' => $max_revisions]);
+  $query->orderBy('total', 'DESC');
+
+  // Allow other modules to alter candidates query.
+  $query->addTag('node_revision_delete_candidates');
+  $query->addTag("node_revision_delete_candidates_$content_type");
+
+  return $query->execute()->fetchCol();
 }
 
 /**