r95050 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r95049‎ | r95050 | r95051 >
Date:23:06, 19 August 2011
Author:reedy
Status:ok (Comments)
Tags:
Comment:
Incorporate Wikia diff, don't duplicate debugging though, add the info to the debug call that already exists
Modified paths:
  • /trunk/phase3/includes/media/Generic.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/media/Generic.php
@@ -494,10 +494,10 @@
495495 if( file_exists( $dstPath ) ) {
496496 $thumbstat = stat( $dstPath );
497497 if( $thumbstat['size'] == 0 || $retval != 0 ) {
 498+ $result = unlink( $dstPath );
498499 wfDebugLog( 'thumbnail',
499 - sprintf( 'Removing bad %d-byte thumbnail "%s"',
500 - $thumbstat['size'], $dstPath ) );
501 - unlink( $dstPath );
 500+ sprintf( 'Removing bad %d-byte thumbnail "%s". unlink() result: %d',
 501+ $thumbstat['size'], $dstPath, $result ) );
502502 return true;
503503 }
504504 }
@@ -588,43 +588,43 @@
589589
590590 $srcWidth = $image->getWidth( $params['page'] );
591591 $srcHeight = $image->getHeight( $params['page'] );
592 -
 592+
593593 if ( isset( $params['height'] ) && $params['height'] != -1 ) {
594594 # Height & width were both set
595595 if ( $params['width'] * $srcHeight > $params['height'] * $srcWidth ) {
596596 # Height is the relative smaller dimension, so scale width accordingly
597597 $params['width'] = self::fitBoxWidth( $srcWidth, $srcHeight, $params['height'] );
598 -
 598+
599599 if ( $params['width'] == 0 ) {
600600 # Very small image, so we need to rely on client side scaling :(
601601 $params['width'] = 1;
602602 }
603 -
 603+
604604 $params['physicalWidth'] = $params['width'];
605605 } else {
606606 # Height was crap, unset it so that it will be calculated later
607607 unset( $params['height'] );
608608 }
609609 }
610 -
 610+
611611 if ( !isset( $params['physicalWidth'] ) ) {
612612 # Passed all validations, so set the physicalWidth
613613 $params['physicalWidth'] = $params['width'];
614614 }
615 -
 615+
616616 # Because thumbs are only referred to by width, the height always needs
617617 # to be scaled by the width to keep the thumbnail sizes consistent,
618618 # even if it was set inside the if block above
619 - $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight,
 619+ $params['physicalHeight'] = File::scaleHeight( $srcWidth, $srcHeight,
620620 $params['physicalWidth'] );
621621
622 - # Set the height if it was not validated in the if block higher up
 622+ # Set the height if it was not validated in the if block higher up
623623 if ( !isset( $params['height'] ) || $params['height'] == -1 ) {
624624 $params['height'] = $params['physicalHeight'];
625625 }
626626
627 -
628 - if ( !$this->validateThumbParams( $params['physicalWidth'],
 627+
 628+ if ( !$this->validateThumbParams( $params['physicalWidth'],
629629 $params['physicalHeight'], $srcWidth, $srcHeight, $mimeType ) ) {
630630 return false;
631631 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r95147Add in \n from/to r95055 to LoadBalancer.php...reedy15:24, 21 August 2011

Comments

#Comment by Hashar (talk | contribs)   14:42, 21 August 2011

Maybe output different messages based on ulink() result? Would make grepping for failure easier.

+ ulink() returns true/false which I suspect %d to format as 1, 0 respectively. Can be miss leading (is 1 for error code or is that ok? :p )

#Comment by Hashar (talk | contribs)   21:04, 21 August 2011

great :)

Status & tagging log