-
-
Notifications
You must be signed in to change notification settings - Fork 189
Fix BC break when converting expression objects #298
Fix BC break when converting expression objects #298
Conversation
* @param mixed|self $expression | ||
* @return string|array | ||
*/ | ||
protected function convertExpression($expression) |
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.
Introducing this method is necessary to allow mongodb-odm to override it and convert the expression using classMetadata from the document the aggregation builder is using. This would require us to release this bugfix as 1.6.0 since protected methods in non-final classes are part of the public API. However, I couldn't find a good way to solve this issue without introducing another method. What do you think @jmikola @malarzm?
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.
I concur with a version bump, unfortunate as it is.
* | ||
* For expression objects, it calls getExpression on the expression object. | ||
* For arrays, it recursively calls itself for each array item. Other values | ||
* are returned directly. |
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.
Does this comment still apply? I wonder if it makes more sense to explain the purpose of this method as an extendable hook, rather than repeating the documentation for the method it proxies.
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.
Good point, will update.
388b478
to
2ce9496
Compare
2ce9496
to
46e5029
Compare
This was introduced in #292 by adding a
convertExpression
method and using that in the expression operator methods. Unfortunately, MongoDB ODM relied on theensureArray
method being called to do the type conversion, which is no longer the case since all methods callconvertExpression
.