DDC-122: Not specifying a Metadata Cache at all leads to fatal error in EM #154

Closed
opened 2026-01-22 12:28:51 +01:00 by admin · 10 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 6, 2009).

Jira issue originally created by user @beberlei:

If for development purposes you dont follow the recommendation to use a Metadata Cache you end up with a fatal error, because the EntityManager sets the null value of the metadata cache to the ClassMetadataFactory which issues a command on it.

Solutions

  1. in ORM Configuration create and return an array cache.
  2. Throw an exception if getMetadataCacheDriverImpl() would return null.
Originally created by @doctrinebot on GitHub (Nov 6, 2009). Jira issue originally created by user @beberlei: If for development purposes you dont follow the recommendation to use a Metadata Cache you end up with a fatal error, because the EntityManager sets the null value of the metadata cache to the ClassMetadataFactory which issues a command on it. Solutions 1. in ORM Configuration create and return an array cache. 2. Throw an exception if getMetadataCacheDriverImpl() would return null.
admin added the Bug label 2026-01-22 12:28:51 +01:00
admin closed this issue 2026-01-22 12:28:52 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2009):

Comment created by @guilhermeblanco:

If no metadata cache is defined, it should always use the array cache.

It should not throw the exception!

@doctrinebot commented on GitHub (Nov 7, 2009): Comment created by @guilhermeblanco: If no metadata cache is defined, it should always use the array cache. It should not throw the exception!
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2009):

Comment created by romanb:

An exception is much better. Just silently using an array cache can hide a serious performance problem... The metadata cache is declared as *REQUIRED* in the documentation, hence you must specify it.

@doctrinebot commented on GitHub (Nov 7, 2009): Comment created by romanb: An exception is much better. Just silently using an array cache can hide a serious performance problem... The metadata cache is declared as **REQUIRED\* in the documentation, hence *you must specify it**.
Author
Owner

@doctrinebot commented on GitHub (Nov 7, 2009):

Comment created by romanb:

ArrayCache is actually *worse than using no metadata cache at all!. Thus we might instead consider turning a metadata cache from *required to recommended. That means, of course, that no exception should be thrown if it is not set.

@doctrinebot commented on GitHub (Nov 7, 2009): Comment created by romanb: ArrayCache is actually **worse than using no metadata cache at all!_. Thus we might instead consider turning a metadata cache from *required_ to *recommended**. That means, of course, that no exception should be thrown if it is not set.
Author
Owner

@doctrinebot commented on GitHub (Nov 16, 2009):

Comment created by romanb:

Not specifying a metadata cache actually works fine for me.

Is this the problematic code you're referring to?

        $this->_cacheDriver = $cacheDriver;
        foreach ($this->_driver->preload() as $className) {
            $cacheKey = "$className\$CLASSMETADATA";
            $this->_cacheDriver->save($cacheKey, $this->getMetadataFor($className), null);
        }

So this would only be problematic in preload mode which we want to remove for A4 anyway. Would that be correct?

@doctrinebot commented on GitHub (Nov 16, 2009): Comment created by romanb: Not specifying a metadata cache actually works fine for me. Is this the problematic code you're referring to? ``` $this->_cacheDriver = $cacheDriver; foreach ($this->_driver->preload() as $className) { $cacheKey = "$className\$CLASSMETADATA"; $this->_cacheDriver->save($cacheKey, $this->getMetadataFor($className), null); } ``` So this would only be problematic in preload mode which we want to remove for A4 anyway. Would that be correct?
Author
Owner

@doctrinebot commented on GitHub (Nov 17, 2009):

Comment created by @beberlei:

yes correct, please remove it :)

@doctrinebot commented on GitHub (Nov 17, 2009): Comment created by @beberlei: yes correct, please remove it :)
Author
Owner

@doctrinebot commented on GitHub (Dec 15, 2009):

Comment created by romanb:

PRELOAD mode removed. ClassMetadataFactory#getAllMetadata introduced.

@doctrinebot commented on GitHub (Dec 15, 2009): Comment created by romanb: PRELOAD mode removed. ClassMetadataFactory#getAllMetadata introduced.
Author
Owner

@doctrinebot commented on GitHub (Dec 15, 2009):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Dec 15, 2009): Issue was closed with resolution "Fixed"
Author
Owner

@doctrinebot commented on GitHub (Dec 16, 2009):

Comment created by @beberlei:

Hm, shouldn't we deprecate and the Respective other File driver options? It seems otherwise the class name has to be specified twice, once as filename, once as attribute in XML or YAML.

@doctrinebot commented on GitHub (Dec 16, 2009): Comment created by @beberlei: Hm, shouldn't we deprecate <entity class=""> and the Respective other File driver options? It seems otherwise the class name has to be specified twice, once as filename, once as attribute in XML or YAML.
Author
Owner

@doctrinebot commented on GitHub (Dec 16, 2009):

Comment created by romanb:

No, I think that is fine. The file drivers just make use of the naming convention in order to not load/parse the file to get at the class name. IMHO the class name should always be present in the mapping document.

@doctrinebot commented on GitHub (Dec 16, 2009): Comment created by romanb: No, I think that is fine. The file drivers just make use of the naming convention in order to not load/parse the file to get at the class name. IMHO the class name should always be present in the mapping document.
Author
Owner

@doctrinebot commented on GitHub (Dec 16, 2009):

Comment created by @beberlei:

But we should at least throw an exception if filename and entity name don't match, this probably kills 95% of support and debugging time in this matter.

@doctrinebot commented on GitHub (Dec 16, 2009): Comment created by @beberlei: But we should at least throw an exception if filename and entity name don't match, this probably kills 95% of support and debugging time in this matter.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#154