Added `wcfDebug()` support during WCFSetup
authorAlexander Ebert <ebert@woltlab.com>
Fri, 18 Nov 2016 10:53:34 +0000 (11:53 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 18 Nov 2016 10:53:34 +0000 (11:53 +0100)
wcfsetup/install.php

index e5f37d8c08d4361c7c07eb87bd555150028f9547..875ecafd3c428fad29a0f0270737ff222e013f1f 100644 (file)
@@ -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.
  *