Skip to content
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

Deprecation and forward compat for flush #2159

Merged
merged 1 commit into from
Jan 28, 2020

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Jan 26, 2020

We missed this originally. Patch also includes forward compatibility layer so consumers may pass $options as a first argument already. Also there's a chance I should have placed similar code in UnitOfWork::commit although I haven't thought about any legit reason to call it directly instead of DocumentManager::flush so I didn't bother

@malarzm malarzm added the Task label Jan 26, 2020
@malarzm malarzm added this to the 1.3.7 milestone Jan 26, 2020
@malarzm malarzm requested a review from alcaeus January 26, 2020 11:32
}
if (func_num_args() === 2) {
@trigger_error(
'$options will become a first argument in doctrine/mongodb-odm 2.0, you may pass it as first now.',
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure about wording here

E_USER_DEPRECATED
);
}
if (func_num_args() === 2) {
Copy link
Member

Choose a reason for hiding this comment

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

We should only trigger the deprecation notice if documents were passed:

Suggested change
if (func_num_args() === 2) {
elseif (func_num_args() === 2) {

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessarily, $dm->flush(null, $options); will stop working as well and folks can call $dm->flush($options); now

Copy link
Member

Choose a reason for hiding this comment

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

As is, $dm->flush([$document], $options); throws two deprecation warnings. We should make sure this doesn't happen as it might confuse the user.

As I write this, we should also make sure to gracefully handle $dm->flush([], $options); to make sure we don't treat it as the "user passed documents" case.

Copy link
Contributor

Choose a reason for hiding this comment

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

It seems that passing an array of documents is an undocumented feature. I didn't find anything in the documentation and the method signature mentions just one object. Only deep down in the UoW is the check if the parameter is an array. So did anyone even use that?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hard to say, but there's a chance :)

}
if (func_num_args() === 2) {
@trigger_error(
'$options will become a first argument in doctrine/mongodb-odm 2.0, you may pass it as first now.',
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
'$options will become a first argument in doctrine/mongodb-odm 2.0, you may pass it as first now.',
sprintf('Flushing selected documents has been deprecated and will be removed in doctrine/mongodb-odm 2.0. You can omit the first argument to %s.', __METHOD__),

lib/Doctrine/ODM/MongoDB/DocumentManager.php Show resolved Hide resolved
@malarzm malarzm merged commit c80d9c3 into doctrine:1.3.x Jan 28, 2020
@malarzm malarzm deleted the partial-flush-deprecation branch January 28, 2020 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants