Skip to content

fix: handle null results in get_dir_file_info()#10407

Open
gr8man wants to merge 5 commits into
codeigniter4:developfrom
gr8man:fix-dir-file-info-null
Open

fix: handle null results in get_dir_file_info()#10407
gr8man wants to merge 5 commits into
codeigniter4:developfrom
gr8man:fix-dir-file-info-null

Conversation

@gr8man

@gr8man gr8man commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description
Add null check in get_dir_file_info() for when get_file_info() returns null (race condition: file deleted after readdir() but before get_file_info()). This prevents broken entries and fixes random test failures in Commands. Includes unit test.

Ref: #9968

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

@neznaika0

neznaika0 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

One question - do you not know how to perform git push -f origin? Why do you open duplicate PR files? It's confusing.

On the topic of PR: after reading the directory, can there be a cache in the file system? Take a look at clearstatcache() in PHP. Have you tested this with a real example, I don't see the test you mention.?

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding clearstatcache() would not solve the race because the file could disappear immediately afterward. More importantly, this fixes a deterministic bug: with $topLevelOnly = true, directories produce incomplete entries containing only relative_path.

We need a test, a changelog entry, and a small update to the PR description.

@michalsn michalsn added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 14, 2026
@gr8man

gr8man commented Jul 14, 2026

Copy link
Copy Markdown
Contributor Author

Those older commits were from accidentally staging files to the wrong branch, which led to me creating and then closing a few incorrect PRs. Sorry for the confusion — the current PR #10407 only contains the two relevant commits (fix + test).

@gr8man gr8man requested a review from michalsn July 14, 2026 18:02
@gr8man gr8man force-pushed the fix-dir-file-info-null branch from fb86f72 to 18bdafb Compare July 14, 2026 18:43
@michalsn michalsn changed the title fix: resolve race condition in get_dir_file_info() when files are deleted concurrently fix: handle null results in get_dir_file_info() Jul 15, 2026

@michalsn michalsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a changelog entry.

@gr8man gr8man requested a review from michalsn July 15, 2026 18:21
Comment thread user_guide_src/source/changelogs/v4.7.5.rst Outdated
gr8man and others added 2 commits July 15, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Verified issues on the current code behavior or pull requests that will fix them

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants