Skip to content

Include a bootstrap autoloader's located files for real before re-running it - #6291

Closed
ondrejmirtes wants to merge 1 commit into
2.2.xfrom
fix-memoized-bootstrap-autoloader-require
Closed

Include a bootstrap autoloader's located files for real before re-running it#6291
ondrejmirtes wants to merge 1 commit into
2.2.xfrom
fix-memoized-bootstrap-autoloader-require

Conversation

@ondrejmirtes

Copy link
Copy Markdown
Member

The file-read trap's pseudo-include succeeds with dummy data, so a bootstrap autoloader that memoizes a require's result — deptrac's bootstrap.php caches $loader = require .../vendor/autoload.php in a closure static — is left holding an int instead of the class loader, and never retries the require. The run-for-real fallback added in 598faaa then re-runs a permanently broken autoloader, and the class stays unresolvable. On a project using deptrac's contract interfaces this surfaces as:

Internal error: Interface "DEPTRAC_INTERNAL\Symfony\Component\EventDispatcher\EventSubscriberInterface" not found

aborting the analysis (this is also what turned the "other tests" jobs red since 598faaa, e.g. run 33088005533).

The fix: when the located files declare nothing under the wanted name and the redeclare gate allows a real run, include those files for real first — that performs the include the poisoned autoloader can no longer do itself. An autoload-infrastructure file registers its nested class loader, and locating the class again consults it through the file-read trap, so the class is still located statically without executing its file. The existing run-the-autoloaders fallback stays for the class_alias shapes.

The new e2e/bug-15102d mirrors deptrac's memoizing bootstrap shape and fails with interface.notFound without the fix; the existing bug-15102/b/c cases stay green.

🤖 Generated with Claude Code

https://claude.ai/code/session_014fMtimQECyyBNKTmFddr8L

…ning it

The file-read trap's pseudo-include succeeds with dummy data, so a
bootstrap autoloader that memoizes a require's result - deptrac's
bootstrap caches $loader = require .../vendor/autoload.php in a closure
static - is left holding an int instead of the class loader and never
retries the require. The run-for-real fallback then re-runs a permanently
broken autoloader and the class stays unresolvable: on a project using
deptrac's contract interfaces this surfaced as "Internal error: Interface
DEPTRAC_INTERNAL\...\EventSubscriberInterface not found", aborting the
analysis.

When the located files declare nothing under the wanted name and the
redeclare gate allows a real run, include those files for real first -
that performs the include the poisoned autoloader can no longer do
itself. An autoload-infrastructure file registers its nested class
loader, and locating the class again consults it through the file-read
trap, so the class is still found statically.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014fMtimQECyyBNKTmFddr8L
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