in trying to port project.module and cvs.module to 5.x, i noticed a rather nasty problem with node_form_add_preview(). in the new release system, if you try to add a release node and there are no available tags, cvs.module form_alter()'s the node add form to remove the preview button (and all other elements of the node form, in fact), and prints an error message instead (the "ERROR: There are no CVS tags for this module that do not already have a release associated with them..." message).

however, in 5.0-rc1, when i hit this page, it immediately thinks i'm trying to preview my node. :( unfortunately, by unsetting the $form['preview'] button, i hit a bug in node_form_add_preview()... currently, the code does this:

  $op = isset($form_values['op']) ? $form_values['op'] : '';
  if ($op == $form_values['preview']) {

(care of revision 1.689, "#80574 Eaton and chx. Replace $_POST['edit'] with $_POST.").

well, in this case, $form_values['preview'] is NULL, and $op isn't set. so, we end up with if ('' == NULL) {, which is true, and we preview the node. :(

attached patch fixes this by comparing that $op really is t('Preview') which both fixes this case, and the case where people rename their preview button to 'Next' (which seems to be somewhat common practice).

CommentFileSizeAuthor
node_form_add_preview.patch.txt740 bytesdww
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

chx’s picture

Status: Needs review » Reviewed & tested by the community

That surely needs to be t('preview')

Dries’s picture

Committed to CVS HEAD. Thanks.

dww’s picture

Version: 5.0-rc1 » 5.x-dev
Status: Reviewed & tested by the community » Fixed

thanks, y'all! guess i should hurry up with this porting task in case i discover any other core bugs. ;)

Anonymous’s picture

Status: Fixed » Closed (fixed)