Skip to content

fix(config): don't follow a symlink cycle in a ** pattern - #14559

Open
jirkace wants to merge 2 commits into
vimeo:masterfrom
jirkace:fix/11722-glob-symlink-cycle
Open

jirkace wants to merge 2 commits into
vimeo:masterfrom
jirkace:fix/11722-glob-symlink-cycle

Conversation

@jirkace

@jirkace jirkace commented Nov 21, 2026

Copy link
Copy Markdown
Contributor

A ** pattern in the config follows a symlink that points back to a parent directory forever, and Psalm stops with a config error.

Before

vendor/some/package/tests-app/example/vendor/some/package -> ../../../../

<ignoreFiles>
    <directory name="**/**/vendor" />
</ignoreFiles>
Problem parsing psalm.xml:
  In <projectFiles>: Could not resolve config path to .../**/**/vendor:0

After: the directories a cycle reaches again are not searched again, and the config loads (ConfigTest::testRecursiveWildcardDoesNotFollowASymlinkCycle).

Fixes #11722

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jirkace

jirkace commented Nov 21, 2026

Copy link
Copy Markdown
Contributor Author

Behaviour change

  • FileFilter::recursiveGlob() keeps the real directories it has searched for the rest of the pattern and skips one it reaches again through a symlink, so a symlink cycle no longer recurses until glob()'s 1024-character limit. On current master the cycle shows up as Could not resolve config path to .../**/**/vendor (the issue reported the underlying glob(): Pattern exceeds the maximum allowed length error).
  • Unchanged: symlinks that don't form a cycle are still followed; testIgnoreRecursiveDoubleWildcardProjectFiles, testIgnoreRecursiveWildcardProjectDirectory, testIgnoreWildcardProjectDirectory and testIgnoreSymlinkedProjectDirectory pass.
  • The new test builds the issue's layout in a temp dir (skipped on Windows, like the other symlink test) and fails on master with that config error. Also checked from the CLI on such a project: master fails, the branch loads the config. The @mutation-free tag of the helper is gone, as it now writes the visited set through a reference.
  • Verified: full self-analysis (only the two local-environment MixedArgument in PoolEventLoopDriverTest, same as master). PHPUnit suite: not run locally, CI runs it.

@github-actions

github-actions Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

✅ Performance: unchanged · Types: unchanged

Project Memory (MB) Wall (s) Issues Weighted (types) Taint Dead code
✅ laravel 1 772 111.6 $\color{gray}{\textsf{-1.8\%}}$ 25 792 53 100 743 0
✅ symfony 3 619 175.9 $\color{gray}{\textsf{-0.1\%}}$ 51 767 100 629 1 582 0
✅ doctrine-orm 381 24.0 $\color{gray}{\textsf{-1.3\%}}$ 3 459 6 218 0 0
✅ psl 618 28.2 $\color{gray}{\textsf{+0.6\%}}$ 1 387 5 600 1 0
✅ phpunit 456 20.3 $\color{gray}{\textsf{-0.2\%}}$ 1 735 3 418 18 0
✅ php-parser 226 13.7 $\color{gray}{\textsf{-0.6\%}}$ 17 116 21 187 0 0
✅ tempest 898 36.9 $\color{gray}{\textsf{+0.4\%}}$ 5 094 10 556 275 0
✅ amphp-amp 48 1.6 29 49 0 0
✅ webmozarts-assert 274 4.9 $\color{gray}{\textsf{-0.6\%}}$ 575 2 714 0 0
✅ guzzle-promises 46 1.7 $\color{gray}{\textsf{+1.8\%}}$ 155 433 2 0
✅ monolog 136 6.3 $\color{gray}{\textsf{+1.8\%}}$ 918 2 491 11 0
✅ drupal 4 847 243.9 $\color{gray}{\textsf{-0.4\%}}$ 97 949 169 915 575 0
✅ wordpress 2 061 136.5 $\color{gray}{\textsf{-0.5\%}}$ 143 633 678 503 505 1
Total 15 381 805.4 $\color{gray}{\textsf{-0.5\%}}$ 349 609 1 054 813 3 712 1
How to read this table
  • Memory: Psalm's own peak figure, threads=1. More than +5 % fails, unless the PR changes composer.json.
  • Wall: base and head run on the same runner; ±10 % is noise. Above +10 % warns, never fails. re-run: a reversed second run was taken and the faster kept.
  • Issues: head count over all categories, then $\color{red}{\textsf{+added}}$ $\color{green}{\textsf{-removed}}$ against base.
  • Weighted (types): type issues weighted by error level (levels 1–8 as is, always-errors 10, strictness checks 1). Taint and dead-code issues are not weighed. The projects' own code is pinned and their dependencies resolve identically for base and head, so a change means Psalm reports more, fewer or differently serious issues. A rise is not necessarily a regression.
  • Taint: head count of Tainted* issues, then $\color{orange}{\textsf{+added}}$ $\color{orange}{\textsf{-removed}}$ against base. Both are orange as either direction needs review: more can be new detection or false positives, fewer can be fixed false positives or lost detection.
  • Dead code: head count of unused-code issues, shown only when a run reported some (findUnusedCode). More is red, fewer is green.
  • Total: sum over the projects compared on both sides. Its wall time warns above +5 % (±5 % is noise); the other thresholds apply per project.
  • Colors: $\color{red}{\textsf{red}}$ past a fail or warn threshold (or more issues), $\color{green}{\textsf{green}}$ an improvement past noise (or fewer issues), $\color{orange}{\textsf{orange}}$ needs review, $\color{gray}{\textsf{gray}}$ noise.
  • Performance: regressed if a head run crashed or timed out or a memory or wall delta is red, else improved if one is green, else unchanged. Its icon is the check result: ❌ fail · ⚠️ warn · ✅ pass; the icon next to each project is that project's result, 💥 = not comparable: base crashed or timed out (counts as ⚠️).
  • Types (heading): direction of the total weighted change, increased · decreased · unchanged. Taint and Dead code (heading): added and removed counts, present only when non-zero. Informational, never fails the check.

head cd5926c · base b5ea40d (merge-base) · workflow run

@jirkace

jirkace commented Nov 22, 2026

Copy link
Copy Markdown
Contributor Author

Review findings of the triage report (head d999075), checked:

  • Not reproduced: "a non-cyclic alias (vendor/acme/foo -> ../../packages/foo) is matched only for whichever directory is met first, so ** patterns match fewer directories". I built that tree (packages/foo/x/a.php plus the alias) and called FileFilter::recursiveGlob() with **/x (directories) and **/x/a.php (files) on this branch and on master. The last step of the recursion returns realpath() of every match, so master returns only /…/packages/foo/x (5 times) and never the alias path; this branch returns the same path 3 times. The set of matched paths is the same.
  • Not changed, minor: one realpath() per searched directory is added to each ** expansion. The test asserts isInProjectDirs() and not the glob result itself.

No code change. Not run: the full suite (CI runs it).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

recursiveGlob follows symlinks without cycle detection, crashes with glob pattern length error

1 participant