Steps to reproduce:

  1. Create a node type with an image field with minimum dimensions of 300x500 pixels
  2. Create a new node of that type and attempt to upload an image which is smaller than 300x500 pixels
  3. Error message presented: "The specified file test.jpg could not be uploaded. The image is too small; the minimum dimensions are 300x500 pixels."
  4. Attempt to upload an image which is at least 300x500 pixels

Expected results:
Image is successfully uploaded and the error message is removed.

Actual results:
Image is successfully uploaded but the error message from the previous upload is still present.

Analysis:
From what I can tell the problem is in file_ajax_upload() in file.module. The markup generated by theme('status_messages') is prepended to the rendered form and ends up outside the form's ajax-wrapper div. When the form is submitted a second time only the ajax-wrapper div is replaced and the message is not removed.

The simplest way to get the status messages inside the ajax-wrapper is to replace line 238 of file.module:
$output = theme('status_messages') . drupal_render($form);
with
$form['#prefix'] .= theme('status_messages');
$output = drupal_render($form);

I verified that this change fixes the problem however I'm new enough to Drupal that someone else should look at this. There might be a better way to solve this or an edge case which is broken by this change.

Comments

prash_98 created an issue. See original summary.

David_Rothstein’s picture

Status: Reviewed & tested by the community » Closed (duplicate)
Issue tags: -Pending Drupal 7 commit

This is the same issue as #1792032: File validation error message not removed after subsequent upload of valid file which is already marked RTBC for Drupal 7.