From a27383b6723f63dfa683f43af71ed71924912b5e Mon Sep 17 00:00:00 2001 From: Antoine Musso Date: Fri, 2 Feb 2007 16:22:22 +0000 Subject: [PATCH] Fix #8858 : handle $wgImageLimits changes correctly --- RELEASE-NOTES | 2 ++ includes/DefaultSettings.php | 7 +++++-- includes/ImagePage.php | 8 +++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 0673d18d91..9eb36e226a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -161,6 +161,8 @@ lighter making things easier to read. * (bug 8535) Allow certain vertical alignment attributes to be used as image keywords * (bug 6987) Allow perrow, widths, and heights attributes for +* (bug 8858) Safer handling when $wgImageLimits is changed. Added a note + in DefaultSettings to make it clear. == Languages updated == diff --git a/includes/DefaultSettings.php b/includes/DefaultSettings.php index 15ac0442f5..fc99c0ae93 100644 --- a/includes/DefaultSettings.php +++ b/includes/DefaultSettings.php @@ -1858,8 +1858,11 @@ $wgExtraNamespaces = NULL; /** * Limit images on image description pages to a user-selectable limit. In order - * to reduce disk usage, limits can only be selected from a list. This is the - * list of settings the user can choose from: + * to reduce disk usage, limits can only be selected from a list. + * The user preference is saved as an array offset in the database, by default + * the offset is set with $wgDefaultUserOptions['imagesize']. Make sure you + * change it if you alter the array (see bug 8858). + * This is the list of settings the user can choose from: */ $wgImageLimits = array ( array(320,240), diff --git a/includes/ImagePage.php b/includes/ImagePage.php index fda8f132bf..e7fdda6a20 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -172,9 +172,15 @@ class ImagePage extends Article { $anchoropen = ''; $anchorclose = ''; $sizeSel = intval( $wgUser->getOption( 'imagesize') ); - if( !isset( $wgImageLimits[$sizeSel] ) ) { $sizeSel = User::getDefaultOption( 'imagesize' ); + + // The user offset might still be incorrect, specially if + // $wgImageLimits got changed (see bug #8858). + if( !isset( $wgImageLimits[$sizeSel] ) ) { + // Default to the first offset in $wgImageLimits + $sizeSel = 0; + } } $max = $wgImageLimits[$sizeSel]; $maxWidth = $max[0]; -- 2.20.1