From: Faidon Liambotis Date: Sun, 11 May 2014 14:57:54 +0000 (+0200) Subject: thumb.php: support an optional "px" width suffix X-Git-Tag: 1.31.0-rc.0~15764 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/password.php?a=commitdiff_plain;h=5ca94d2d26e80bb2a4ea9339a3adc31baf186d3a;p=lhc%2Fweb%2Fwiklou.git 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 --- diff --git a/thumb.php b/thumb.php index 59bf8dcffd..d7bf453382 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']; }