Skip to content

Create missing parent folders for the file rate limiter path #585

Closed

Description

@armanist

Summary

FileRateLimitAdapter creates its storage folder with a non-recursive mkdir. When the configured path points to a folder whose parent does not exist, every request that goes through the rate limit middleware fails with a 500.

Current state (checked on master)

  • FileRateLimitAdapter::__construct() calls $this->fs->makeDirectory($this->path) when path is not a directory (src/RateLimit/Adapters/FileRateLimitAdapter.php:46).
  • LocalFileSystemAdapter::makeDirectory() returns mkdir($dirname), which does not create parent folders (src/Storage/Adapters/Local/LocalFileSystemAdapter.php:27).
  • ViewCache already creates its folder recursively: mkdir($this->cacheDir, 0777, true) (src/ResourceCache/ViewCache.php:68).
  • With path set to base_dir()/cache/data and no cache/ folder, the first request fails with mkdir(): No such file or directory. The starter project hit this on a fresh install (Align the project with framework 3.1 and fix the fresh-install API 500 project#203).

Proposed change

Create the whole path in FileRateLimitAdapter, with a recursive mkdir as ViewCache does. Nothing else changes: the shared makeDirectory() contract, which also has the Dropbox and Google Drive adapters, stays as it is.

Breaking changes

None. A path that already exists, or whose parent exists, behaves exactly as before.

Tests (first)

  • In FileRateLimitAdapterTest: construct the adapter with a path whose parent folders do not exist and assert that the full path is created. Red on master, green after the change.

Acceptance criteria

  • Constructing FileRateLimitAdapter with a path that has missing parents creates the whole path.
  • The existing rate limiter tests pass unchanged.
  • composer test, composer cs:check and composer phpstan pass.

Out of scope

  • Making LocalFileSystemAdapter::makeDirectory() recursive for all callers (CronLock, ModuleManager, the console commands). That changes a shared primitive and needs its own decision.
  • Throwing a clear error when the folder cannot be created at all (for example, permissions).

Activity

  1. added this to the 3.1.0 milestone on Oct 19, 2026
  2. added a commit that references this issue on Oct 19, 2026
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

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions