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

Don't let blame run for longer than 15 seconds

Summary: Fixes T2450. If we spend more than 15 seconds in blame, just cut it off.

Test Plan:
- Changed timeout to 0.01 seconds.
- Did blame on a non-highlighted file, got no blame, saw warning.
- Did blame on a highlighted file, got no blame.
- Note: you don't get a warning here because of Ajax stuff. It'd be kind of tricky to add and doesn't seem like a big deal so I'm planning to leave it as-is for now.

Reviewers: chad

Reviewed By: chad

Subscribers: 20after4, chasemp

Maniphest Tasks: T2450

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

+35 -10
+35 -10
src/applications/diffusion/controller/DiffusionBrowseController.php
··· 591 591 $data) { 592 592 593 593 $viewer = $this->getViewer(); 594 + $blame_timeout = 15; 595 + $blame_failed = false; 594 596 595 - if ($needs_blame) { 596 - $blame = $this->loadBlame($path, $drequest->getCommit()); 597 + $file_corpus = $file_content->getCorpus(); 598 + $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; 599 + $blame_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; 600 + $can_highlight = (strlen($file_corpus) <= $highlight_limit); 601 + $can_blame = (strlen($file_corpus) <= $blame_limit); 602 + 603 + if ($needs_blame && $can_blame) { 604 + $blame = $this->loadBlame($path, $drequest->getCommit(), $blame_timeout); 597 605 list($blame_list, $blame_commits) = $blame; 606 + if ($blame_list === null) { 607 + $blame_failed = true; 608 + $blame_list = array(); 609 + } 598 610 } else { 599 611 $blame_list = array(); 600 612 $blame_commits = array(); 601 613 } 602 - 603 - $file_corpus = $file_content->getCorpus(); 604 - $highlight_limit = DifferentialChangesetParser::HIGHLIGHT_BYTE_LIMIT; 605 - $can_highlight = (strlen($file_corpus) <= $highlight_limit); 606 614 607 615 if (!$show_color) { 608 616 $corpus = $this->renderPlaintextCorpus( ··· 697 705 ->appendChild($corpus) 698 706 ->setCollapsed(true); 699 707 708 + $messages = array(); 709 + 700 710 if (!$can_highlight) { 701 - $message = pht( 711 + $messages[] = pht( 702 712 'This file is larger than %s, so syntax highlighting is disabled '. 703 713 'by default.', 704 714 phutil_format_bytes($highlight_limit)); 715 + } 705 716 717 + if ($show_blame && !$can_blame) { 718 + $messages[] = pht( 719 + 'This file is larger than %s, so blame is disabled.', 720 + phutil_format_bytes($blame_limit)); 721 + } 722 + 723 + if ($blame_failed) { 724 + $messages[] = pht( 725 + 'Failed to load blame information for this file in %s second(s).', 726 + new PhutilNumber($blame_timeout)); 727 + } 728 + 729 + if ($messages) { 706 730 $corpus->setInfoView( 707 731 id(new PHUIInfoView()) 708 732 ->setSeverity(PHUIInfoView::SEVERITY_WARNING) 709 - ->setErrors(array($message))); 733 + ->setErrors($messages)); 710 734 } 711 735 712 736 return $corpus; ··· 1709 1733 return $view; 1710 1734 } 1711 1735 1712 - private function loadBlame($path, $commit) { 1736 + private function loadBlame($path, $commit, $timeout) { 1713 1737 $blame = $this->callConduitWithDiffusionRequest( 1714 1738 'diffusion.blame', 1715 1739 array( 1716 1740 'commit' => $commit, 1717 1741 'paths' => array($path), 1742 + 'timeout' => $timeout, 1718 1743 )); 1719 1744 1720 - $identifiers = idx($blame, $path, array()); 1745 + $identifiers = idx($blame, $path, null); 1721 1746 1722 1747 if ($identifiers) { 1723 1748 $viewer = $this->getViewer();