upload 2 or more files
uncheck display checkboxes for all files
save node

the 2nd file is displayed

Comments

giorgosk’s picture

Title: Display Setting of 2ND file uploaded when Disabled/Off is not respected » 2ND file uploaded is displayed when display option is unchecked

better title

aaron’s picture

subscribe

duellj’s picture

Status: Active » Needs review
StatusFileSize
new682 bytes

Simple fix. Field items were being rekeyed before loop to remove hidden items finished.

webchick’s picture

Issue tags: +Needs tests

Nice catch.

Could we please add tests for this? We've found all kinds of these tweaky edge-case bugs in File.module lately, and I'd like to ensure we don't ever have to fix them twice. :)

duellj’s picture

Assigned: Unassigned » duellj
Status: Needs review » Needs work

It looks like there was a test case to test the "display" option, but it only accounted for one file attached to a node. I'll rework the test so more than one file upload is tested. Do you think two will be enough?

giorgosk’s picture

#3 fixes problem

duellj’s picture

Status: Needs work » Needs review
StatusFileSize
new3.95 KB

Here's a reworking of the file field test to test multiple file fields (currently it's two, but could easily be changed to more). The only other thing I can see that needs to be tested is file order. It looks like there's a nice TODO message in field.test to add a test for display order, so maybe that can be handled in another issue.

dave reid’s picture

Priority: Normal » Major
Status: Needs review » Reviewed & tested by the community

Marked #1016068: File field display consecutive files hide error and #1041508: Problem with file_field_prepare_view as duplicates of this issue.

Confirmed this fixes a fairly major bug in D7 and the test looks like it covers it well.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Awesome, thanks!

I committed #3 to HEAD for now so we can get the bug fixed, but some feedback on the test:

-    $type_name = 'article';
+    $nid_or_type = 'article';

Ick! Can we not do this? Let's make separate variables for $nid and $type and use them accordingly. This change makes the test much harder to read and understand.

duellj’s picture

Title: 2ND file uploaded is displayed when display option is unchecked » Make filefield upload node tests more readable

Agreed that $nid_or_type is just plain icky :). I was just referencing the call to FileFieldTestCase::uploadNodeFile, which takes $nid_or_type as an argument:

  /**
   * Upload a file to a node.
   */
  function uploadNodeFile($file, $field_name, $nid_or_type, $new_revision = TRUE) {

That function should also be rewritten, probably split out into two methods.

webchick’s picture

Well, we unfortunately can't change that function signature in Drupal 7 without breaking other peoples' tests. However, we do have control over what the variables are named within the tests calling that function. So let's just revert the name change back to what it was before.

lolmaus’s picture

So what's going to be done with this issue?

lolmaus’s picture

I've applied the #7 patch against Drupal 7.0 and it seems to resolve the issue.

markabur’s picture

Glad I found this. Client was extremely confused this morning. Patched 7.0 (using -p0) using #7 above and it works fine.

sun’s picture

Version: 7.x-dev » 8.x-dev
Priority: Major » Minor
Issue tags: +Needs backport to D7
donquixote’s picture

Works ok for Drupal 7.
(I only tested the two lines in the foreach, not the test stuff)

mgifford’s picture

Version: 8.0.x-dev » 8.1.x-dev
Assigned: duellj » Unassigned
Issue summary: View changes

This still a concern in D8? Unassigned issue too.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.0-beta1 was released on March 2, 2016, which means new developments and disruptive changes should now be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • webchick committed 19aac3d on 8.3.x
    #932426 by duellj: Fix second file uploaded is displayed when display...

  • webchick committed 19aac3d on 8.3.x
    #932426 by duellj: Fix second file uploaded is displayed when display...

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.0-beta1 was released on August 3, 2016, which means new developments and disruptive changes should now be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

  • webchick committed 19aac3d on 8.4.x
    #932426 by duellj: Fix second file uploaded is displayed when display...

  • webchick committed 19aac3d on 8.4.x
    #932426 by duellj: Fix second file uploaded is displayed when display...

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.0-alpha1 will be released the week of January 30, 2017, which means new developments and disruptive changes should now be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.0-alpha1 will be released the week of July 31, 2017, which means new developments and disruptive changes should now be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

  • webchick committed 19aac3d on 9.1.x
    #932426 by duellj: Fix second file uploaded is displayed when display...

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

catch’s picture

Title: Make filefield upload node tests more readable » 2ND file uploaded is displayed when display option is unchecked
Version: 9.3.x-dev » 7.x-dev
Status: Needs work » Fixed

The original bug was fixed back in 2011, and UploadNodeField, while it still exists, no longer has an $nid_or_file argument.

Status: Fixed » Closed (fixed)

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