-
Notifications
You must be signed in to change notification settings - Fork 232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Collections are not created in new Mongo 2.6 #239
Comments
I found the root of the problem:
Of course the right fix would be that MongoDB createCollection function checks its params for being integer and not null, but until then, my fixes are (either one or both):
My choice is solution 1, but I would like this fix to be done in MongoDB createCollection, there where the root is. |
@bogdanmt: Can you quickly test if adding public function createCollection($name, $cappedOrOptions = false, $size = 0, $max = 0)
{
$options = is_array($cappedOrOptions)
? array_merge(array('capped' => false, 'size' => 0, 'max' => 0), $cappedOrOptions)
: array('capped' => (boolean) $cappedOrOptions, 'size' => (int) $size, 'max' => (int) $max);
// ...
} |
That was my first thought too, but actually it was not enough. At that time I didn't took a closer look why. The reason is the variable $cappedOrOptions, which comes as an array having keys "size" and "max" NULL. In this line of code it goes with the merge, thus overwriting the zeros and leaving NULL for those keys: My fix, in order to cover both cases is to write immediatelly after: This I tested and it works fine. |
Would be great to have an official fix, even below ODM. We could rely on composer install again. |
MongoDB 2.6 complains if the size/max options are non-numeric (e.g. null). See: doctrine/DoctrineMongoDBBundle#239
Tagged doctrine/mongodb 1.1.6, which should address this. |
I confirm it works. Good job! |
You probably want a quick and concise email...
Mongo released this last Tue (April 8, 2014) the new version 2.6;
Your Symfony2 DoctrineMongoDBBundle FAILS to create collections when "app/console doctrine:mongodb:schema:create" or "app/console doctrine:mongodb:schema:update" are used.
The problem is caused by Mongo 2.6 which, for the collection creation command, does not allow anymore "size=null" and "max=null". Those two nulls have to be changed into numbers (zeros per default) or remove those properties from the command. The result is the same.
Currently, when a collection is created, your command definition is: { create: "SomeName", capped: null, size: null, max: null }
Mongo 2.6, because it wants numbers for "size" and "max", throws the error:
com.mongodb.CommandFailureException: { "serverUsed" : "localhost/127.0.0.1:27017" , "ok" : 0.0 , "errmsg" : "BadValue size has to be a number"}
at com.mongodb.CommandResult.getException(CommandResult.java:71)
at com.mongodb.CommandResult.throwOnError(CommandResult.java:110)
at com.edgytech.umongo.DbJobCmd.doRun(DbJobCmd.java:56)
at com.edgytech.umongo.DbJob$1.doInBackground(DbJob.java:84)
at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at javax.swing.SwingWorker.run(SwingWorker.java:334)
at com.edgytech.swingfast.ScalableThreadPool$ScalableThreadpoolWorker.run(ScalableThreadPool.java:48)
at java.lang.Thread.run(Thread.java:744)
That's it. I hope you'll release a quick fix asap.
Anyway RESPECT FOR YOUR WORK!
The text was updated successfully, but these errors were encountered: