From 12f1adb7bbdd1bfcab0df93a998909d85f650454 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Thu, 14 Apr 2016 11:22:38 +0200 Subject: [PATCH] Properly handle exception within templates * fixes partial printed templates when exception is thrown in between --- lib/private/template/base.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/private/template/base.php b/lib/private/template/base.php index 72abc38c36..2c745b02a1 100644 --- a/lib/private/template/base.php +++ b/lib/private/template/base.php @@ -168,8 +168,13 @@ class Base { // Include ob_start(); - include $file; - $data = ob_get_contents(); + try { + include $file; + $data = ob_get_contents(); + } catch (\Exception $e) { + @ob_end_clean(); + throw $e; + } @ob_end_clean(); // Return data