r30821 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r30820‎ | r30821 | r30822 >
Date:03:27, 11 February 2008
Author:aaron
Status:old
Tags:
Comment:
Tweak r30820. Pass $time variable further in. This avoids extra wfFindFile() calls if we were fetching the current revision.
Modified paths:
  • /trunk/phase3/includes/Linker.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/Linker.php
@@ -460,6 +460,7 @@
461461 * @param boolean $thumb shows image as thumbnail in a frame
462462 * @param string $manualthumb image name for the manual thumbnail
463463 * @param string $valign vertical alignment: baseline, sub, super, top, text-top, middle, bottom, text-bottom
 464+ * @param string $time, timestamp of the file, set as false for current
464465 * @return string
465466 */
466467 function makeImageLinkObj( $title, $label, $alt, $align = '', $handlerParams = array(), $framed = false,
@@ -482,7 +483,7 @@
483484 $frameParams['valign'] = $valign;
484485 }
485486 $file = wfFindFile( $title, $time );
486 - return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams );
 487+ return $this->makeImageLink2( $title, $file, $frameParams, $handlerParams, $time );
487488 }
488489
489490 /**
@@ -508,8 +509,9 @@
509510 *
510511 * @param array $handlerParams Associative array of media handler parameters, to be passed
511512 * to transform(). Typical keys are "width" and "page".
 513+ * @param string $time, timestamp of the file, set as false for current
512514 */
513 - function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array() ) {
 515+ function makeImageLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false ) {
514516 global $wgContLang, $wgUser, $wgThumbLimits, $wgThumbUpright;
515517 if ( $file && !$file->allowInlineDisplay() ) {
516518 wfDebug( __METHOD__.': '.$title->getPrefixedDBkey()." does not allow inline display\n" );
@@ -570,7 +572,7 @@
571573 if ( $fp['align'] == '' ) {
572574 $fp['align'] = $wgContLang->isRTL() ? 'left' : 'right';
573575 }
574 - return $prefix.$this->makeThumbLink2( $title, $file, $fp, $hp ).$postfix;
 576+ return $prefix.$this->makeThumbLink2( $title, $file, $fp, $hp, $time ).$postfix;
575577 }
576578
577579 if ( $file && isset( $fp['frameless'] ) ) {
@@ -590,7 +592,7 @@
591593 }
592594
593595 if ( !$thumb ) {
594 - $s = $this->makeBrokenImageLinkObj( $title );
 596+ $s = $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
595597 } else {
596598 $s = $thumb->toHtml( array(
597599 'desc-link' => true,
@@ -620,7 +622,7 @@
621623 return $this->makeThumbLink2( $title, $file, $frameParams, $params );
622624 }
623625
624 - function makeThumbLink2( Title $title, $file, $frameParams = array(), $handlerParams = array() ) {
 626+ function makeThumbLink2( Title $title, $file, $frameParams = array(), $handlerParams = array(), $time = false ) {
625627 global $wgStylePath, $wgContLang;
626628 $exists = $file && $file->exists();
627629
@@ -680,7 +682,7 @@
681683
682684 $s = "<div class=\"thumb t{$fp['align']}\"><div class=\"thumbinner\" style=\"width:{$outerWidth}px;\">";
683685 if( !$exists ) {
684 - $s .= $this->makeBrokenImageLinkObj( $title );
 686+ $s .= $this->makeBrokenImageLinkObj( $title, '', '', '', '', $time==true );
685687 $zoomicon = '';
686688 } elseif ( !$thumb ) {
687689 $s .= htmlspecialchars( wfMsg( 'thumbnail_error', '' ) );
@@ -711,14 +713,15 @@
712714 * @param string $query Query string
713715 * @param string $trail Link trail
714716 * @param string $prefix Link prefix
 717+ * @param bool $time, a file of a certain timestamp was requested
715718 * @return string
716719 */
717 - public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '' ) {
 720+ public function makeBrokenImageLinkObj( $title, $text = '', $query = '', $trail = '', $prefix = '', $time = false ) {
718721 global $wgEnableUploads;
719722 if( $title instanceof Title ) {
720723 wfProfileIn( __METHOD__ );
721 - $currentFile = wfFindFile( $title );
722 - if( $wgEnableUploads && !$currentFile ) {
 724+ $currentExists = $time ? ( wfFindFile( $title ) != false ) : false;
 725+ if( $wgEnableUploads && !$currentExists ) {
723726 $upload = SpecialPage::getTitleFor( 'Upload' );
724727 if( $text == '' )
725728 $text = htmlspecialchars( $title->getPrefixedText() );

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r30820If a link is made to an old version of an image that doesn't exists, but a cu...aaron03:04, 11 February 2008

Status & tagging log