Skip to content

[13.x] Alternative: Allow later filesystem disks to override earlier …#59302

Open
sadique-cws wants to merge 1 commit intolaravel:13.xfrom
sadique-cws:fix/filesystem-disk-collision-alternative
Open

[13.x] Alternative: Allow later filesystem disks to override earlier …#59302
sadique-cws wants to merge 1 commit intolaravel:13.xfrom
sadique-cws:fix/filesystem-disk-collision-alternative

Conversation

@sadique-cws
Copy link
Contributor

Problem

When the framework merges base configuration with user configuration via LoadConfiguration, framework-default disks (like local, s3) get deep-merged back into the user's disks array list even if they were intentionally excluded.

If a user-defined disk (e.g., 'private') uses the same driver and root options as the base default disk, both will have serve => true and no explicit url, causing both to claim the /storage URI.

Previously, this condition threw: "The [private] disk conflicts with the [local] disk at [/storage]." This prevents users from defining their own served disks without assigning explicit unique URLs to default disks they don't even intend to use.

Solution

This fix leaves the config merging behavior as-is and addresses the safety limit in FilesystemServiceProvider::serveFiles().

It separates disk collection from route registration:

  1. Pass 1: Collect all serveable disks into a Map keyed by uri path. Since array_merge places user configuration after framework defaults, any duplicate keys deep-merged are overriden by the user-defined items during collection.
  2. Pass 2: Register routes only for the winning disks.

This allows the user-defined disk to silently take precedence over the framework-default disk for that shared URI — exactly what one would expect.

Changes

  • FilesystemServiceProvider::serveFiles() — Separate disk iteration into a Map collections checklist (no exceptions on URI collision) before binding app->booted.
  • FilesystemServiceProviderTest — Updated the conflict test to expect later-item overrides instead of exceptions, and added a specific test for the user-override scenario.

@sadique-cws sadique-cws force-pushed the fix/filesystem-disk-collision-alternative branch from 6370c15 to 0f79fa9 Compare March 23, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant