Ejemplo n.º 1
0
 /**
  * Outputs a stack trace based on the supplied options.
  *
  * ### Options
  *
  * - `depth` - The number of stack frames to return. Defaults to 50
  * - `start` - The stack frame to start generating a trace from. Defaults to 1
  *
  * @param array $options Format for outputting stack trace
  * @return mixed Formatted stack trace
  * @link https://github.com/cakephp/cakephp/blob/master/src/basics.php
  */
 function stackTrace(array $options = array())
 {
     if (!WP_DEBUG) {
         return;
     }
     $defaults = array('start' => 0);
     if (Strata::isBundledServer() || Strata::isCommandLineInterface()) {
         $defaults['output'] = Debugger::CONSOLE;
     }
     $options += $defaults;
     $options['start']++;
     $trace = Debugger::trace(null, $options);
     if (Strata::isBundledServer()) {
         Strata::app()->getLogger("StrataConsole")->debug("\n\n" . $trace . "\n\n");
     }
     if (Strata::isCommandLineInterface()) {
         echo "\n\n" . $trace . "\n\n";
     } else {
         echo "<div style=\"" . Debugger::HTML_STYLES . "\"><pre>" . $trace . "</pre></div>";
     }
 }
Ejemplo n.º 2
0
 /**
  * Fetches the terms matching the TaxonomyQuery.
  * @return array
  */
 public function fetch()
 {
     $this->logQueryStart();
     $results = null;
     if (is_array($this->termLookupMode)) {
         $queryLog = "get_term_by(" . Debugger::export($this->termLookupMode[0]) . ", " . Debugger::export($this->termLookupMode[1]) . ", " . Debugger::export($this->taxnomony) . ")";
         $results = get_term_by($this->termLookupMode[0], $this->termLookupMode[1], $this->taxnomony);
     } elseif (is_null($this->postId)) {
         $queryLog = "get_terms(" . Debugger::export($this->taxnomony) . ", " . Debugger::export($this->filters) . ")";
         $results = get_terms($this->taxnomony, $this->filters);
     } else {
         $queryLog = "get_the_terms(" . Debugger::export($this->postId) . ", " . Debugger::export($this->taxnomony) . ", " . Debugger::export($this->filters) . ")";
         $results = get_the_terms($this->postId, $this->taxnomony, $this->filters);
     }
     $this->logQueryCompletion($queryLog);
     if ($results === false) {
         return array();
     }
     if (!is_array($results)) {
         $results = array($results);
     }
     return $results;
 }
Ejemplo n.º 3
0
 /**
  * Used to express the contents of the model entity more clearly
  * when debugged.
  * @return array
  */
 public function __debugInfo()
 {
     $objectVars = array();
     if (!is_null($this)) {
         foreach (get_object_vars($this) as $key => $value) {
             $objectVars[$key] = Debugger::export($value);
         }
     }
     return array_merge($objectVars, $this->toArray());
 }
Ejemplo n.º 4
0
 /**
  * Handle uncaught exceptions.
  *
  * Uses a template method provided by subclasses to display errors in an
  * environment appropriate way.
  *
  * @param \Exception $exception Exception instance.
  * @return void
  * @throws \Exception When renderer class not found
  * @see http://php.net/manual/en/function.set-exception-handler.php
  */
 public function handleException($exception)
 {
     if (!$this->canCatchTheError($exception->getFile())) {
         return;
     }
     $data = array('type' => "Exception", 'code' => $exception->getCode(), 'description' => $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'context' => null, 'trace' => Debugger::trace($exception->getTrace()));
     $this->displayExceptionData($data);
     $this->logExceptionData($data);
     $this->endProcesses();
 }