Skip to content

A Stache file deleted while it is being traversed or read aborts the traversal or is rebuilt as an empty item #15902

Closed

Description

@joshdaugherty

Bug description

A file deleted while the Stache is traversing or reading it either aborts the traversal or is rebuilt as a new, empty item.

When a content file is removed between the moment the Stache lists it and the moment it stats or reads it, the result is:

  • Traverser::traverse(): RuntimeException: SplFileInfo::getMTime(): stat failed for ..., aborting the whole traversal.
  • Store::paths(), Store::getItemFromModifiedPath(), BasicStore::getItem() and the three taxonomy-term equivalents: File::get() returns null for the vanished file and the item is built from no contents, so the Stache records a new, empty item for a file that no longer exists.

Present on 6.40.0 and on current 6.x (9d20aef), where the traverser has no guard around getMTime(), and the stores pass File::get()'s result straight to makeItemFromFile().

Expected: a file that is confirmed gone is skipped. A real permission or IO error still throws.

How to reproduce

  1. Let the Stache list a content directory.
  2. Delete one of the listed files before the Stache stats or reads it (a test can do this by removing the file between the listing and the getMTime() call).
  3. Observe the RuntimeException from Traverser::traverse(), or a new empty item for the deleted file from the stores listed above.

Regression tests for each case are in the pull request that follows.

Logs

RuntimeException: SplFileInfo::getMTime(): stat failed for ...

Environment

Statamic: 6.40.0 (also current 6.x, 9d20aef)

Found by reading the package source and reproducing it in the package's own test suite, not on a running site, so the full php please support:details output is not available.

Installation

Other (please explain): reproduced in the statamic/cms test suite.

Additional details

A fix that skips a file only when a fresh scandir() of its directory confirms it is gone is in the pull request that follows, with regression tests.

Activity

  1. duncanmcclean commented on Nov 14, 2026

    @duncanmcclean
    Member

    In the future, please open issues using our issue template. Issues created without them aren't categorised correctly and may be missing crucial details useful in closing the issue.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions