From 1a2817c43f71b86e3c8082a5b1388452b6c84b3c Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 18 Nov 2016 11:53:34 +0100 Subject: [PATCH] Added `wcfDebug()` support during WCFSetup --- wcfsetup/install.php | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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 "
";
+	
+	$args = func_get_args();
+	$length = count($args);
+	if ($length === 0) {
+		echo "ERROR: No arguments provided.
"; + } + else { + for ($i = 0; $i < $length; $i++) { + $arg = $args[$i]; + + echo "

Argument {$i} (" . gettype($arg) . ")

"; + + if (is_array($arg) || is_object($arg)) { + print_r($arg); + } + else { + var_dump($arg); + } + + echo "
"; + } + } + + $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 "
"; + + exit; +} + /** * Calls the show method on the given exception. * -- 2.20.1