Skip to content

Same-named files in different upload directories report zero Grid usage #5409

Description

@robinsowell

Description of the problem

Two files with the same basename, stored at the top level of two different upload directories and referenced from a Grid, have both been reported with a usage count of zero.

These should be independent file records with unique file_id values. Legacy-style references also include the upload-location ID, for example {filedir_1}image.jpg and {filedir_2}image.jpg, so the shared basename should not make the references ambiguous.

This is being reported separately from the multiple-File-column Grid rebuild defect so the duplicate-name/upload-directory behavior can be reproduced and diagnosed independently.

How To Reproduce

  1. Create two upload directories.
  2. Upload a file named image.jpg at the top level of each directory. Confirm that the files have different file_id values.
  3. Create a Grid containing a single native File column. Using only one File column avoids the separate multi-column accumulation issue.
  4. Reference the first image.jpg from one entry and the second image.jpg from another entry.
  5. Save both entries.
  6. Run Developer > Utilities > Update File Usage (or run php system/ee/eecli.php sync:file-usage).
  7. View the usage count/details for each file.

Reported result: both files show zero usage.

Expected result: each file is resolved by its unique file ID/upload location and shows the entry that references it.

Error Messages

No error is displayed. Both usage counts remain zero.

Screenshots / Videos / Template Code

Not currently available.

Environment Details:

  • Version: ExpressionEngine 7; exact installed patch version pending confirmation
  • PHP Version: pending confirmation
  • MySQL Version: pending confirmation
  • OS: pending confirmation
  • Web Server: pending confirmation

Possible Solution

First confirm the raw Grid cell values and corresponding database records:

  • exp_files.file_id
  • exp_files.upload_location_id
  • exp_files.file_name
  • the value stored in exp_channel_grid_field_*
  • matching rows, if any, in exp_file_usage

The current rebuild query groups each lookup by both upload_location_id and file_name, so two top-level files in different upload locations should be distinguishable. If both still resolve to zero, the failure likely occurs before or after filename matching rather than being a simple basename collision.

Coverage should use two top-level files with the same basename in different upload destinations and assert that each produces the correct (file_id, entry_id) relationship.

Additional context

This report intentionally excludes subfolders. Files located in subfolders exercise different path-resolution logic and should be investigated separately if needed.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bug: UnconfirmedBug report that is not yet confirmed and/or is not reproducible.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions