DDC-615: Single table inhertiance not working when base class is/starts-with "Module" #755

Closed
opened 2026-01-22 12:49:17 +01:00 by admin · 7 comments
Owner

Originally created by @doctrinebot on GitHub (May 28, 2010).

Originally assigned to: @jwage on GitHub.

Jira issue originally created by user garrett:

While trying to get single table inheritance working we ran into the following: Single table inheritance works fine as long as the base class that's extended isn't named "Module" or doesn't start with "Module" (e.g. ModuleBase, Moduleabcdefg). Using any other file/class name not starting with "Module" works:

Module.php
========================
<?php
namespace App\Entities;

/****
 * @Entity
 * @InheritanceType("SINGLE_TABLE")
 * @DiscriminatorColumn(name="discr", type="string")
 * @DiscriminatorMap({"module" = "Module", "blog" = "Blog"})
 */
class Module
{
    /*** @Id @Column(type="string", length=32) **/
    private $id;

    /*** @Id @Column(type="string", length=32) **/
    private $name;
}

Blog.php
========================
<?php
namespace App\Entities;

/****
 * @Entity
 */
class Blog extends Module
{
     //...
}

Running: php ./doctrine orm:schema-tool:create results in:

PHP Fatal error:  Class 'App\Entities\Module' not found in [path] on line [line]

... change Module.php to SystemModule.php and extend that...everythings fine.

Originally created by @doctrinebot on GitHub (May 28, 2010). Originally assigned to: @jwage on GitHub. Jira issue originally created by user garrett: While trying to get single table inheritance working we ran into the following: Single table inheritance works fine as long as the base class that's extended isn't named "Module" or doesn't start with "Module" (e.g. ModuleBase, Moduleabcdefg). Using any other file/class name not starting with "Module" works: ``` Module.php ======================== <?php namespace App\Entities; /**** * @Entity * @InheritanceType("SINGLE_TABLE") * @DiscriminatorColumn(name="discr", type="string") * @DiscriminatorMap({"module" = "Module", "blog" = "Blog"}) */ class Module { /*** @Id @Column(type="string", length=32) **/ private $id; /*** @Id @Column(type="string", length=32) **/ private $name; } Blog.php ======================== <?php namespace App\Entities; /**** * @Entity */ class Blog extends Module { //... } ``` Running: php ./doctrine orm:schema-tool:create results in: ``` PHP Fatal error: Class 'App\Entities\Module' not found in [path] on line [line] ``` ... change Module.php to SystemModule.php and extend that...everythings fine.
admin added the Bug label 2026-01-22 12:49:17 +01:00
admin closed this issue 2026-01-22 12:49:17 +01:00
Author
Owner

@doctrinebot commented on GitHub (May 29, 2010):

Comment created by romanb:

That sounds weird. Are you using Symfony (2) with Doctrine2Bundle? There is no specific treatment of classes with certain names within Doctrine that I can think of.

@doctrinebot commented on GitHub (May 29, 2010): Comment created by romanb: That sounds weird. Are you using Symfony (2) with Doctrine2Bundle? There is no specific treatment of classes with certain names within Doctrine that I can think of.
Author
Owner

@doctrinebot commented on GitHub (Jun 1, 2010):

Comment created by garrett:

Seems weird to me to.

I'm using the version that gets included when downloading via:

svn co http://svn.github.com/doctrine/doctrine2.git doctrine2-orm

... not sure how to determine the exact version. Looked for some files that might indicate the version in the Symfony directory (README, Version.txt, etc.) and none exist. Did a grep and that didn't produce any results either.

@doctrinebot commented on GitHub (Jun 1, 2010): Comment created by garrett: Seems weird to me to. I'm using the version that gets included when downloading via: ``` svn co http://svn.github.com/doctrine/doctrine2.git doctrine2-orm ``` ... not sure how to determine the exact version. Looked for some files that might indicate the version in the Symfony directory (README, Version.txt, etc.) and none exist. Did a grep and that didn't produce any results either.
Author
Owner

@doctrinebot commented on GitHub (Jun 2, 2010):

Comment created by @jwage:

Can you check your Doctrine/ORM/Version.php file?

@doctrinebot commented on GitHub (Jun 2, 2010): Comment created by @jwage: Can you check your Doctrine/ORM/Version.php file?
Author
Owner

@doctrinebot commented on GitHub (Jun 2, 2010):

Comment created by @jwage:

Also, did you try reproducing this in a simpler scenario? i.e. without Symfony? I tried creating a simple test here and I cannot reproduce anything so far.

@doctrinebot commented on GitHub (Jun 2, 2010): Comment created by @jwage: Also, did you try reproducing this in a simpler scenario? i.e. without Symfony? I tried creating a simple test here and I cannot reproduce anything so far.
Author
Owner

@doctrinebot commented on GitHub (Jun 9, 2010):

Comment created by garrett:

Can you check your Doctrine/ORM/Version.php file?

Tried but that file doesn't exist for me. To make sure I was using the proper beta package I've started from scratch and downloaded Doctrine via http://www.doctrine-project.org/downloads/DoctrineORM-2.0.0-BETA1.tgz

The only Version.php file I found was Doctrine/Common/Version.php and the "VERSION" costants value is "2.0-DEV" (That's the same version that gets spit out using "php doctrine -V")

Also, did you try reproducing this in a simpler scenario? i.e. without Symfony?

Yes. And everything worked. I used the SchemaTool class and didn't have any issues.

New Issues

After starting over using the files located at the URL above the problem still exists however it's changed slightly. I still can't extend a class using another class located in a different file (same namespace). If I place both classes in the same file then the cli works. However, unlike my original post it's no longer limited to classes named "Module"; all class names fail now.

Just to make sure I had a clean version of Symfony I grabbed the latest from http://svn.symfony-project.com/branches/2.0 (Rev 29773) and nothing changed..same error.

Not sure if it will help but here's a stack trace:```

php doctrine -v orm:schema-tool:update
PHP Fatal error: Class 'App\Entities\Module' not found in [path] on line [line]
PHP Stack trace:
PHP 1. {main}() /srv/www/projects/test/scripts/doctrine/doctrine:0
PHP 2. include() /srv/www/projects/test/scripts/doctrine/doctrine:4
PHP 3. Symfony\Components\Console\Application->run() /srv/www/projects/test/scripts/doctrine/doctrine.php:41
PHP 4. Symfony\Components\Console\Application->doRun() /srv/www/projects/test/library/Symfony/Components/Console/Application.php:115
PHP 5. Symfony\Components\Console\Command\Command->run() /srv/www/projects/test/library/Symfony/Components/Console/Application.php:186
PHP 6. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() /srv/www/projects/test/library/Symfony/Components/Console/Command/Command.php:152
PHP 7. Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() /srv/www/projects/test/library/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:53
PHP 8. Doctrine\ORM\Mapping\Driver\AnnotationDriver->getAllClassNames() /srv/www/projects/test/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php:99
PHP 9. require_once() /srv/www/projects/test/library/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:454

... I haven't changed the original Entities at all, they are still as described above.

@doctrinebot commented on GitHub (Jun 9, 2010): Comment created by garrett: # Can you check your Doctrine/ORM/Version.php file? Tried but that file doesn't exist for me. To make sure I was using the proper beta package I've started from scratch and downloaded Doctrine via http://www.doctrine-project.org/downloads/DoctrineORM-2.0.0-BETA1.tgz The only Version.php file I found was Doctrine/Common/Version.php and the "VERSION" costants value is "2.0-DEV" (That's the same version that gets spit out using "php doctrine -V") # Also, did you try reproducing this in a simpler scenario? i.e. without Symfony? Yes. And everything worked. I used the SchemaTool class and didn't have any issues. # New Issues After starting over using the files located at the URL above the problem still exists however it's changed slightly. I still can't extend a class using another class located in a different file (same namespace). If I place both classes in the same file then the cli works. However, unlike my original post it's no longer limited to classes named "Module"; all class names fail now. Just to make sure I had a clean version of Symfony I grabbed the latest from http://svn.symfony-project.com/branches/2.0 (Rev 29773) and nothing changed..same error. Not sure if it will help but here's a stack trace:``` > php doctrine -v orm:schema-tool:update > PHP Fatal error: Class 'App\Entities\Module' not found in [path] on line [line] > PHP Stack trace: > PHP 1. {main}() /srv/www/projects/test/scripts/doctrine/doctrine:0 > PHP 2. include() /srv/www/projects/test/scripts/doctrine/doctrine:4 > PHP 3. Symfony\Components\Console\Application->run() /srv/www/projects/test/scripts/doctrine/doctrine.php:41 > PHP 4. Symfony\Components\Console\Application->doRun() /srv/www/projects/test/library/Symfony/Components/Console/Application.php:115 > PHP 5. Symfony\Components\Console\Command\Command->run() /srv/www/projects/test/library/Symfony/Components/Console/Application.php:186 > PHP 6. Doctrine\ORM\Tools\Console\Command\SchemaTool\AbstractCommand->execute() /srv/www/projects/test/library/Symfony/Components/Console/Command/Command.php:152 > PHP 7. Doctrine\ORM\Mapping\ClassMetadataFactory->getAllMetadata() /srv/www/projects/test/library/Doctrine/ORM/Tools/Console/Command/SchemaTool/AbstractCommand.php:53 > PHP 8. Doctrine\ORM\Mapping\Driver\AnnotationDriver->getAllClassNames() /srv/www/projects/test/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php:99 > PHP 9. require_once() /srv/www/projects/test/library/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php:454 > > ``` > ``` ... I haven't changed the original Entities at all, they are still as described above.
Author
Owner

@doctrinebot commented on GitHub (Jun 15, 2010):

Comment created by garrett:

Closing this due to my inability to reproduce on any other installation other than the original install this bug was found on.

@doctrinebot commented on GitHub (Jun 15, 2010): Comment created by garrett: Closing this due to my inability to reproduce on any other installation other than the original install this bug was found on.
Author
Owner

@doctrinebot commented on GitHub (Jun 15, 2010):

Issue was closed with resolution "Cannot Reproduce"

@doctrinebot commented on GitHub (Jun 15, 2010): Issue was closed with resolution "Cannot Reproduce"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#755