project_issue_node_form_validate() is currently attempting to modify $form_values, which is apparently a big no-no from inside a FAPI validate() hook. according to gatsby on the #drupal IRC:

|gatsby|: dww: You are not actually supposed to modify anything in _validate regardless of that patch - You can do so only with #refs. It's like a maxim

here's the problem code:

function project_issue_node_form_validate($form_id, $form) {
  global $form_values;
  ...
    if ($form_values['pid'] && $project = node_load($form_values['pid'])) {
      $node->title = $form_values['title'];
      if ($releases = project_release_load($project)) {
        if (!$form_values['rid'] || !$releases[$form_values['rid']]) {
          $form_values['rid'] = $project->version;
        }
        empty($form_values['rid']) and form_set_error('rid', t('You have to specify a valid version.'));
      }
      if ($form_values['component'] && !in_array($form_values['component'], $project->components)) {
        $form_values['component'] = 0;
      }
  ...
      $file = file_check_upload('file_issue');
      $form_values['file'] = file_save_upload($file);
  ...
}

as soon as #56921 is committed, project will break unless we fix this. sadly, i don't have time to roll a patch right now. i hope someone else can take care of this soon.

thanks,
-derek

Comments

dww’s picture

by the way, i'm pretty sure the 2nd hunk of code in there:

$file = file_check_upload('file_issue');
$form_values['file'] = file_save_upload($file);
?>

is what's responsible for #55984 "Can't attach patch to initial issue post"...

dww’s picture

whoops, the code i was trying to include got left out (damn preview not working!). i'm talking about file_check_upload():

      $file = file_check_upload('file_issue');
      $form_values['file'] = file_save_upload($file);
dww’s picture

Priority: Critical » Normal

it appears that the patch to form.inc discussed in #56921 has been reverted and won't be applied on drupal.org. so, the crisis for this issue has passed (which is why i'm downgrading this to normal). however, it's still probably a bad idea to be changing $form_values from inside validate() without using #ref, so i'm leaving this active.

aclight’s picture

Project: Project » Project issue tracking
Version: x.y.z » 4.7.x-1.x-dev
Status: Active » Fixed

I looked through both project_issue.module and issue.inc and it doesn't look like we're still doing anything evil to $form_values. So I'm marking this one fixed (and moving to the right queue).

Anonymous’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.