DDC-318: AnnotationDriver::getAllClassNames() can incorrectly return empty array #391

Open
opened 2026-01-22 12:36:55 +01:00 by admin · 0 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 11, 2010).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user bjori:

Calling AnnotationDriver::getAllClassNames() 2 times will result in a wrongly empty array() for the second call.
The only case I can think of where this method actually gets called 2 times is when you are calling multiple doctrine cli tasks from the same PHP process (like, for example, generating the schema and then the proxy files in a deployment script).

Attached is a patch to use a local static variable to skip the get_declared_classes() on subsequent calls.

The quickest example I can think of to demonstrate the issue is to modify the sandbox to call the generate-proxies method 2 times.

Index: doctrine.php
===================================================================
--- doctrine.php    (revision 7149)
<ins></ins><ins> doctrine.php   (working copy)
@@ -9,4 </ins>9,6 @@
 require *_DIR_* . '/cli-config.php';

 $cli = new \Doctrine\Common\Cli\CliController($configuration);
-$cli->run($_SERVER['argv']);
\ No newline at end of file
<ins>$cli->run(array("php", "Orm:generate-proxies", "--class-dir=Entities"));
</ins>$cli->run(array("php", "Orm:generate-proxies", "--class-dir=Entities"));
+

The first run will generate the proxy classes, the second run will say "No classes".

Originally created by @doctrinebot on GitHub (Feb 11, 2010). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user bjori: Calling AnnotationDriver::getAllClassNames() 2 times will result in a wrongly empty array() for the second call. The only case I can think of where this method actually gets called 2 times is when you are calling multiple doctrine cli tasks from the same PHP process (like, for example, generating the schema and then the proxy files in a deployment script). Attached is a patch to use a local static variable to skip the get_declared_classes() on subsequent calls. The quickest example I can think of to demonstrate the issue is to modify the sandbox to call the generate-proxies method 2 times. ``` Index: doctrine.php =================================================================== --- doctrine.php (revision 7149) <ins></ins><ins> doctrine.php (working copy) @@ -9,4 </ins>9,6 @@ require *_DIR_* . '/cli-config.php'; $cli = new \Doctrine\Common\Cli\CliController($configuration); -$cli->run($_SERVER['argv']); \ No newline at end of file <ins>$cli->run(array("php", "Orm:generate-proxies", "--class-dir=Entities")); </ins>$cli->run(array("php", "Orm:generate-proxies", "--class-dir=Entities")); + ``` The first run will generate the proxy classes, the second run will say "No classes".
admin added the Bug label 2026-01-22 12:36:55 +01:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#391