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

[5.2] Transaction count cannot be negative #14085

Merged
merged 1 commit into from
Jun 21, 2016
Merged

[5.2] Transaction count cannot be negative #14085

merged 1 commit into from
Jun 21, 2016

Conversation

ashleydw
Copy link
Contributor

@ashleydw ashleydw commented Jun 21, 2016

As per ->rollback, the $this->transactions should not go into negative values.

If calling ->commit() without an active transaction will cause the next number to be incorrect.

As per ->rollback, the $this->transactions should not go into negative values.

If calling ->commit() without an active transaction will cause the next number to be incorrect.
@ashleydw ashleydw changed the title Transaction count cannot be negative [5.2] Transaction count cannot be negative Jun 21, 2016
@GrahamCampbell
Copy link
Member

I don't think this is correct. If it goes negative, you should not have called it?

@ashleydw
Copy link
Contributor Author

ashleydw commented Jun 21, 2016

The logic here replicates that in ->rollback():

$this->transactions = max(0, $this->transactions - 1);

The if statements handle cases where developers are incorrectly calling the method (by doing nothing).

@GrahamCampbell
Copy link
Member

We should probably throw an exception here instead. During correct usage, this should never be negative.

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

Successfully merging this pull request may close these issues.

3 participants