diff --git a/lib/config.php b/lib/config.php
index 0bd497b8e50a396758f987ca44ecef66052fd948..c94eb278159164230a7d9e8ea29cca957a5d9627 100644
--- a/lib/config.php
+++ b/lib/config.php
@@ -155,7 +155,11 @@ class OC_Config{
 	 */
 	public static function writeData() {
 		// Create a php file ...
-		$content = "<?php\n\$CONFIG = ";
+		$content = "<?php\n ";
+		if (defined('DEBUG') && DEBUG) {
+			$content .= "define('DEBUG',true);\n";
+		}
+		$content .= "\$CONFIG = ";
 		$content .= var_export(self::$cache, true);
 		$content .= ";\n";