@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
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Remove some ancient daemon log code

Summary:
Ref T13253. Long ago, daemon logs were visible in the web UI. They were removed because access to logs generally does not conform to policy rules, and may leak the existence (and sometimes contents) of hidden objects, occasionally leak credentials in certain error messages, etc.

These bits and pieces were missed.

Test Plan: Grepped for removed symbols.

Reviewers: amckinley

Reviewed By: amckinley

Maniphest Tasks: T13253

Differential Revision: https://secure.phabricator.com/D20199

-183
-4
src/__phutil_library_map__.php
··· 2860 2860 'PhabricatorDaemonLog' => 'applications/daemon/storage/PhabricatorDaemonLog.php', 2861 2861 'PhabricatorDaemonLogEvent' => 'applications/daemon/storage/PhabricatorDaemonLogEvent.php', 2862 2862 'PhabricatorDaemonLogEventGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonLogEventGarbageCollector.php', 2863 - 'PhabricatorDaemonLogEventViewController' => 'applications/daemon/controller/PhabricatorDaemonLogEventViewController.php', 2864 - 'PhabricatorDaemonLogEventsView' => 'applications/daemon/view/PhabricatorDaemonLogEventsView.php', 2865 2863 'PhabricatorDaemonLogGarbageCollector' => 'applications/daemon/garbagecollector/PhabricatorDaemonLogGarbageCollector.php', 2866 2864 'PhabricatorDaemonLogListController' => 'applications/daemon/controller/PhabricatorDaemonLogListController.php', 2867 2865 'PhabricatorDaemonLogListView' => 'applications/daemon/view/PhabricatorDaemonLogListView.php', ··· 8725 8723 ), 8726 8724 'PhabricatorDaemonLogEvent' => 'PhabricatorDaemonDAO', 8727 8725 'PhabricatorDaemonLogEventGarbageCollector' => 'PhabricatorGarbageCollector', 8728 - 'PhabricatorDaemonLogEventViewController' => 'PhabricatorDaemonController', 8729 - 'PhabricatorDaemonLogEventsView' => 'AphrontView', 8730 8726 'PhabricatorDaemonLogGarbageCollector' => 'PhabricatorGarbageCollector', 8731 8727 'PhabricatorDaemonLogListController' => 'PhabricatorDaemonController', 8732 8728 'PhabricatorDaemonLogListView' => 'AphrontView',
-1
src/applications/daemon/application/PhabricatorDaemonsApplication.php
··· 45 45 '' => 'PhabricatorDaemonLogListController', 46 46 '(?P<id>[1-9]\d*)/' => 'PhabricatorDaemonLogViewController', 47 47 ), 48 - 'event/(?P<id>[1-9]\d*)/' => 'PhabricatorDaemonLogEventViewController', 49 48 'bulk/' => array( 50 49 '(?:query/(?P<queryKey>[^/]+)/)?' => 51 50 'PhabricatorDaemonBulkJobListController',
-47
src/applications/daemon/controller/PhabricatorDaemonLogEventViewController.php
··· 1 - <?php 2 - 3 - final class PhabricatorDaemonLogEventViewController 4 - extends PhabricatorDaemonController { 5 - 6 - public function handleRequest(AphrontRequest $request) { 7 - $id = $request->getURIData('id'); 8 - 9 - $event = id(new PhabricatorDaemonLogEvent())->load($id); 10 - if (!$event) { 11 - return new Aphront404Response(); 12 - } 13 - 14 - $event_view = id(new PhabricatorDaemonLogEventsView()) 15 - ->setEvents(array($event)) 16 - ->setUser($request->getUser()) 17 - ->setCombinedLog(true) 18 - ->setShowFullMessage(true); 19 - 20 - $log_panel = id(new PHUIObjectBoxView()) 21 - ->setBackground(PHUIObjectBoxView::BLUE_PROPERTY) 22 - ->appendChild($event_view); 23 - 24 - $daemon_id = $event->getLogID(); 25 - 26 - $crumbs = $this->buildApplicationCrumbs() 27 - ->addTextCrumb( 28 - pht('Daemon %s', $daemon_id), 29 - $this->getApplicationURI("log/{$daemon_id}/")) 30 - ->addTextCrumb(pht('Event %s', $event->getID())) 31 - ->setBorder(true); 32 - 33 - $header = id(new PHUIHeaderView()) 34 - ->setHeader(pht('Combined Log')) 35 - ->setHeaderIcon('fa-file-text'); 36 - 37 - $view = id(new PHUITwoColumnView()) 38 - ->setHeader($header) 39 - ->setFooter($log_panel); 40 - 41 - return $this->newPage() 42 - ->setTitle(pht('Combined Daemon Log')) 43 - ->appendChild($view); 44 - 45 - } 46 - 47 - }
-131
src/applications/daemon/view/PhabricatorDaemonLogEventsView.php
··· 1 - <?php 2 - 3 - final class PhabricatorDaemonLogEventsView extends AphrontView { 4 - 5 - private $events; 6 - private $combinedLog; 7 - private $showFullMessage; 8 - 9 - 10 - public function setShowFullMessage($show_full_message) { 11 - $this->showFullMessage = $show_full_message; 12 - return $this; 13 - } 14 - 15 - public function setEvents(array $events) { 16 - assert_instances_of($events, 'PhabricatorDaemonLogEvent'); 17 - $this->events = $events; 18 - return $this; 19 - } 20 - 21 - public function setCombinedLog($is_combined) { 22 - $this->combinedLog = $is_combined; 23 - return $this; 24 - } 25 - 26 - public function render() { 27 - $viewer = $this->getViewer(); 28 - $rows = array(); 29 - 30 - foreach ($this->events as $event) { 31 - 32 - // Limit display log size. If a daemon gets stuck in an output loop this 33 - // page can be like >100MB if we don't truncate stuff. Try to do cheap 34 - // line-based truncation first, and fall back to expensive UTF-8 character 35 - // truncation if that doesn't get things short enough. 36 - 37 - $message = $event->getMessage(); 38 - $more = null; 39 - 40 - if (!$this->showFullMessage) { 41 - $more_lines = null; 42 - $more_chars = null; 43 - $line_limit = 12; 44 - if (substr_count($message, "\n") > $line_limit) { 45 - $message = explode("\n", $message); 46 - $more_lines = count($message) - $line_limit; 47 - $message = array_slice($message, 0, $line_limit); 48 - $message = implode("\n", $message); 49 - } 50 - 51 - $char_limit = 8192; 52 - if (strlen($message) > $char_limit) { 53 - $message = phutil_utf8v($message); 54 - $more_chars = count($message) - $char_limit; 55 - $message = array_slice($message, 0, $char_limit); 56 - $message = implode('', $message); 57 - } 58 - 59 - if ($more_chars) { 60 - $more = new PhutilNumber($more_chars); 61 - $more = pht('Show %d more character(s)...', $more); 62 - } else if ($more_lines) { 63 - $more = new PhutilNumber($more_lines); 64 - $more = pht('Show %d more line(s)...', $more); 65 - } 66 - 67 - if ($more) { 68 - $id = $event->getID(); 69 - $more = array( 70 - "\n...\n", 71 - phutil_tag( 72 - 'a', 73 - array( 74 - 'href' => "/daemon/event/{$id}/", 75 - ), 76 - $more), 77 - ); 78 - } 79 - } 80 - 81 - $row = array( 82 - $event->getLogType(), 83 - phabricator_date($event->getEpoch(), $viewer), 84 - phabricator_time($event->getEpoch(), $viewer), 85 - array( 86 - $message, 87 - $more, 88 - ), 89 - ); 90 - 91 - if ($this->combinedLog) { 92 - array_unshift( 93 - $row, 94 - phutil_tag( 95 - 'a', 96 - array( 97 - 'href' => '/daemon/log/'.$event->getLogID().'/', 98 - ), 99 - pht('Daemon %s', $event->getLogID()))); 100 - } 101 - 102 - $rows[] = $row; 103 - } 104 - 105 - $classes = array( 106 - '', 107 - '', 108 - 'right', 109 - 'wide prewrap', 110 - ); 111 - 112 - $headers = array( 113 - 'Type', 114 - 'Date', 115 - 'Time', 116 - 'Message', 117 - ); 118 - 119 - if ($this->combinedLog) { 120 - array_unshift($classes, 'pri'); 121 - array_unshift($headers, 'Daemon'); 122 - } 123 - 124 - $log_table = new AphrontTableView($rows); 125 - $log_table->setHeaders($headers); 126 - $log_table->setColumnClasses($classes); 127 - 128 - return $log_table->render(); 129 - } 130 - 131 - }