public function processRequest() { $request = $this->getRequest(); $viewer = $request->getUser(); $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontCursorPagerView(); $pager->readFromRequest($request); $pager->setPageSize(500); $query = id(new PhabricatorConduitLogQuery())->setViewer($viewer); $methods = $request->getStrList('methods'); if ($methods) { $query->withMethods($methods); } $calls = $query->executeWithCursorPager($pager); $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $box = id(new PHUIObjectBoxView())->setHeaderText(pht('Call Logs'))->appendChild($table); $crumbs = $this->buildApplicationCrumbs(); $crumbs->addTextCrumb(pht('Call Logs')); return $this->buildApplicationPage(array($crumbs, $box, $pager), array('title' => pht('Conduit Logs'))); }
public function loadPage() { $table = new PhabricatorConduitMethodCallLog(); $conn_r = $table->establishConnection('r'); $data = queryfx_all($conn_r, 'SELECT * FROM %T %Q %Q %Q', $table->getTableName(), $this->buildWhereClause($conn_r), $this->buildOrderClause($conn_r), $this->buildLimitClause($conn_r)); return $table->loadAllFromArray($data); }
public function processRequest() { $request = $this->getRequest(); $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $calls = $call_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $calls = $pager->sliceResults($calls); $pager->setURI(new PhutilURI('/conduit/log/'), 'page'); $pager->setEnableKeyboardShortcuts(true); $min = $pager->getOffset() + 1; $max = $min + count($calls) - 1; $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Method Calls (' . $min . '-' . $max . ')'); $panel->appendChild($table); $panel->appendChild($pager); $this->setShowSideNav(false); return $this->buildStandardPageResponse($panel, array('title' => 'Conduit Logs')); }
public function processRequest() { $request = $this->getRequest(); $nav = new AphrontSideNavView(); $links = array('calls' => 'All Calls'); if (empty($links[$this->view])) { $this->view = key($links); } foreach ($links as $slug => $name) { $nav->addNavItem(phutil_render_tag('a', array('href' => '/conduit/log/view/' . $slug . '/', 'class' => $slug == $this->view ? 'aphront-side-nav-selected' : null), phutil_escape_html($name))); } $conn_table = new PhabricatorConduitConnectionLog(); $call_table = new PhabricatorConduitMethodCallLog(); $conn_r = $call_table->establishConnection('r'); $pager = new AphrontPagerView(); $pager->setOffset($request->getInt('page')); $calls = $call_table->loadAllWhere('1 = 1 ORDER BY id DESC LIMIT %d, %d', $pager->getOffset(), $pager->getPageSize() + 1); $calls = $pager->sliceResults($calls); $pager->setURI(new PhutilURI('/conduit/log/view/' . $this->view . '/'), 'page'); $pager->setEnableKeyboardShortcuts(true); $min = $pager->getOffset() + 1; $max = $min + count($calls) - 1; $conn_ids = array_filter(mpull($calls, 'getConnectionID')); $conns = array(); if ($conn_ids) { $conns = $conn_table->loadAllWhere('id IN (%Ld)', $conn_ids); } $table = $this->renderCallTable($calls, $conns); $panel = new AphrontPanelView(); $panel->setHeader('Conduit Method Calls (' . $min . '-' . $max . ')'); $panel->appendChild($table); $panel->appendChild($pager); $nav->appendChild($panel); return $this->buildStandardPageResponse($nav, array('title' => 'Conduit Logs', 'tab' => 'logs')); }
protected function collectGarbage() { $table = new PhabricatorConduitMethodCallLog(); $conn_w = $table->establishConnection('w'); queryfx($conn_w, 'DELETE FROM %T WHERE dateCreated < %d ORDER BY dateCreated ASC LIMIT 100', $table->getTableName(), $this->getGarbageEpoch()); return $conn_w->getAffectedRows() == 100; }
public function collectGarbage() { $key = 'gcdaemon.ttl.conduit-logs'; $ttl = PhabricatorEnv::getEnvConfig($key); if ($ttl <= 0) { return false; } $table = new PhabricatorConduitMethodCallLog(); $conn_w = $table->establishConnection('w'); queryfx($conn_w, 'DELETE FROM %T WHERE dateCreated < %d ORDER BY dateCreated ASC LIMIT 100', $table->getTableName(), time() - $ttl); return $conn_w->getAffectedRows() == 100; }
protected function executeChecks() { $methods = id(new PhabricatorConduitMethodQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIsDeprecated(true)->execute(); if (!$methods) { return; } $methods = mpull($methods, null, 'getAPIMethodName'); $method_names = mpull($methods, 'getAPIMethodName'); $table = new PhabricatorConduitMethodCallLog(); $conn_r = $table->establishConnection('r'); $calls = queryfx_all($conn_r, 'SELECT DISTINCT method FROM %T WHERE dateCreated > %d AND method IN (%Ls)', $table->getTableName(), time() - 60 * 60 * 24 * 30, $method_names); $calls = ipull($calls, 'method', 'method'); foreach ($calls as $method_name) { $method = $methods[$method_name]; $summary = pht('Deprecated Conduit method `%s` was called in the last 30 days. ' . 'You should migrate away from use of this method: it will be ' . 'removed in a future version of Phabricator.', $method_name); $uri = PhabricatorEnv::getURI('/conduit/log/?methods=' . $method_name); $description = $method->getMethodStatusDescription(); $message = pht('Deprecated Conduit method %s was called in the last 30 days. ' . 'You should migrate away from use of this method: it will be ' . 'removed in a future version of Phabricator.' . "\n\n" . "%s: %s" . "\n\n" . 'If you have already migrated all callers away from this method, ' . 'you can safely ignore this setup issue.', phutil_tag('tt', array(), $method_name), phutil_tag('tt', array(), $method_name), $description); $this->newIssue('conduit.deprecated.' . $method_name)->setShortName(pht('Deprecated Conduit Method'))->setName(pht('Deprecated Conduit Method "%s" In Use', $method_name))->setSummary($summary)->setMessage($message)->addLink($uri, pht('View Method Call Logs')); } }