aboutsummaryrefslogtreecommitdiffstats
path: root/thumb.php
diff options
context:
space:
mode:
authorFaidon Liambotis <faidon@wikimedia.org>2014-05-11 16:57:54 +0200
committerFaidon Liambotis <faidon@wikimedia.org>2014-05-11 16:58:14 +0200
commit5ca94d2d26e80bb2a4ea9339a3adc31baf186d3a (patch)
tree663fdb1ba631be6c10d6fe31c1391299c26b5919 /thumb.php
parentd8f3dd8f391512fe68712c4fef229e84fa797afb (diff)
downloadmediawikicore-5ca94d2d26e80bb2a4ea9339a3adc31baf186d3a.tar.gz
mediawikicore-5ca94d2d26e80bb2a4ea9339a3adc31baf186d3a.zip
thumb.php: support an optional "px" width suffix
A large percentage (40-50%) of the 500s that are emitted in production are for a single URL, https://commons.wikimedia.org/w/thumb.php?f=Crystal_Clear_action_viewmag.png&width=21px The reason this fails is because thumb.php expects width to be "21", not "21px", and it currently tries to fetch (and generate) the "21pxpx" thumb size, which is obviously an invalid size. (an invalid size shouldn't result in a 5xx but rather to a 4xx. though; that's a separate bug that needs to be fixed). This URL is embedded by a gadget, Gadget-searchbox-js, that is copied in a lot of our wikis, including a big one, frwiki. mwgrep reveals that there are a bunch of other URLs in various Gadgets that have width values with "px" in them, so this presumably worked at some point in the past. While we could in theory fix all those URLs in these dozens of gadgets across wikis to not suffix width with "px", this sounds like a herculean effort and we're probably better off adding this compatibility branch to thumb.php that strips the "px" suffix, if existent. Change-Id: I3a00c9634b1c6af49fb8503cc3ff4cafdaff6b43
Diffstat (limited to 'thumb.php')
-rw-r--r--thumb.php4
1 files changed, 4 insertions, 0 deletions
diff --git a/thumb.php b/thumb.php
index 59bf8dcffdc8..d7bf45338241 100644
--- a/thumb.php
+++ b/thumb.php
@@ -116,6 +116,10 @@ function wfStreamThumb( array $params ) {
$params['width'] = $params['w'];
unset( $params['w'] );
}
+ if ( isset( $params['width'] ) && substr( $params['width'], -2 ) == 'px' ) {
+ // strip the px (pixel) suffix, if found
+ $params['width'] = substr( $width, 0, strlen( $width ) - 2 );
+ }
if ( isset( $params['p'] ) ) {
$params['page'] = $params['p'];
}