Skip to content

Commit

Permalink
clean output buffer for Throwable instead of just Exception (#798)
Browse files Browse the repository at this point in the history
* clean output buffer for Throwable instead of just Exception
  • Loading branch information
wisskid authored Sep 22, 2022
1 parent 1a69f4e commit e1fb2ad
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed
- Output buffer is now cleaned for internal PHP errors as well, not just for Exceptions [#514](https://github.com/smarty-php/smarty/issues/514)

## [3.1.47] - 2022-09-14

### Security
Expand Down
10 changes: 9 additions & 1 deletion libs/sysplugins/smarty_internal_templatebase.php
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,15 @@ private function _execute($template, $cache_id, $compile_id, $parent, $function)
error_reporting($_smarty_old_error_level);
}
return $result;
} catch (Exception $e) {
} catch (Exception $e) { // PHP 5.x specific
while (ob_get_level() > $level) {
ob_end_clean();
}
if (isset($_smarty_old_error_level)) {
error_reporting($_smarty_old_error_level);
}
throw $e;
} catch (Throwable $e) { // For PHP ^7.0 this can also catch Errors
while (ob_get_level() > $level) {
ob_end_clean();
}
Expand Down

0 comments on commit e1fb2ad

Please sign in to comment.