Skip to content

Fix undefined $subs crash in showAllDirFiles() with flat view + load-… - #246

Merged
michael-o merged 1 commit into
masterfrom
fix-showAllDirFiles-undefined-subs
Sep 10, 2026
Merged

Fix undefined $subs crash in showAllDirFiles() with flat view + load-…#246
michael-o merged 1 commit into
masterfrom
fix-showAllDirFiles-undefined-subs

Conversation

@michael-o

Copy link
Copy Markdown
Member

…all-repos

showAllDirFiles() referenced $subs to build the ".." parent-directory entry in flat view, but never received or computed it itself. The variable is only ever assigned in showTreeDir(), on the code path that calls showDirFiles() instead -- showTreeDir() returns early via showAllDirFiles() whenever $config->showLoadAllRepos() is enabled, before $subs is ever set.

setLoadAllRepos(true) and useFlatView() are independent, both documented config options, so enabling both together is a legitimate configuration. On PHP 8.0+ (this project's floor), count(null) throws a TypeError instead of the silent PHP 7 warning, so any directory listing deeper than the repository root crashed outright under that combination.

Compute $subs locally from $path, the same way showTreeDir() does, instead of relying on a value only ever set on a code path this function is never reached from.

@michael-o michael-o added this to the 2.9.0 milestone Sep 2, 2026
@michael-o michael-o self-assigned this Sep 2, 2026
…all-repos

showAllDirFiles() referenced $subs to build the ".." parent-directory
entry in flat view, but never received or computed it itself. The
variable is only ever assigned in showTreeDir(), on the code path that
calls showDirFiles() instead -- showTreeDir() returns early via
showAllDirFiles() whenever $config->showLoadAllRepos() is enabled,
before $subs is ever set.

setLoadAllRepos(true) and useFlatView() are independent, both
documented config options, so enabling both together is a legitimate
configuration. On PHP 8.0+ (this project's floor), count(null) throws
a TypeError instead of the silent PHP 7 warning, so any directory
listing deeper than the repository root crashed outright under that
combination.

Compute $subs locally from $path, the same way showTreeDir() does,
instead of relying on a value only ever set on a code path this
function is never reached from.
@michael-o
michael-o force-pushed the fix-showAllDirFiles-undefined-subs branch from 684aa13 to 539dbcf Compare September 10, 2026 15:48
@michael-o
michael-o merged commit 539dbcf into master Sep 10, 2026
@michael-o
michael-o deleted the fix-showAllDirFiles-undefined-subs branch September 10, 2026 15:49
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