Skip to content

fix: resolve race condition in get_dir_file_info() when files are deleted concurrently#10406

Closed
gr8man wants to merge 3 commits into
codeigniter4:developfrom
gr8man:test/filesystem-helper-race-condition
Closed

fix: resolve race condition in get_dir_file_info() when files are deleted concurrently#10406
gr8man wants to merge 3 commits into
codeigniter4:developfrom
gr8man:test/filesystem-helper-race-condition

Conversation

@gr8man

@gr8man gr8man commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description
When scanning directories, get_dir_file_info() could encounter a race condition if a file was deleted right after being read by readdir(). In this scenario, get_file_info() would return null, causing an incomplete entry (lacking server_path or other keys) to be added to the result array.

This PR adds a null check to gracefully ignore files deleted mid-scan, which also prevents broken entries from being created when passing directories with $topLevelOnly = true. This fixes random test failures observed in the Commands component. A unit test has been added to ensure the correct behavior.

Checklist:

  • Securely signed commits
  • Component(s) with PHPDoc blocks, only if necessary or adds value (without duplication)
  • Unit testing, with >80% coverage
  • User guide updated
  • Conforms to style guide

gr8man added 3 commits July 13, 2026 20:11
This squashes several fixes regarding Entity::toRawArray returning string values instead of Time objects, addressing issue codeigniter4#8302. It also updates DatetimeCast to handle string values to prevent DataConverter crashes, and applies phpstan, rector, and cs-fix formatting.
@gr8man gr8man force-pushed the test/filesystem-helper-race-condition branch from ecd4a6b to 97baf02 Compare July 13, 2026 18:34
@gr8man gr8man closed this Jul 13, 2026
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