Something went wrong. Try again.
@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
Something went wrong. Try again.
PHP
at commit ff8b4897
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157<?php
/** * @group console */final class DarkConsoleErrorLogPlugin extends DarkConsolePlugin {
public function getName() { $count = count($this->getData()); if ($count) { return pht('Error Log (%d)', $count); } return pht('Error Log'); }
public function getOrder() { return 0; }
public function getColor() { if (count($this->getData())) { return '#ff0000'; } return null; }
public function getDescription() { return pht('Shows errors and warnings.'); }
public function generateData() { return DarkConsoleErrorLogPluginAPI::getErrors(); }
public function renderPanel() { $data = $this->getData();
$rows = array(); $details = array();
foreach ($data as $index => $row) { $file = $row['file']; $line = $row['line'];
$tag = phutil_tag( 'a', array( 'onclick' => jsprintf('show_details(%d)', $index), ), $row['str'].' at ['.basename($file).':'.$line.']'); $rows[] = array($tag);
$details[] = hsprintf( '<div class="dark-console-panel-error-details" id="row-details-%s">'. "%s\nStack trace:\n", $index, $row['details']);
foreach ($row['trace'] as $key => $entry) { $line = ''; if (isset($entry['class'])) { $line .= $entry['class'].'::'; } $line .= idx($entry, 'function', ''); $href = null; if (isset($entry['file'])) { $line .= ' called at ['.$entry['file'].':'.$entry['line'].']'; try { $user = $this->getRequest()->getUser(); $href = $user->loadEditorLink($entry['file'], $entry['line'], ''); } catch (Exception $ex) { // The database can be inaccessible. } }
$details[] = phutil_tag( 'a', array( 'href' => $href, ), $line); $details[] = "\n"; }
$details[] = hsprintf('</div>'); }
$table = new AphrontTableView($rows); $table->setClassName('error-log'); $table->setHeaders(array('Error')); $table->setNoDataString('No errors.');
return phutil_tag( 'div', array(), array( phutil_tag('div', array(), $table->render()), phutil_tag('pre', array('class' => 'PhabricatorMonospaced'), $details), )); }}
/* $data = $this->getData(); if (!$data) { return <x:frag> <div class="mu">No errors.</div> </x:frag>; }
$markup = <table class="LConsoleErrors" />; $alt = false; foreach ($data as $error) { $row = <tr class={$alt ? 'alt' : null} />;
$text = $error['error']; $text = preg_replace('/\(in .* on line \d+\)$/', '', trim($text));
$trace = $error['trace']; $trace = explode("\n", $trace); if (!$trace) { $trace = array('unknown@0@unknown'); }
foreach ($trace as $idx => $traceline) { list($file, $line, $where) = array_merge( explode('@', $traceline), array('?', '?', '?')); if ($where == 'DarkConsole->addError' || $where == 'debug_rlog') { unset($trace[$idx]); } }
$row->appendChild(<th rowspan={count($trace)}>{$text}</th>);
foreach ($trace as $traceline) { list($file, $line, $where) = array_merge( explode('@', $traceline), array('?', '?', '?')); $row->appendChild(<td>{$file}:{$line}</td>); $row->appendChild(<td>{$where}()</td>); $markup->appendChild($row); $row = <tr class={$alt ? 'alt' : null} />; }
$alt = !$alt; }
return <x:frag> <h1>Errors</h1> <div class="LConsoleErrors">{$markup}</div> </x:frag>;*/