From: Aaron Schulz Date: Sun, 20 May 2012 05:07:09 +0000 (-0700) Subject: Avoid extreme performance regression in ImagePage. X-Git-Tag: 1.31.0-rc.0~23507^2 X-Git-Url: http://git.cyclocoop.org/%7B%24admin_url%7Dcompta/comptes/journal.php?a=commitdiff_plain;h=1aaac4c915c001f3b759d22d65e12aa0dda02d1e;p=lhc%2Fweb%2Fwiklou.git Avoid extreme performance regression in ImagePage. * For some reason, when 404 handling is off, all the links for $wgImageLimits were still generated but not put into the HTML. They still triggered convert() calls - 7 times by default. Change-Id: I0d12c7ec3c02039c1307a1a1d04d1d1cbd44b547 --- diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 3fbbcba26b..3aeb70afe8 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -346,18 +346,30 @@ class ImagePage extends Article { # Note that $height <= $maxHeight now, but might not be identical # because of rounding. } - $msgbig = wfMsgHtml( 'show-big-image' ); + $msgbig = wfMsgHtml( 'show-big-image' ); + if ( $this->displayImg->getRepo()->canTransformVia404() ) { + $thumbSizes = $wgImageLimits; + } else { + # Creating thumb links triggers thumbnail generation. + # Just generate the thumb for the current users prefs. + $thumbOption = $user->getOption( 'thumbsize' ); + $thumbSizes = array( isset( $wgImageLimits[$thumbOption] ) + ? $wgImageLimits[$thumbOption] + : $wgImageLimits[User::getDefaultOption( 'thumbsize' )] ); + } + # Generate thumbnails or thumbnail links as needed... $otherSizes = array(); - foreach ( $wgImageLimits as $size ) { - if ( $size[0] < $width_orig && $size[1] < $height_orig && - $size[0] != $width && $size[1] != $height ) { + foreach ( $thumbSizes as $size ) { + if ( $size[0] < $width_orig && $size[1] < $height_orig + && $size[0] != $width && $size[1] != $height ) + { $otherSizes[] = $this->makeSizeLink( $params, $size[0], $size[1] ); } } $msgsmall = wfMessage( 'show-big-image-preview' )-> rawParams( $this->makeSizeLink( $params, $width, $height ) )-> parse(); - if ( count( $otherSizes ) && $this->displayImg->getRepo()->canTransformVia404() ) { + if ( count( $otherSizes ) ) { $msgsmall .= ' ' . Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ), wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )->