doctrine / doctrine/common

Proxy Autoloader: autoloader assumes $notFoundCallback always creates the proxy file

Open
#870 0 comments 0 reactions 0 assignees View on GitHub
Bug
Dominant language
PHP
Stars
5.8k
Forks
284
PR merge metrics
No merged PRs in 30d

Description

I saw this while trying to figure out https://github.com/doctrine/DoctrineBundle/issues/848. In this case, the autoloader was called to load a proxy for a mapped superclass. Since the file didn't exist, the `$notFoundCallback` was called to generate a proxy class. However, the `ProxyFactory` in ORM will skip over mapped superclasses and didn't create a class, but neither threw an exception.

This causes an error because the autoloader wrongly assumes that the file will be present, at least after invoking the `$notFoundCallback`: https://github.com/doctrine/common/blob/master/lib/Doctrine/Common/Proxy/Autoloader.php#L74. However, this assumption is wrong and should probably be checked, with an exception being thrown if no file was generated/found.

Contributor guide

Open the contributing guide

Research direction

Start with lib/Doctrine/Common/Proxy/Autoloader.php at line 74 and trace how the autoloader handles a missing proxy file and invokes $notFoundCallback. Compare that flow with the ORM ProxyFactory behavior for mapped superclasses; the work is done when a callback that creates no file is detected and produces the intended exception rather than continuing with a missing file.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.