r99916 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99915‎ | r99916 | r99917 >
Date:21:38, 15 October 2011
Author:btongminh
Status:resolved
Tags:
Comment:
Follow-up r99911: fix tests
Add NullRepo to autoloader
Modified paths:
  • /trunk/phase3/includes/AutoLoader.php (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/tests/phpunit/includes/media/BitmapScalingTest.php (modified) (history)

Diff [purge]

Index: trunk/phase3/tests/phpunit/includes/media/BitmapScalingTest.php
@@ -3,13 +3,16 @@
44 class BitmapScalingTest extends MediaWikiTestCase {
55
66 function setUp() {
7 - global $wgMaxImageArea;
 7+ global $wgMaxImageArea, $wgCustomConvertCommand;
88 $this->oldMaxImageArea = $wgMaxImageArea;
 9+ $this->oldCustomConvertCommand = $wgCustomConvertCommand;
910 $wgMaxImageArea = 1.25e7; // 3500x3500
 11+ $wgCustomConvertCommand = 'dummy'; // Set so that we don't get client side rendering
1012 }
1113 function tearDown() {
12 - global $wgMaxImageArea;
 14+ global $wgMaxImageArea, $wgCustomConvertCommand;
1315 $wgMaxImageArea = $this->oldMaxImageArea;
 16+ $wgCustomConvertCommand = $this->oldCustomConvertCommand;
1417 }
1518 /**
1619 * @dataProvider provideNormaliseParams
@@ -105,14 +108,16 @@
106109 $file = new FakeDimensionFile( array( 4000, 4000 ) );
107110 $handler = new BitmapHandler;
108111 $params = array( 'width' => '3700' ); // Still bigger than max size.
109 - $this->assertFalse( $handler->normaliseParams( $file, $params ) );
 112+ $this->assertEquals( 'TransformParameterError',
 113+ get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
110114 }
111115 function testTooBigMustRenderImage() {
112116 $file = new FakeDimensionFile( array( 4000, 4000 ) );
113117 $file->mustRender = true;
114118 $handler = new BitmapHandler;
115119 $params = array( 'width' => '5000' ); // Still bigger than max size.
116 - $this->assertFalse( $handler->normaliseParams( $file, $params ) );
 120+ $this->assertEquals( 'TransformParameterError',
 121+ get_class( $handler->doTransform( $file, 'dummy path', '', $params ) ) );
117122 }
118123 }
119124
@@ -120,7 +125,8 @@
121126 public $mustRender = false;
122127
123128 public function __construct( $dimensions ) {
124 - parent::__construct( Title::makeTitle( NS_FILE, 'Test' ), null );
 129+ parent::__construct( Title::makeTitle( NS_FILE, 'Test' ),
 130+ new NullRepo( null ) );
125131
126132 $this->dimensions = $dimensions;
127133 }
@@ -133,4 +139,7 @@
134140 public function mustRender() {
135141 return $this->mustRender;
136142 }
 143+ public function getPath() {
 144+ return '';
 145+ }
137146 }
Index: trunk/phase3/includes/AutoLoader.php
@@ -471,6 +471,7 @@
472472 'LocalFileMoveBatch' => 'includes/filerepo/LocalFile.php',
473473 'LocalFileRestoreBatch' => 'includes/filerepo/LocalFile.php',
474474 'LocalRepo' => 'includes/filerepo/LocalRepo.php',
 475+ 'NullRepo' => 'includes/filerepo/NullRepo.php',
475476 'OldLocalFile' => 'includes/filerepo/OldLocalFile.php',
476477 'RepoGroup' => 'includes/filerepo/RepoGroup.php',
477478 'UnregisteredLocalFile' => 'includes/filerepo/UnregisteredLocalFile.php',
Index: trunk/phase3/includes/ImagePage.php
@@ -287,6 +287,9 @@
288288 $width = $width_orig;
289289 $height_orig = $this->displayImg->getHeight( $page );
290290 $height = $height_orig;
 291+ $mustRender = $this->displayImg->getHandler() &&
 292+ $this->displayImg->getHandler()->mustRender( $this->displayImg );
 293+ $addFullResolutionLink = false;
291294
292295 $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() );
293296
@@ -312,14 +315,19 @@
313316 # Note that $height <= $maxHeight now, but might not be identical
314317 # because of rounding.
315318 }
316 - $msgbig = wfMsgHtml( 'show-big-image' );
 319+
317320 $otherSizes = array();
318321 foreach ( $wgImageLimits as $size ) {
319322 if ( $size[0] < $width_orig && $size[1] < $height_orig &&
320323 $size[0] != $width && $size[1] != $height ) {
321324 $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] );
322 - }
 325+ }
323326 }
 327+ if ( $mustRender ) {
 328+ $otherSizes[] = $this->makeSizeLink( $params, $width_orig, $height_orig, 'show-big-image' );
 329+ } else {
 330+ $addFullResolutionLink = true;
 331+ }
324332 $msgsmall = wfMessage( 'show-big-image-preview' )->
325333 rawParams( $this->makeSizeLink( $params, $width, $height ) )->
326334 parse() . ' ' .
@@ -347,7 +355,7 @@
348356 if ( $thumbnail ) {
349357 $options = array(
350358 'alt' => $this->displayImg->getTitle()->getPrefixedText(),
351 - 'file-link' => true,
 359+ 'file-link' => !$mustRender,
352360 );
353361 $wgOut->addHTML( '<div class="fullImageLink" id="file">' .
354362 $thumbnail->toHtml( $options ) .
@@ -428,8 +436,8 @@
429437 if ( $showLink ) {
430438 $filename = wfEscapeWikiText( $this->displayImg->getName() );
431439 $linktext = $filename;
432 - if ( isset( $msgbig ) ) {
433 - $linktext = wfEscapeWikiText( $msgbig );
 440+ if ( $addFullResolutionLink ) {
 441+ $linktext = wfMsg( 'show-big-image' );
434442 }
435443 $medialink = "[[Media:$filename|$linktext]]";
436444
@@ -484,7 +492,7 @@
485493 * @param int $width
486494 * @param int $height
487495 */
488 - private function makeSizeLink( $params, $width, $height ) {
 496+ private function makeSizeLink( $params, $width, $height, $msg = 'show-big-image-size' ) {
489497 $params['width'] = $width;
490498 $params['height'] = $height;
491499 $thumbnail = $this->displayImg->transform( $params );
@@ -492,7 +500,7 @@
493501 return Html::rawElement( 'a', array(
494502 'href' => $thumbnail->getUrl(),
495503 'class' => 'mw-thumbnail-link'
496 - ), wfMessage( 'show-big-image-size' )->numParams(
 504+ ), wfMessage( $msg )->numParams(
497505 $thumbnail->getWidth(), $thumbnail->getHeight()
498506 )->parse() );
499507 } else {

Follow-up revisions

RevisionCommit summaryAuthorDate
r99917Revert unrelated changes from r99916btongminh21:40, 15 October 2011
r104389MFT VipsScaler dependencies r99911, r99916, r99917, r101677, r104386, r104387...tstarling05:04, 28 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r99911Per bug 28135, disable $wgMaxImageArea check when transforming using a hook, ...btongminh20:36, 15 October 2011

Status & tagging log