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).
Comment | File | Size | Author |
---|---|---|---|
node_form_add_preview.patch.txt | 740 bytes | dww |
Comments
Comment #1
chx CreditAttribution: chx commentedThat surely needs to be t('preview')
Comment #2
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #3
dwwthanks, y'all! guess i should hurry up with this porting task in case i discover any other core bugs. ;)
Comment #4
(not verified) CreditAttribution: commented