Index: branches/wmf-deployment/extensions/CodeReview/api/ApiCodeDiff.php |
— | — | @@ -3,7 +3,7 @@ |
4 | 4 | class ApiCodeDiff extends ApiBase { |
5 | 5 | |
6 | 6 | public function execute() { |
7 | | - global $wgUser; |
| 7 | + global $wgUser, $wgCodeReviewMaxDiffSize; |
8 | 8 | // Before doing anything at all, let's check permissions |
9 | 9 | if( !$wgUser->isAllowed('codereview-use') ) { |
10 | 10 | $this->dieUsage('You don\'t have permission to view code diffs','permissiondenied'); |
— | — | @@ -31,12 +31,14 @@ |
32 | 32 | |
33 | 33 | $diff = $repo->getDiff( $params['rev'] ); |
34 | 34 | |
35 | | - if ( $diff ) { |
| 35 | + if ( strval( $diff ) === '' ) { |
| 36 | + // FIXME: Are we sure we don't want to throw an error here? |
| 37 | + $html = 'Failed to load diff.'; |
| 38 | + } elseif ( strlen( $diff ) > $wgCodeReviewMaxDiffSize ) { |
| 39 | + $html = 'Diff too large.'; |
| 40 | + } else { |
36 | 41 | $hilite = new CodeDiffHighlighter(); |
37 | 42 | $html = $hilite->render( $diff ); |
38 | | - } else { |
39 | | - // FIXME: Are we sure we don't want to throw an error here? |
40 | | - $html = 'Failed to load diff.'; |
41 | 43 | } |
42 | 44 | |
43 | 45 | $data = array( |
Property changes on: branches/wmf-deployment/extensions/CodeReview/ui/CodeAuthorListView.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
44 | 46 | Merged /trunk/extensions/CodeReview/ui/CodeAuthorListView.php:r60646 |
Index: branches/wmf-deployment/extensions/CodeReview/ui/CodeRevisionView.php |
— | — | @@ -330,7 +330,7 @@ |
331 | 331 | } |
332 | 332 | |
333 | 333 | protected function formatDiff() { |
334 | | - global $wgEnableAPI; |
| 334 | + global $wgEnableAPI, $wgCodeReviewMaxDiffSize; |
335 | 335 | |
336 | 336 | // Asynchronous diff loads will require the API |
337 | 337 | // And JS in the client, but tough shit eh? ;) |
— | — | @@ -353,6 +353,8 @@ |
354 | 354 | if ( !$diff && $deferDiffs ) { |
355 | 355 | // We'll try loading it by AJAX... |
356 | 356 | return $this->stubDiffLoader(); |
| 357 | + } elseif ( strlen( $diff ) > $wgCodeReviewMaxDiffSize ) { |
| 358 | + return htmlspecialchars( wfMsg( 'code-rev-diff-too-large' ) ); |
357 | 359 | } else { |
358 | 360 | $hilite = new CodeDiffHighlighter(); |
359 | 361 | return $hilite->render( $diff ); |
Property changes on: branches/wmf-deployment/extensions/CodeReview/ui/CodeRevisionView.php |
___________________________________________________________________ |
Modified: svn:mergeinfo |
360 | 362 | Merged /trunk/extensions/CodeReview/ui/CodeRevisionView.php:r60646 |
Index: branches/wmf-deployment/extensions/CodeReview/CodeReview.i18n.php |
— | — | @@ -73,6 +73,7 @@ |
74 | 74 | 'code-rev-comment-preview' => 'Preview', |
75 | 75 | 'code-rev-diff' => 'Diff', |
76 | 76 | 'code-rev-diff-link' => 'diff', |
| 77 | + 'code-rev-diff-too-large' => 'The diff is too large to display.', |
77 | 78 | 'code-rev-purge-link' => 'purge', |
78 | 79 | 'code-status-new' => 'new', |
79 | 80 | 'code-status-fixme' => 'fixme', |
Index: branches/wmf-deployment/extensions/CodeReview/CodeReview.php |
— | — | @@ -140,6 +140,11 @@ |
141 | 141 | // Should match test runner's $wgParserTestRemote['secret']. |
142 | 142 | $wgCodeReviewSharedSecret = false; |
143 | 143 | |
| 144 | +/** |
| 145 | + * Maximum size of diff text before it is omitted from the revision view |
| 146 | + */ |
| 147 | +$wgCodeReviewMaxDiffSize = 500000; |
| 148 | + |
144 | 149 | # Schema changes |
145 | 150 | $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates'; |
146 | 151 | |
Property changes on: branches/wmf-deployment/extensions/CodeReview |
___________________________________________________________________ |
Modified: svn:mergeinfo |
147 | 152 | Merged /trunk/extensions/CodeReview:r60646 |