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

2.6 add 'atomic' option to "save()" API - delivery #3604

Merged
merged 1 commit into from
Jun 5, 2014

Conversation

Haititi
Copy link
Contributor

@Haititi Haititi commented May 30, 2014

New PR created for delivery of #3516 .
Due to some branch problem, I had to create another branch for delivery, but the previous PR could not be updated with the new branch.

Moreover, conflicts due to merged commits from #3590 were resolved by me (the author of these commits) to make this new PR easier to merge.

@markstory markstory added this to the 2.6.0 milestone Jun 1, 2014
}
return $success;
}
catch (Exception $e) {
Copy link
Member

Choose a reason for hiding this comment

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

Should be '} catch (... ) {`.

@Haititi
Copy link
Contributor Author

Haititi commented Jun 2, 2014

some weird error appears in travis.
related to some OpenSSL error which make the mysql builds fail...
I don't think it is related to my last commit.
Can someone look at the problem ? Thanks.

@ADmad
Copy link
Member

ADmad commented Jun 2, 2014

That error is unrelated to your changes. It will be taken care of. Can you please squash your commits.

This commit adds a transaction context to 'save()' API in order to rollback
possible modifications done in some 'Model.beforeSave' listener callback.
This will allow cakephp 2.x to behave like 3.0 .
It uses try/catch to better handle transaction.
Previous save() API is renamed to protected _doSave() method.
A new save() method is created for transaction handling.
'atomic' option is disabled for internal 'save()' call.
@Haititi
Copy link
Contributor Author

Haititi commented Jun 3, 2014

I didn't know what 'squash your commits' means, so I hope I didn't do something bad lol.
I merged all my commits into one with these following commands :
git reset --soft HEAD~20
git commit

@ADmad
Copy link
Member

ADmad commented Jun 3, 2014

I merged all my commits into one

Yup that's what i meant, sorry for not being clear enough :)

$transactionBegun = $db->begin();
try {
$success = $this->_doSave($data, $options);
if ($transactionBegun) {
Copy link
Member

Choose a reason for hiding this comment

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

This if is not actually needed, I think. If atomic, it will always evaluate to true

@lorenzo
Copy link
Member

lorenzo commented Jun 3, 2014

Apart from my nitpick, this looks great. Awesome job!

lorenzo added a commit that referenced this pull request Jun 5, 2014
2.6 add 'atomic' option to "save()" API - delivery
@lorenzo lorenzo merged commit 932bf47 into cakephp:2.6 Jun 5, 2014
@markstory
Copy link
Member

I'll update the book.

markstory added a commit to cakephp/docs that referenced this pull request Jun 5, 2014
@Haititi
Copy link
Contributor Author

Haititi commented Jun 5, 2014

first contribution to an opensource project ever.
happy

@dereuromark
Copy link
Member

@Haititi 👏 Nice job!

@rchavik
Copy link
Member

rchavik commented Jun 5, 2014

👏 🍸

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants