Index: comment.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/comment.inc,v retrieving revision 1.124 diff -u -F^f -u -F^f -r1.124 comment.inc --- comment.inc 4 Mar 2008 20:14:12 -0000 1.124 +++ comment.inc 5 Mar 2008 15:24:21 -0000 @@ -94,7 +94,7 @@ function project_issue_comment(&$arg, $o } if (isset($id)) { - db_query("INSERT INTO {project_issue_comments} (nid, cid, pid, rid, component, category, priority, assigned, sid, title, timestamp) VALUES (%d, %d, %d, %d, '%s', '%s', %d, %d, %d, '%s', %d)", $arg['nid'], $arg['cid'], $arg['project_info']['pid'], $arg['project_info']['rid'], $arg['project_info']['component'], $arg['category'], $arg['priority'], $arg['assigned'], $arg['sid'], $arg['title'], $arg['timestamp']); + db_query("INSERT INTO {project_issue_comments} (nid, cid, pid, rid, component, category, priority, assigned, sid, title, timestamp, comment_number) VALUES (%d, %d, %d, %d, '%s', '%s', %d, %d, %d, '%s', %d, %d)", $arg['nid'], $arg['cid'], $arg['project_info']['pid'], $arg['project_info']['rid'], $arg['project_info']['component'], $arg['category'], $arg['priority'], $arg['assigned'], $arg['sid'], $arg['title'], $arg['timestamp'], $id); db_query("UPDATE {comments} SET subject = '%s' WHERE cid = %d", "#$id", $arg['cid']); project_issue_update_by_comment($arg, 'insert'); } Index: project_issue.install =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.install,v retrieving revision 1.44 diff -u -F^f -u -F^f -r1.44 project_issue.install --- project_issue.install 4 Mar 2008 18:43:59 -0000 1.44 +++ project_issue.install 5 Mar 2008 15:24:21 -0000 @@ -713,6 +713,29 @@ function project_issue_update_5205() { } /** + * Add a comment_number column to {project_issue_comments}. + */ +function project_issue_update_5206() { + $ret = array(); + + switch ($GLOBALS['db_type']) { + case 'mysql': + case 'mysqli': + $ret[] = update_sql("ALTER TABLE {project_issue_comments} ADD comment_number INT(10) NOT NULL DEFAULT '0'"); + $ret[] = update_sql("ALTER TABLE {project_issue_comments} ADD INDEX (comment_number)"); + $ret[] = update_sql("UPDATE {project_issue_comments} pic INNER JOIN {comments} c ON pic.cid = c.cid SET pic.comment_number = CONVERT(SUBSTRING(c.subject, 2), UNSIGNED)"); + break; + case 'pgsql': + db_add_column($ret, 'project_issue_comments', 'comment_number', 'int', array('not null' => TRUE, 'default' => 0)); + $ret[] = update_sql('CREATE INDEX {project_issue_comments}_comment_number_idx ON {project_issue_comments} (comment_number)'); + $ret[] = update_sql("UPDATE ONLY {project_issue_comments} pic SET comment_number = CAST(substring(c.subject from 2) AS int) FROM comments c WHERE pic.cid = c.cid"); + break; + } + + return $ret; +} + +/** * Helper function for determining new module dependencies. * * @param $modules Index: project_issue.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/project_issue.module,v retrieving revision 1.83 diff -u -F^f -u -F^f -r1.83 project_issue.module --- project_issue.module 8 Feb 2008 17:49:26 -0000 1.83 +++ project_issue.module 5 Mar 2008 15:24:22 -0000 @@ -1155,9 +1155,8 @@ function project_issue_filter($op, $delt $comment_number = $preg_matches[4][0]; $node = node_load($nid); if (is_object($node) && node_access('view', $node) && $node->type == 'project_issue') { - if (!is_null($comment_number)) { - // Pull comment id based on the comment number. - $comment_id = db_result(db_query("SELECT cid FROM {comments} WHERE nid = %d AND thread = '%s'", $nid, int2vancode($comment_number) .'/')); + // Pull comment id based on the comment number if we have one. + if (!is_null($comment_number) && ($comment_id = db_result(db_query("SELECT pic.cid FROM {project_issue_comments} pic INNER JOIN {comments} c ON pic.cid = c.cid WHERE pic.nid = %d AND pic.comment_number = %d AND c.status = %d", $nid, $comment_number, COMMENT_PUBLISHED)))) { $link = theme('project_issue_issue_link', $node, $comment_id, $comment_number); } else {