diff --git a/debian/patches/02-php5.4.diff b/debian/patches/02-php5.4.diff
--- /dev/null
@@ -0,0 +1,26 @@
+Description: Fix for PHP 5.4.
+ PHP 5.4 seems to handle ob_end_clean() a bit different than previous
+ versions.
+Author: Sebastian Harl <tokkee@debian.org>
+
+--- a/system/core/Kohana.php
++++ b/system/core/Kohana.php
+@@ -719,7 +719,17 @@ final class Kohana {
+ }
+
+ // Store the Kohana output buffer
+- ob_end_clean();
++ if (($ob_len = ob_get_length()) !== FALSE)
++ {
++ if ($ob_len > 0)
++ {
++ ob_end_flush();
++ }
++ else
++ {
++ ob_end_clean();
++ }
++ }
+ }
+ }
+