Fix #8858 : handle $wgImageLimits changes correctly
authorAntoine Musso <hashar@users.mediawiki.org>
Fri, 2 Feb 2007 16:22:22 +0000 (16:22 +0000)
committerAntoine Musso <hashar@users.mediawiki.org>
Fri, 2 Feb 2007 16:22:22 +0000 (16:22 +0000)
RELEASE-NOTES
includes/DefaultSettings.php
includes/ImagePage.php

index 0673d18..9eb36e2 100644 (file)
@@ -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 <gallery>
+* (bug 8858) Safer handling when $wgImageLimits is changed. Added a note
+  in DefaultSettings to make it clear.
 
 
 == Languages updated ==
index 15ac044..fc99c0a 100644 (file)
@@ -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),
index fda8f13..e7fdda6 100644 (file)
@@ -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];