[14.x] Fix faking the on-demand disk hijacking scoped and read-through disks

Merged
SU
18d ago
+19-3

Since #61378, build() returns the ondemand disk when it has been faked. Scoped disks and read-through disks with inline config are created through build() internally, so faking the on-demand disk also replaces them, and the scoped prefix is lost:

Storage::fake('ondemand');

Storage::disk('avatars')->put('me.png', $contents); // written to the root of the ondemand fake, not avatars/me.png

This resolves those child disks directly, the same way they're resolved on 13.x, so only direct Storage::build() calls pick up the fake. A scoped disk can still be faked by name with Storage::fake('avatars').