r60647 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r60646‎ | r60647 | r60648 >
Date:07:23, 5 January 2010
Author:tstarling
Status:ok
Tags:
Comment:
Merged r60646 from trunk.
Modified paths:
  • /branches/wmf-deployment/extensions/CodeReview (modified) (history)
  • /branches/wmf-deployment/extensions/CodeReview/CodeReview.i18n.php (modified) (history)
  • /branches/wmf-deployment/extensions/CodeReview/CodeReview.php (modified) (history)
  • /branches/wmf-deployment/extensions/CodeReview/api/ApiCodeDiff.php (modified) (history)
  • /branches/wmf-deployment/extensions/CodeReview/ui/CodeAuthorListView.php (modified) (history)
  • /branches/wmf-deployment/extensions/CodeReview/ui/CodeRevisionView.php (modified) (history)

Diff [purge]

Index: branches/wmf-deployment/extensions/CodeReview/api/ApiCodeDiff.php
@@ -3,7 +3,7 @@
44 class ApiCodeDiff extends ApiBase {
55
66 public function execute() {
7 - global $wgUser;
 7+ global $wgUser, $wgCodeReviewMaxDiffSize;
88 // Before doing anything at all, let's check permissions
99 if( !$wgUser->isAllowed('codereview-use') ) {
1010 $this->dieUsage('You don\'t have permission to view code diffs','permissiondenied');
@@ -31,12 +31,14 @@
3232
3333 $diff = $repo->getDiff( $params['rev'] );
3434
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 {
3641 $hilite = new CodeDiffHighlighter();
3742 $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.';
4143 }
4244
4345 $data = array(
Property changes on: branches/wmf-deployment/extensions/CodeReview/ui/CodeAuthorListView.php
___________________________________________________________________
Modified: svn:mergeinfo
4446 Merged /trunk/extensions/CodeReview/ui/CodeAuthorListView.php:r60646
Index: branches/wmf-deployment/extensions/CodeReview/ui/CodeRevisionView.php
@@ -330,7 +330,7 @@
331331 }
332332
333333 protected function formatDiff() {
334 - global $wgEnableAPI;
 334+ global $wgEnableAPI, $wgCodeReviewMaxDiffSize;
335335
336336 // Asynchronous diff loads will require the API
337337 // And JS in the client, but tough shit eh? ;)
@@ -353,6 +353,8 @@
354354 if ( !$diff && $deferDiffs ) {
355355 // We'll try loading it by AJAX...
356356 return $this->stubDiffLoader();
 357+ } elseif ( strlen( $diff ) > $wgCodeReviewMaxDiffSize ) {
 358+ return htmlspecialchars( wfMsg( 'code-rev-diff-too-large' ) );
357359 } else {
358360 $hilite = new CodeDiffHighlighter();
359361 return $hilite->render( $diff );
Property changes on: branches/wmf-deployment/extensions/CodeReview/ui/CodeRevisionView.php
___________________________________________________________________
Modified: svn:mergeinfo
360362 Merged /trunk/extensions/CodeReview/ui/CodeRevisionView.php:r60646
Index: branches/wmf-deployment/extensions/CodeReview/CodeReview.i18n.php
@@ -73,6 +73,7 @@
7474 'code-rev-comment-preview' => 'Preview',
7575 'code-rev-diff' => 'Diff',
7676 'code-rev-diff-link' => 'diff',
 77+ 'code-rev-diff-too-large' => 'The diff is too large to display.',
7778 'code-rev-purge-link' => 'purge',
7879 'code-status-new' => 'new',
7980 'code-status-fixme' => 'fixme',
Index: branches/wmf-deployment/extensions/CodeReview/CodeReview.php
@@ -140,6 +140,11 @@
141141 // Should match test runner's $wgParserTestRemote['secret'].
142142 $wgCodeReviewSharedSecret = false;
143143
 144+/**
 145+ * Maximum size of diff text before it is omitted from the revision view
 146+ */
 147+$wgCodeReviewMaxDiffSize = 500000;
 148+
144149 # Schema changes
145150 $wgHooks['LoadExtensionSchemaUpdates'][] = 'efCodeReviewSchemaUpdates';
146151
Property changes on: branches/wmf-deployment/extensions/CodeReview
___________________________________________________________________
Modified: svn:mergeinfo
147152 Merged /trunk/extensions/CodeReview:r60646

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r60646Don't attempt to format diffs more than 500KB in size. Fix for OOM observed i...tstarling07:21, 5 January 2010

Status & tagging log