Skip to content

fix(cache): resolve a relative cache path against the project root - #528

Open
etienne-scherrer wants to merge 1 commit into
marko-php:developfrom
etienne-org:fix/cache-path-project-root
Open

etienne-scherrer wants to merge 1 commit into
marko-php:developfrom
etienne-org:fix/cache-path-project-root

Conversation

@etienne-scherrer

Copy link
Copy Markdown
Contributor

Summary

CacheConfig::path() returned cache.path as configured, so a relative path resolved against the working directory. That holds on the CLI, which runs from the project root, but PHP-FPM, CGI and mod_php chdir() into public/ before the front controller runs. With the shipped default (storage/cache), the file cache under FPM writes to public/storage/cache: inside the web root, and usually not writable there. Since #509 every login attempt goes through the cache, so this reaches the default marko/cache-file setup.

A relative cache.path now resolves against ProjectPaths::$base, the way CacheDirectoryGuard already resolves the view cache. An absolute path is used as configured.

ProjectPaths is an optional constructor argument, so existing new CacheConfig($repository) calls keep working. The container always injects it, since it resolves class-typed parameters even when they have a default. One test covers that wiring.

Found in an app where the login throttle's cache landed in public/ under FPM; the app currently works around it with an absolute cache.path.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Docs
  • Refactor

Related Issues

None; issues are disabled on this repository.

Checklist

  • Tests pass (./vendor/bin/pest --parallel)
  • Lint passes (./vendor/bin/phpcs)
  • Follows code standards

Run locally in a CI-equivalent container (PHP 8.5 with the extensions CI installs, as a non-root user, with an init process):

  • composer test: 11933 passed, 333 skipped, 0 failed.
  • composer test:integration against Postgres 17, MySQL 8.4 and Redis 7 with MARKO_INTEGRATION_REQUIRED=1: 316 passed, 5 skipped (the MariaDB-only cases); the MySQL suites against MariaDB 11.8 and 10.11: 118 passed each.
  • composer phpstan, phpcs --standard=phpcs.xml and php-cs-fixer --dry-run: clean.
  • The two new path tests fail without the change.

@github-actions github-actions Bot added bug Something isn't working breaking Introduces a breaking change labels Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Introduces a breaking change bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant