-
-
Notifications
You must be signed in to change notification settings - Fork 505
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
[2.0] Replace doctrine/mongodb for mongodb/mongodb and ext-mongodb #1553
Conversation
Thought I'll find the big 🎉 comment here :D |
Hey there! Any update on this PR? I would be glad to help if any help is needed. |
I got bogged down with a bunch of other stuff and haven’t had time to work on this. Work will resume within the next few weeks, starting with finalizing the existing parts. The GridFS support will return at a later date, I’ll focus on getting the driver change done and then worry about GridFS. |
f07e68d
to
fa8edc9
Compare
95a96b8
to
f1ff95a
Compare
52d381c
to
056371b
Compare
It's time for an update:
|
$done = true; | ||
|
||
// Need to check error message because MongoDB 3.0 does not return a code for this error | ||
if ($result['ok'] != 1 && strpos($result['errmsg'], 'please create an index that starts') !== false) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jmikola you might know the answer to this: the legacy driver returned a result object containing the error message for many of those commands, while ext-mongodb seems to throw an exception. Is it safe to remove this type of handling and always rely on exceptions being thrown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can rely on the driver to throw an exception if the command reports { ok: 0 }
. A good example of this is DropCollection::execute()
in PHPLIB, as the server reports { ok: 0 }
if the collection doesn't exist.
I believe this relates to your request for PHPC-578, so that you still have access to the raw command response after such an error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct: the server checks if an index covers the shard key before creation. If there is no suitable index, it will suggest an index that satisfies the requirement through the command result. We used that suggestion to create a new index and tried to enable sharding once more.
I suppose a workaround would be to attempt creating an index for the fields in the shard key (not sure if field order is relevant here) before sharding the collection.
09c19e9
to
52e1680
Compare
May I help something with tests here? 😅 |
I've been sick the past few days, which is why there wasn't any progress. I'll clean this up in the next couple of weeks and merge it down to odm-ng, including all BC breaks, temporarily broken stuff, etc. Once that's done, we'll have to tie up loose ends (e.g. re-adding GridFS support), remove a bunch of deprecated features, and so on. I'll create issues for all things to be done once I'm done with this pull request. |
@alcaeus Okay men. Get well soon! |
0bf9a82
to
81b189f
Compare
…ethod in references
The tests currently fail because of a missing feature in ext-mongodb. Skipping the tests is the best way to solve this for now.
89681a3
to
ff07011
Compare
Last update before merging:
I believe it's more sensible to update these tests once this pull request has been merged: they don't affect the features (except maybe for bugs that we'll only catch later), so there's no point keeping a PR with this amount of changes open. As for features, I've created issues to cover features that were dropped in this pull request or are not completely taken care of:
Merging this pull request allows multiple people to work on this and makes it easier to apply changes like #1691 and #1692 without constantly having to rebase multiple branches. Once this pull request has been merged, |
|
These helpers were originally removed when porting Doctrine MongoDB's query builder over to ODM (#1553 for 2.0.0-beta1); however, some traces remained in the public API, docs, and test suite.
These helpers were originally removed when porting Doctrine MongoDB's query builder over to ODM (doctrine#1553 for 2.0.0-beta1); however, some traces remained in the public API, docs, and test suite.
These helpers were originally removed when porting Doctrine MongoDB's query builder over to ODM (doctrine#1553 for 2.0.0-beta1); however, some traces remained in the public API, docs, and test suite.
These helpers were originally removed when porting Doctrine MongoDB's query builder over to ODM (doctrine#1553 for 2.0.0-beta1); however, some traces remained in the public API, docs, and test suite.
Note: update below.
This PR serves as the discussion point for most of the changes required by migrating from
ext-mongo
toext-mongodb
. In many instances, the replacement is rather painless, but there are a few heavy BC breaks involved. Note: the following lists are not exhaustive and may be expanded depending on the progress:The current state is:
Doctrine\MongoDB\Query\Builder
andDoctrine\MongoDB\Aggregation\Builder
.mapReduce
orgroup
currently don't work yet due to the query builder only receiving a collection object, which doesn't have any helpers for those methods. We'll have to figure out a solution when dropping doctrine/mongodb.An incomplete list of BC breaks:
slaveOkay
is dropped completely - this should be handled viareadPreference
readPreference
is no longer given as string and an optional array but instead a value object. Same goes forwriteConcern
.metadata
embedded document. We'll need to figure out how to handle that BC break as it's a big one.Cursors can only be iterated over once. There's PHPLIB-81: Add caching iterator mongodb/mongo-php-library#327 which aims to add an iterator that allows multiple iterations of cursors (similar toEagerCursor
)There is a BC break in inverse collections usingrepositoryMethod
- the method may no longer return an iterator but must return a query builder. This is because the new cursors cannot be sorted like old cursors.repositoryMethod
can no longer be combined with theskip
,limit
andsort
options. These have to be handled in therepositoryMethod
directly.Along with these BC breaks, there are a few things left to figure out:
typemap
setting on the driver needs to be set correctly, we might not want to deal with arrays, but there's a potential performance issue with usingBSONDocument
andBSONArray