use try/finally to make sure working-path restore on Exceptions (#1463)

* use try/finally to make sure working-path restore on Exceptions

* Update functions.php

* Update CHANGELOG.md

* Update CHANGELOG.md

* fixed CS
This commit is contained in:
Markus Staab 2017-12-20 13:19:16 +01:00 committed by Anton Medvedev
parent 4ca0edd47f
commit b8c81fab0e
2 changed files with 9 additions and 3 deletions

View File

@ -3,6 +3,8 @@
## master
[v6.0.5...master](https://github.com/deployphp/deployer/compare/v6.0.5...master)
### Fixed
- fix within() to also restore the working-path when the given callback throws a Exception [#1463]
## v6.0.5
[v6.0.4...v6.0.5](https://github.com/deployphp/deployer/compare/v6.0.4...v6.0.5)
@ -337,6 +339,7 @@
- Fixed remove of shared dir on first deploy
[#1463]: https://github.com/deployphp/deployer/pull/1463
[#1455]: https://github.com/deployphp/deployer/pull/1455
[#1452]: https://github.com/deployphp/deployer/pull/1452
[#1426]: https://github.com/deployphp/deployer/pull/1426

View File

@ -258,9 +258,12 @@ function cd($path)
function within($path, $callback)
{
$lastWorkingPath = get('working_path', '');
set('working_path', parse($path));
$callback();
set('working_path', $lastWorkingPath);
try {
set('working_path', parse($path));
$callback();
} finally {
set('working_path', $lastWorkingPath);
}
}
/**