Skip to content

Create a GridFS file instead of a collection #486

wants to merge 1 commit into from

2 participants


When using the "odm:schema:create" command it would create a GridFS file collection as a regular collection. This creates the proper GridFS files collection instead.

Doctrine member
jmikola commented Jan 31, 2013

Instantiating the MongoGridFS class doesn't actually create anything on the server. Are you sure this is actually creating a collection, or is it NOP-ing in the case of a file?

Technically, both GridFS collections are normal collections -- they just have a specific naming convention. It may be more reasonable to call createCollection() with the appropriate name (e.g. fs.files).


Without this change, when I run the schema:create command I get these collections created. There shouldn't be an Asset collection.

> show collections

It may be better to explicitly create the Asset.files and Asset.chunks collections, but I assumed the driver handled that automatically when you instantiated MongoGridFS

Doctrine member
jmikola commented Feb 1, 2013

What is actually creating the Asset.files collection? The reason I mention the NOP, is because:


...shouldn't do anything at all on the server-side. It's going to instantiate a MongoGridFS class that quickly falls out of scope in this PHP method. I think it'd be better to simply do:

if ($class->isFile()) {

...between the exception for mapped superclasses and the existing createCollection() call. Otherwise, we could amend the createCollection() code to actually create a *.files collection, but someone is bound to shoot themselves in the foot that way. If you created a capped fs.files collection and it fills up, you're going to end up with orphan chunks in the fs.chunks collection at some point.

@jmikola jmikola added a commit that closed this pull request Apr 1, 2013
@jmikola jmikola Create GridFS collections in SchemaManager (closes #486)
GridFS collections should never use capped collections, so we can ignore those options from ClassMetadataInfo.
@jmikola jmikola closed this in 517e0a5 Apr 1, 2013
Doctrine member
jmikola commented Apr 1, 2013

@MDrollette: Please take a look at 517e0a5. I believe that addresses your concerns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.