From b5250860122e724110140f403e656528ab978801 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 6 Dec 2004 14:51:18 +0000 Subject: [PATCH] 1014 fix from REL1_4 --- includes/Image.php | 9 +++++++-- includes/ImagePage.php | 12 ++++++++++-- includes/User.php | 36 ++++++++++++++++++++++++++++++------ 3 files changed, 47 insertions(+), 10 deletions(-) diff --git a/includes/Image.php b/includes/Image.php index 52bca6e9e1..654048e5d5 100644 --- a/includes/Image.php +++ b/includes/Image.php @@ -191,7 +191,11 @@ class Image function getSize() { $st = stat( $this->getImagePath() ); - return $st['size']; + if( $st ) { + return $st['size']; + } else { + return false; + } } /** @@ -554,7 +558,8 @@ class Image function getFullPath( $fromSharedRepository = false ) { global $wgUploadDirectory, $wgSharedUploadDirectory; - + global $wgHashedUploadDirectory, $wgHashedSharedUploadDirectory; + $dir = $fromSharedRepository ? $wgSharedUploadDirectory : $wgUploadDirectory; $ishashed = $fromSharedRepository ? $wgHashedSharedUploadDirectory : diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 0a28e55f94..6b52070614 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -46,8 +46,16 @@ class ImagePage extends Article { $url = $this->img->getViewURL(); $anchoropen = ''; $anchorclose = ''; - if ( $wgUseImageResize && $wgUser->getOption( 'imagesize' ) != '' ) { - $max = $wgImageLimits[ intval( $wgUser->getOption( 'imagesize' ) ) ]; + if ( $wgUseImageResize ) { + if( $wgUser->getOption( 'imagesize' ) == '' ) { + $sizeSel = User::getDefaultOption( 'imagesize' ); + } else { + $sizeSel = IntVal( $wgUser->getOption( 'imagesize' ) ); + } + if( !isset( $wgImageLimits[$sizeSel] ) ) { + $sizeSel = User::getDefaultOption( 'imagesize' ); + } + $max = $wgImageLimits[$sizeSel]; $maxWidth = $max[0]; $maxHeight = $max[1]; } diff --git a/includes/User.php b/includes/User.php index d9aa940dde..90b2dfeb55 100644 --- a/includes/User.php +++ b/includes/User.php @@ -177,9 +177,18 @@ class User { * a language object. */ function loadDefaultFromLanguage(){ - $fname = 'User::loadDefaultFromLanguage'; - wfProfileIn( $fname ); - + $this->mOptions = User::getDefaultOptions(); + } + + /** + * Combine the language default options with any site-specific options + * and add the default language variants. + * + * @return array + * @static + * @access private + */ + function getDefaultOptions() { /** * Site defaults will override the global/language defaults */ @@ -193,9 +202,24 @@ class User { $defOpt['variant'] = $variant; $defOpt['language'] = $variant; - $this->mOptions = $defOpt; - - wfProfileOut(); + return $defOpt; + } + + /** + * Get a given default option value. + * + * @param string $opt + * @return string + * @static + * @access public + */ + function getDefaultOption( $opt ) { + $defOpts = User::getDefaultOptions(); + if( isset( $defOpts[$opt] ) ) { + return $defOpts[$opt]; + } else { + return ''; + } } /** -- 2.20.1