From: Alexander Ebert <ebert@woltlab.com>
Date: Fri, 18 Nov 2016 10:53:34 +0000 (+0100)
Subject: Added `wcfDebug()` support during WCFSetup
X-Git-Tag: 3.0.0_Beta_5~29
X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=1a2817c43f71b86e3c8082a5b1388452b6c84b3c;p=GitHub%2FWoltLab%2FWCF.git

Added `wcfDebug()` support during WCFSetup
---

diff --git a/wcfsetup/install.php b/wcfsetup/install.php
index e5f37d8c08..875ecafd3c 100644
--- a/wcfsetup/install.php
+++ b/wcfsetup/install.php
@@ -444,6 +444,45 @@ function escapeString($string) {
 	return \wcf\system\WCF::getDB()->escapeString($string);
 }
 
+/**
+ * Helper method to output debug data for all passed variables,
+ * uses `print_r()` for arrays and objects, `var_dump()` otherwise.
+ */
+function wcfDebug() {
+	echo "<pre>";
+	
+	$args = func_get_args();
+	$length = count($args);
+	if ($length === 0) {
+		echo "ERROR: No arguments provided.<hr>";
+	}
+	else {
+		for ($i = 0; $i < $length; $i++) {
+			$arg = $args[$i];
+			
+			echo "<h2>Argument {$i} (" . gettype($arg) . ")</h2>";
+			
+			if (is_array($arg) || is_object($arg)) {
+				print_r($arg);
+			}
+			else {
+				var_dump($arg);
+			}
+			
+			echo "<hr>";
+		}
+	}
+	
+	$backtrace = debug_backtrace();
+	
+	// output call location to help finding these debug outputs again
+	echo "wcfDebug() called in {$backtrace[0]['file']} on line {$backtrace[0]['line']}";
+	
+	echo "</pre>";
+	
+	exit;
+}
+
 /**
  * Calls the show method on the given exception.
  *