Skip to content
This repository was archived by the owner on Nov 11, 2020. It is now read-only.

Fix BC break when converting expression objects #298

Merged

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Jul 18, 2017

This was introduced in #292 by adding a convertExpression method and using that in the expression operator methods. Unfortunately, MongoDB ODM relied on the ensureArray method being called to do the type conversion, which is no longer the case since all methods call convertExpression.

* @param mixed|self $expression
* @return string|array
*/
protected function convertExpression($expression)
Copy link
Member Author

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?

Copy link
Member

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.
Copy link
Member

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, will update.

@alcaeus alcaeus added this to the 1.6.0 milestone Aug 6, 2017
@alcaeus alcaeus force-pushed the fix-aggregation-expression-conversion branch from 388b478 to 2ce9496 Compare August 6, 2017 14:25
@alcaeus alcaeus force-pushed the fix-aggregation-expression-conversion branch from 2ce9496 to 46e5029 Compare August 8, 2017 05:35
@alcaeus alcaeus merged commit 9ad5ca3 into doctrine:master Aug 9, 2017
@alcaeus alcaeus deleted the fix-aggregation-expression-conversion branch August 9, 2017 13:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants