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

Make sure pop() is called when Callback errors in on(...) function #1513

Merged
merged 3 commits into from
Jan 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- fix within() to also restore the working-path when the given callback throws a Exception [#1463]
- `pcntl_fork` is blacklisted per default on ubuntu lts boxes. make sure deployer doesnt emit a warning in this case [#1476]
- Update silverstripe recipe to support silverstripe 4
- Make sure Context::pop() is called when Callback errors in on(...) function [#1513]

## v6.0.5
[v6.0.4...v6.0.5](https://github.com/deployphp/deployer/compare/v6.0.4...v6.0.5)
Expand Down Expand Up @@ -344,6 +345,7 @@
- Fixed typo3 recipe
- Fixed remove of shared dir on first deploy

[#1513]: https://github.com/deployphp/deployer/pull/1513
[#1481]: https://github.com/deployphp/deployer/issues/1481
[#1476]: https://github.com/deployphp/deployer/pull/1476
[#1472]: https://github.com/deployphp/deployer/pull/1472
Expand Down
9 changes: 6 additions & 3 deletions src/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,12 @@ function on($hosts, callable $callback)

foreach ($hosts as $host) {
if ($host instanceof Host) {
Context::push(new Context($host, $input, $output));
$callback($host);
Context::pop();
try {
Context::push(new Context($host, $input, $output));
$callback($host);
} finally {
Context::pop();
}
} else {
throw new \InvalidArgumentException("Function on can iterate only on Host instances.");
}
Expand Down