? 361649-21.patch
Index: comment.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/comment.inc,v
retrieving revision 1.140
diff -u -p -r1.140 comment.inc
--- comment.inc	27 Jan 2009 17:03:58 -0000	1.140
+++ comment.inc	28 Jan 2009 04:14:08 -0000
@@ -78,7 +78,7 @@ function project_issue_comment(&$arg, $o
         $test->component = $arg->project_info['component'];
         $test->assigned = $arg->project_info['assigned'];
         // Add a dummy rid if necessary -- prevents incorrect change data.
-        $test->rid = $arg->project_info['rid'] ? $arg->project_info['rid'] : 0;
+        $test->rid = isset($arg->project_info['rid']) ? $arg->project_info['rid'] : 0;
         $comment_changes = project_issue_metadata_changes($node, $old_data, $test, project_issue_field_labels('web'));
         $project_issue_table = theme('project_issue_comment_table', $comment_changes);
       }
@@ -278,7 +278,8 @@ function project_issue_form_comment_vali
     form_set_value(array('#parents' => array('pid')), 0, $form_state);
 
     // Validate version.
-    if (module_exists('project_release') && ($releases = project_release_get_releases($project, 0, 'version', 'all', array($form_state['values']['project_info']['rid'])))) {
+    $current_rid = isset($form_state['values']['project_info']['rid']) ? $form_state['values']['project_info']['rid'] : 0;
+    if (module_exists('project_release') && $current_rid && ($releases = project_release_get_releases($project, 0, 'version', 'all', array($current_rid)))) {
       $rid = $form_state['values']['project_info']['rid'];
       if ($rid && !in_array($rid, array_keys($releases))) {
         $rid = 0;
@@ -323,8 +324,13 @@ function project_issue_form_comment_vali
     $comment->pid = $form_state['values']['project_info']['pid'];
     $comment->component = $form_state['values']['project_info']['component'];
     // Add a dummy rid if necessary -- prevents incorrect change data.
-    $comment->rid = $form_state['values']['project_info']['rid'] ? $form_state['values']['project_info']['rid'] : 0;
+    $comment->rid = isset($form_state['values']['project_info']['rid']) ? $form_state['values']['project_info']['rid'] : 0;
+    $comment->assigned = $form_state['values']['project_info']['assigned'];
     $comment_changes = project_issue_metadata_changes($node, $old_data, $comment, project_issue_field_labels('web'));
+    // If the PID changed, rebuild the form
+    if ($comment_changes['pid']['new'] === TRUE) {
+      $form_state['rebuild'] = TRUE;
+    }
     $has_change = FALSE;
     foreach ($comment_changes as $field => $changes) {
       if (isset($changes['new'])) {
@@ -573,7 +579,7 @@ function project_issue_comment_pre_rende
   // after the comment form on preview, in the case where the comment
   // parent is 0.  If we want our issue previews to be consistent, this
   // ugly hack is necessary.
-  if ($_POST['op'] == t('Preview comment')) {
+  if (isset($_POST['op']) && $_POST['op'] == t('Preview comment')) {
     $preview = comment_render($node, 0);
   }
   else {
Index: issue.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue/issue.inc,v
retrieving revision 1.333
diff -u -p -r1.333 issue.inc
--- issue.inc	27 Jan 2009 14:40:25 -0000	1.333
+++ issue.inc	28 Jan 2009 04:14:09 -0000
@@ -25,7 +25,7 @@ function project_issue_update_project() 
   // These used to be path arguments. Now they arrive via form element.
   $issue_nid = $form['nid']['#value'];
   $pid = $form_state['values']['project_info']['pid'];
-  $rid = $form_state['values']['project_info']['rid'];
+  $rid = isset($form_state['values']['project_info']['rid']) ? $form_state['values']['project_info']['rid'] : 0;
   $cid = $form_state['values']['cid'];
   $assigned_uid = $form_state['values']['project_info']['assigned'];
 
