diff --git a/resources/sql/autopatches/20150901.xhpast.stderr.sql b/resources/sql/autopatches/20150901.xhpast.stderr.sql new file mode 100644 --- /dev/null +++ b/resources/sql/autopatches/20150901.xhpast.stderr.sql @@ -0,0 +1,5 @@ +ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree + ADD status INT NOT NULL AFTER input; + +ALTER TABLE {$NAMESPACE}_xhpastview.xhpastview_parsetree + ADD stderr longtext NOT NULL AFTER stdout; diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php --- a/src/applications/phpast/controller/PhabricatorXHPASTViewController.php +++ b/src/applications/phpast/controller/PhabricatorXHPASTViewController.php @@ -3,7 +3,6 @@ abstract class PhabricatorXHPASTViewController extends PhabricatorController { public function buildStandardPageResponse($view, array $data) { - $page = $this->buildStandardPageView(); $page->setApplicationName('XHPASTView'); diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php --- a/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php +++ b/src/applications/phpast/controller/PhabricatorXHPASTViewRunController.php @@ -13,17 +13,23 @@ $resolved = $future->resolve(); // This is just to let it throw exceptions if stuff is broken. - $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture( - $source, - $resolved); + try { + $parse_tree = XHPASTTree::newFromDataAndResolvedExecFuture( + $source, + $resolved); + } catch (XHPASTSyntaxErrorException $ex) { + // This is possibly expected. + } list($err, $stdout, $stderr) = $resolved; - $storage_tree = new PhabricatorXHPASTViewParseTree(); - $storage_tree->setInput($source); - $storage_tree->setStdout($stdout); - $storage_tree->setAuthorPHID($viewer->getPHID()); - $storage_tree->save(); + $storage_tree = id(new PhabricatorXHPASTViewParseTree()) + ->setInput($source) + ->setReturnCode($err) + ->setStdout($stdout) + ->setStderr($stderr) + ->setAuthorPHID($viewer->getPHID()) + ->save(); return id(new AphrontRedirectResponse()) ->setURI('/xhpast/view/'.$storage_tree->getID().'/'); diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php --- a/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php +++ b/src/applications/phpast/controller/PhabricatorXHPASTViewStreamController.php @@ -6,11 +6,15 @@ public function handleRequest(AphrontRequest $request) { $storage = $this->getStorageTree(); $input = $storage->getInput(); + $err = $storage->getReturnCode(); $stdout = $storage->getStdout(); + $stderr = $storage->getStderr(); $tree = XHPASTTree::newFromDataAndResolvedExecFuture( $input, - array(0, $stdout, '')); + array($err, $stdout, $stderr)); + + // TODO: Handle exception. $tokens = array(); foreach ($tree->getRawTokenStream() as $id => $token) { diff --git a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php --- a/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php +++ b/src/applications/phpast/controller/PhabricatorXHPASTViewTreeController.php @@ -10,18 +10,21 @@ public function handleRequest(AphrontRequest $request) { $storage = $this->getStorageTree(); $input = $storage->getInput(); + $err = $storage->getReturnCode(); $stdout = $storage->getStdout(); + $stderr = $storage->getStderr(); $tree = XHPASTTree::newFromDataAndResolvedExecFuture( $input, - array(0, $stdout, '')); + array($err, $stdout, $stderr)); + + // TODO: Handle exception. $tree = phutil_tag('ul', array(), $this->buildTree($tree->getRootNode())); return $this->buildXHPASTViewPanelResponse($tree); } protected function buildTree($root) { - try { $name = $root->getTypeName(); $title = $root->getDescription(); diff --git a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php --- a/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php +++ b/src/applications/phpast/storage/PhabricatorXHPASTViewParseTree.php @@ -3,16 +3,19 @@ final class PhabricatorXHPASTViewParseTree extends PhabricatorXHPASTViewDAO { protected $authorPHID; - protected $input; + protected $returnCode; protected $stdout; + protected $stderr; protected function getConfiguration() { return array( self::CONFIG_COLUMN_SCHEMA => array( 'authorPHID' => 'phid?', 'input' => 'text', + 'returnCode' => 'sint32', 'stdout' => 'text', + 'stderr' => 'text', ), ) + parent::getConfiguration(); }