@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.

Unprototype "Facts" to clear Maniphest/chart fatals

Summary: Ref T13279. Facts is still fairly rough, but not broken/policy-violating, so it can be unprototyped to fix the issue where Maniphest reports (which are now driven by Facts) don't work if prototypes are disabled.

Test Plan: Viewed Maniphest reports and Project reports with prototypes on/off and Fact installed/uninstalled.

Subscribers: yelirekim

Maniphest Tasks: T13279

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

+39 -75
-5
src/applications/fact/application/PhabricatorFactApplication.php
··· 22 22 return self::GROUP_UTILITIES; 23 23 } 24 24 25 - public function isPrototype() { 26 - return true; 27 - } 28 - 29 25 public function getRoutes() { 30 26 return array( 31 27 '/fact/' => array( 32 28 '' => 'PhabricatorFactHomeController', 33 - 'chart/' => 'PhabricatorFactChartController', 34 29 'chart/(?P<chartKey>[^/]+)/(?:(?P<mode>draw)/)?' => 35 30 'PhabricatorFactChartController', 36 31 'object/(?<phid>[^/]+)/' => 'PhabricatorFactObjectController',
+19 -22
src/applications/fact/controller/PhabricatorFactChartController.php
··· 1 1 <?php 2 2 3 - final class PhabricatorFactChartController extends PhabricatorFactController { 3 + final class PhabricatorFactChartController 4 + extends PhabricatorFactController { 4 5 5 6 public function handleRequest(AphrontRequest $request) { 6 7 $viewer = $request->getViewer(); 7 8 8 9 $chart_key = $request->getURIData('chartKey'); 9 - if ($chart_key === null) { 10 - return $this->newDemoChart(); 10 + if (!$chart_key) { 11 + return new Aphront404Response(); 11 12 } 12 13 13 14 $engine = id(new PhabricatorChartRenderingEngine()) ··· 24 25 $mode = $request->getURIData('mode'); 25 26 $is_draw_mode = ($mode === 'draw'); 26 27 27 - // TODO: For now, always pull the data. We'll throw it away if we're just 28 - // drawing the frame, but this makes errors easier to debug. 29 - $chart_data = $engine->newChartData(); 28 + $want_data = $is_draw_mode; 29 + 30 + // In developer mode, always pull the data in the main request. We'll 31 + // throw it away if we're just drawing the chart frame, but this currently 32 + // makes errors quite a bit easier to debug. 33 + if (PhabricatorEnv::getEnvConfig('phabricator.developer-mode')) { 34 + $want_data = true; 35 + } 30 36 31 - if ($is_draw_mode) { 32 - return id(new AphrontAjaxResponse())->setContent($chart_data); 37 + if ($want_data) { 38 + $chart_data = $engine->newChartData(); 39 + if ($is_draw_mode) { 40 + return id(new AphrontAjaxResponse())->setContent($chart_data); 41 + } 33 42 } 34 43 35 44 $chart_view = $engine->newChartView(); 36 - $tabular_view = $engine->newTabularView(); 37 45 38 - return $this->newChartResponse($chart_view, $tabular_view); 46 + return $this->newChartResponse($chart_view); 39 47 } 40 48 41 - private function newChartResponse($chart_view, $tabular_view) { 49 + private function newChartResponse($chart_view) { 42 50 $box = id(new PHUIObjectBoxView()) 43 51 ->setHeaderText(pht('Chart')) 44 52 ->appendChild($chart_view); ··· 55 63 ->appendChild( 56 64 array( 57 65 $box, 58 - $tabular_view, 59 66 )); 60 - } 61 - 62 - private function newDemoChart() { 63 - $viewer = $this->getViewer(); 64 - 65 - $chart = id(new PhabricatorDemoChartEngine()) 66 - ->setViewer($viewer) 67 - ->newStoredChart(); 68 - 69 - return id(new AphrontRedirectResponse())->setURI($chart->getURI()); 70 67 } 71 68 72 69 }
+7 -46
src/applications/fact/controller/PhabricatorFactHomeController.php
··· 1 1 <?php 2 2 3 - final class PhabricatorFactHomeController extends PhabricatorFactController { 3 + final class PhabricatorFactHomeController 4 + extends PhabricatorFactController { 4 5 5 6 public function shouldAllowPublic() { 6 7 return true; 7 8 } 8 9 9 10 public function handleRequest(AphrontRequest $request) { 10 - $viewer = $request->getViewer(); 11 + $viewer = $this->getViewer(); 11 12 12 - if ($request->isFormPost()) { 13 - $uri = new PhutilURI('/fact/chart/'); 14 - $uri->replaceQueryParam('y1', $request->getStr('y1')); 15 - return id(new AphrontRedirectResponse())->setURI($uri); 16 - } 13 + $chart = id(new PhabricatorDemoChartEngine()) 14 + ->setViewer($viewer) 15 + ->newStoredChart(); 17 16 18 - $chart_form = $this->buildChartForm(); 19 - 20 - $crumbs = $this->buildApplicationCrumbs(); 21 - $crumbs->addTextCrumb(pht('Home')); 22 - 23 - $title = pht('Facts'); 24 - 25 - return $this->newPage() 26 - ->setTitle($title) 27 - ->setCrumbs($crumbs) 28 - ->appendChild( 29 - array( 30 - $chart_form, 31 - )); 32 - } 33 - 34 - private function buildChartForm() { 35 - $request = $this->getRequest(); 36 - $viewer = $request->getUser(); 37 - 38 - $specs = PhabricatorFact::getAllFacts(); 39 - $options = mpull($specs, 'getName', 'getKey'); 40 - 41 - $form = id(new AphrontFormView()) 42 - ->setUser($viewer) 43 - ->appendChild( 44 - id(new AphrontFormSelectControl()) 45 - ->setLabel(pht('Y-Axis')) 46 - ->setName('y1') 47 - ->setOptions($options)) 48 - ->appendChild( 49 - id(new AphrontFormSubmitControl()) 50 - ->setValue(pht('Plot Chart'))); 51 - 52 - $panel = new PHUIObjectBoxView(); 53 - $panel->setForm($form); 54 - $panel->setHeaderText(pht('Plot Chart')); 55 - 56 - return $panel; 17 + return id(new AphrontRedirectResponse())->setURI($chart->getURI()); 57 18 } 58 19 59 20 }
+2
src/applications/fact/engine/PhabricatorDemoChartEngine.php
··· 17 17 array('shift', 256)); 18 18 19 19 $function->getFunctionLabel() 20 + ->setKey('cos-x') 20 21 ->setName(pht('cos(x)')) 21 22 ->setColor('rgba(0, 200, 0, 1)') 22 23 ->setFillColor('rgba(0, 200, 0, 0.15)'); ··· 27 28 array('constant', 345)); 28 29 29 30 $function->getFunctionLabel() 31 + ->setKey('constant-345') 30 32 ->setName(pht('constant(345)')) 31 33 ->setColor('rgba(0, 0, 200, 1)') 32 34 ->setFillColor('rgba(0, 0, 200, 0.15)');
+6 -2
src/applications/maniphest/controller/ManiphestReportController.php
··· 35 35 $nav->addLabel(pht('Open Tasks')); 36 36 $nav->addFilter('user', pht('By User')); 37 37 $nav->addFilter('project', pht('By Project')); 38 - $nav->addLabel(pht('Burnup')); 39 - $nav->addFilter('burn', pht('Burnup Rate')); 38 + 39 + $class = 'PhabricatorFactApplication'; 40 + if (PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 41 + $nav->addLabel(pht('Burnup')); 42 + $nav->addFilter('burn', pht('Burnup Rate')); 43 + } 40 44 41 45 $this->view = $nav->selectFilter($this->view, 'user'); 42 46
+5
src/applications/project/menuitem/PhabricatorProjectReportsProfileMenuItem.php
··· 34 34 return false; 35 35 } 36 36 37 + $class = 'PhabricatorFactApplication'; 38 + if (!PhabricatorApplication::isClassInstalledForViewer($class, $viewer)) { 39 + return false; 40 + } 41 + 37 42 return true; 38 43 } 39 44