r22566 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r22565‎ | r22566 | r22567 >
Date:15:38, 30 May 2007
Author:tstarling
Status:old
Tags:
Comment:
Used Image::newFromTitle() as per Brion's suggestion
Modified paths:
  • /trunk/extensions/FileSearch/FileSearchIndexer.php (modified) (history)
  • /trunk/extensions/Filepath/SpecialFilepath_body.php (modified) (history)
  • /trunk/extensions/ImageMap/ImageMap_body.php (modified) (history)
  • /trunk/extensions/Logo/Logo.php (modified) (history)
  • /trunk/extensions/News/NewsRenderer.php (modified) (history)
  • /trunk/extensions/PicturePopup/PicturePopup_body.php (modified) (history)
  • /trunk/extensions/Player/PlayerClass.php (modified) (history)
  • /trunk/extensions/ProofreadPage/ProofreadPage.php (modified) (history)
  • /trunk/extensions/SmoothGallery/SmoothGallery.php (modified) (history)

Diff [purge]

Index: trunk/extensions/ImageMap/ImageMap_body.php
@@ -83,8 +83,8 @@
8484 $thumbWidth = $imageNode->getAttribute('width');
8585 $thumbHeight = $imageNode->getAttribute('height');
8686
87 - $imageObj = function_exists( 'wfFindFile' ) ? wfFindFile( $imageTitle ) : new Image( $imageTitle );
88 - if ( !$imageObj || !$imageObj->exists() ) {
 87+ $imageObj = Image::newFromTitle( $imageTitle );
 88+ if ( !$imageObj->exists() ) {
8989 return self::error( 'imagemap_invalid_image' );
9090 }
9191 # Add the linear dimensions to avoid inaccuracy in the scale
Index: trunk/extensions/SmoothGallery/SmoothGallery.php
@@ -215,9 +215,9 @@
216216
217217 foreach ( $title_arr as $title ) {
218218 //Get the image object from the database
219 - $img_obj = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
 219+ $img_obj = Image::newFromTitle( $title );
220220
221 - if ( !$img_obj || !$img_obj->exists() ) {
 221+ if ( !$img_obj->exists() ) {
222222 //The user asked for an image that doesn't exist, let's
223223 //add this to the list of missing objects and not output
224224 //any html
Index: trunk/extensions/FileSearch/FileSearchIndexer.php
@@ -47,8 +47,8 @@
4848 if( $namespace == NS_IMAGE ) {
4949 wfDebugLog( 'filesearch', "Update called for `{$title}`" );
5050 $titleObj = Title::makeTitle( NS_IMAGE, $title );
51 - $image = function_exists( 'wfFindFile' ) ? wfFindFile( $titleObj ) : new Image( $titleObj );
52 - if ( !$image || !$image->exists() ) {
 51+ $image = Image::newFromTitle( $titleObj );
 52+ if ( !$image->exists() ) {
5353 wfDebugLog( 'filesearch', "Image does not exist: $title" );
5454 return;
5555 }
Index: trunk/extensions/Player/PlayerClass.php
@@ -49,8 +49,8 @@
5050 static function newFromTitle( $title, $options, $sizeDefault = 'imagesize' ) {
5151 loadPlayerI18n();
5252
53 - $image = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
54 - if ( !$image || !$image->exists() ) {
 53+ $image = Image::newFromTitle( $title );
 54+ if ( !$image->exists() ) {
5555 throw new PlayerException(wfMsg("player-not-found"), 404);
5656 }
5757
Index: trunk/extensions/Logo/Logo.php
@@ -23,8 +23,8 @@
2424 if( is_object( $title ) ) {
2525 if( $title->getNamespace() != NS_IMAGE )
2626 $title = Title::makeTitle( NS_IMAGE, $title->getText() );
27 - $logo = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
28 - if( $logo && $logo->exists() )
 27+ $logo = Image::newFromTitle( $title );
 28+ if( $logo->exists() )
2929 $wgLogo = $wgLogoAutoScale ? $logo->createThumb( 135 ) : $logo->getUrl();
3030 }
3131 }
Index: trunk/extensions/ProofreadPage/ProofreadPage.php
@@ -108,8 +108,8 @@
109109 return true;
110110 }
111111
112 - $image = function_exists( 'wfFindFile' ) ? wfFindFile( $imageTitle ) : new Image( $imageTitle );
113 - if ( $image && $image->exists() ) {
 112+ $image = Image::newFromTitle( $imageTitle );
 113+ if ( $image->exists() ) {
114114 $width = intval( $image->getWidth() );
115115 $height = intval( $image->getHeight() );
116116 if($m[2]) {
Index: trunk/extensions/PicturePopup/PicturePopup_body.php
@@ -64,8 +64,8 @@
6565 }
6666
6767 function ajaxNoCache( $sizeSel ) {
68 - $image = function_exists( 'wfFindFile' ) ? wfFindFile( $this->mTitle ) : new Image( $this->mTitle );
69 - if ( !$image || !$image->exists() ) {
 68+ $image = Image::newFromTitle( $this->mTitle );
 69+ if ( !$image->exists() ) {
7070 return self::jsonError( 'picturepopup_no_image' );
7171 }
7272 $licenseData = $this->getImageLicenseMetadata( $this->mTitle );
Index: trunk/extensions/Filepath/SpecialFilepath_body.php
@@ -28,7 +28,7 @@
2929 $cform = new FilepathForm( $title );
3030 $cform->execute();
3131 } else {
32 - $file = function_exists( 'wfFindFile' ) ? wfFindFile( $title ) : new Image( $title );
 32+ $file = Image::newFromTitle( $title );
3333 if ( $file && $file->exists() ) {
3434 $wgOut->redirect( $file->getURL() );
3535 } else {
Index: trunk/extensions/News/NewsRenderer.php
@@ -613,7 +613,10 @@
614614
615615 $ticon = $icon ? Title::newFromText($icon, NS_IMAGE) : NULL;
616616 if ( $ticon ) {
617 - $image = function_exists( 'wfFindFile' ) ? wfFindFile( $ticon ) : new Image( $ticon );
 617+ $image = Image::newFromTitle( $ticon );
 618+ if ( !$image->exists() ) {
 619+ $image = false;
 620+ }
618621 } else {
619622 $image = false;
620623 }