Commit graph

151 commits

Author SHA1 Message Date
Vivek Ghaisas
5132a68683 Remove multiple empty lines in functions
Functions must not contain multiple empty lines in a row
(Squiz.WhiteSpace.SuperfluousWhitespace sniff).

Bug: T102774
Change-Id: Ib706e4fc34b95c0d7c887e54af0ea61227767d8f
2015-06-17 13:30:57 +03:00
Vivek Ghaisas
9f5b6f5aeb Fix whitespace issues around parentheses
Fix issues found by MediaWiki.WhiteSpace.SpaceyParenthesis sniff.

Bug: T102617
Change-Id: Iec7f71e64081659fba373ec20d9d2006306a98f4
2015-06-16 22:14:02 +03:00
Kunal Mehta
f6e5079a69 Use mediawiki/at-ease library for suppressing warnings
wfSuppressWarnings() and wfRestoreWarnings() were split out into a
separate library. All usages in core were replaced with the new
functions, and the wf* global functions are marked as deprecated.

Additionally, some uses of @ were replaced due to composer's autoloader
being loaded even earlier.

Ie1234f8c12693408de9b94bf6f84480a90bd4f8e adds the library to
mediawiki/vendor.

Bug: T100923
Change-Id: I5c35079a0a656180852be0ae6b1262d40f6534c4
2015-06-11 18:49:29 +00:00
Timo Tijhof
70429dc8a2 Use HttpStatus::header instead of manually crafting header()
Also:
* Update wfHttpError() to use uppercase DOCTYPE, to match other code
  such as Html.php, wfThumbError(), HttpError.php, etc.

Change-Id: I4027e7fe1a138b03f78797b6d1bfe7bd1064d360
2015-06-04 02:27:35 +00:00
Timo Tijhof
f57b6af45b WebResponse: Implement statusHeader() using the new HttpStatus::header()
* Convert existing use of WebResponse::header() for HTTP status headers
  to use this new statusHeader() method.

* Extend unit test forFauxResponse.

I'm not calling HttpStatus::header directly in code. We keep the abstraction
layer of WebResponse so that responses can continue to be mocked/fauxed without
affecting the outer HTTP response.

Change-Id: I8a536e16659fa88b54cffa1457efb889efa5fcd6
2015-06-04 02:27:30 +00:00
Aaron Schulz
016fd0b776 Refactored entry points to have uniform shutdown handling
* Added doPreOutputCommit() and doPostOutputShutdown(),
  which most entry points just using the later
* Also fixed problem where text profiling did not show up
* Avoid calling triggerJobs() in the file streaming
  entry points

Bug: T100127
Bug: T100085
Change-Id: Ibc7e768fd483389a01847f08cdeba4058c853d3f
2015-05-29 20:40:46 +00:00
Chad Horohoe
63c7b003c4 wfRunHooks() -> Hooks::run() in remaining entry point files
Change-Id: I074deaa7dabc9512812a0ec76a8cc2ea4535a484
2015-04-27 21:37:20 -07:00
Gergő Tisza
9859521e78 Return HTTP 500 not 200 from thumb.php when streaming fails
Bug: T92545
Change-Id: Id40a8f401232cc7b9ca102a2866957f80c5ec8a3
2015-03-12 22:50:19 +00:00
jenkins-bot
e6696ed611 Merge "Handle missing width nicely in thumb.php" 2015-02-11 09:09:54 +00:00
Gergő Tisza
769e7e339e Handle missing width nicely in thumb.php
Bug: T88508
Change-Id: I2cbe4ab914a9edba71461b194151938feeafeb11
2015-02-10 19:40:49 +00:00
jenkins-bot
8ad81cbb75 Merge "Make thumb.php respond with HTTP 400 (not 500) on invalid parameters" 2015-02-10 08:29:47 +00:00
Brion VIBBER
3409636b72 Merge "Move wfThumbIsStandard() to GlobalFunctions and add tests" 2015-02-06 18:47:31 +00:00
Fomafix
0e32146627 thumb.php: Generate valid HTML code on error page
http://validator.w3.org/check?uri=https%3A%2F%2Fwww.mediawiki.org%2Fw%2Fthumb.php;No200=1

criticize

Error Line 1, Column 1: no document type declaration; implying "<!DOCTYPE HTML SYSTEM>"

Change-Id: I8dcb6c7f342957ec473fe481aef2011a193ef8a5
2015-02-05 11:59:34 +00:00
Timo Tijhof
39ac4fa5a4 Move wfThumbIsStandard() to GlobalFunctions and add tests
Change-Id: Ife9c011a476a4022cd72d433497944cbd7258e67
2015-02-04 19:50:06 -08:00
Gergő Tisza
5cea189b1b Make thumb.php respond with HTTP 400 (not 500) on invalid parameters
Bug: T88412
Change-Id: I21d34a3fb52992e51122ab7c07a38e946a55c680
2015-02-05 00:26:38 +00:00
Chad Horohoe
aa21e125a3 Remove obvious function-level profiling
Xhprof generates this data now. Custom profiling of various
sub-function units are kept.

Calls to profiler represented about 3% of page execution
time on Special:BlankPage (1.5% in/out); after this change
it's down to about 0.98% of page execution time.

Change-Id: Id9a1dc9d8f80bbd52e42226b724a1e1213d07af7
2015-01-07 11:14:24 -08:00
jenkins-bot
d34a6ca677 Merge "Fix some stuttering in comments and documentation" 2014-12-17 22:28:27 +00:00
Ricordisamoa
12dec5d85d Fix some stuttering in comments and documentation
Change-Id: I9c0088b9aab37335203cad45a1d6fa8ac3f43321
2014-12-17 19:44:10 +00:00
Kunal Mehta
a8c2cda231 thumb.php: Set proper output formats for messages going into HTML
* Use ->parse() instead of ->text() for wikitext messages that were
  being treated as HTML
* Explicitly specify ->parse() if no output format was set
* Document that wfThumbError() takes HTML

Bug: T76686
Change-Id: Id6e7548b2e081cfda7803772ed0395a15feb1f84
2014-12-17 19:11:52 +01:00
Chad Horohoe
74c8bea769 Per 5a4a33a, remove support for magic quotes gpc
Change-Id: I6110b843e6c6ef3431206d25b8fd72ed4f113ee8
2014-09-22 15:01:56 -07:00
umherirrender
21e0c1c533 Correct variable names in @param to match method declarations
Some @param have a typo in the variable name,
some @param's were in wrong order.

Change-Id: Ie25806831027112b398f6f4a909c59147ac3a5fa
2014-08-13 21:48:28 +02:00
rillke
c31fbf073e Unify the spelling of MIME in documentation
Writing MIME as written in Wikipedia and some documentation clean up.

Change-Id: I9dfc36d2bf55d72d9374c4075bd6d45eef0415a4
2014-08-07 23:38:45 +02:00
jenkins-bot
3d53f0acbd Merge "Avoid function calls in the loop condition of a for statement" 2014-07-24 19:51:16 +00:00
umherirrender
2c6bba5e9b Avoid function calls in the loop condition of a for statement
Change-Id: I64d9ba96797085b6f54658218404a02d4087ceaf
2014-07-24 19:45:53 +00:00
umherirrender
d15f1cc5e1 Break some long lines in maintenance, skins, tests
Change-Id: I5d86ad3e0c90e09440268a670f5af3e2bf080612
2014-07-24 19:03:17 +02:00
umherirrender
53c420e278 Fixed spacing
- use tab as indent instead of spaces
- Added space after closures "function"
- Added spaces around string_concat
- Added newline inside empty blocks
- Removed four spaces after comma

Change-Id: I4425b0c6a69b36f40acfea6511b8950cf09ce2b2
2014-07-20 21:41:41 +02:00
Sergio Santoro
2e741ad641 thumb.php: Fix undefined variable $width
Follows-up 5ca94d2d26.

In thumb.php an undefined variable ($width) was used, triggering
fatal errors while processing requests that were passing thumbnail
width with px (pixel) suffix.

Change-Id: I2dc4f4d2979f8225d2a6211ec50cdc79438539a9
2014-07-09 21:46:15 +00:00
Brian Wolff
e3bb925b9c Do thumb attempt-failures limitting via sha1 instead of name.
Otherwise if there is a broken file, and somebody fixes the file,
it could take an hour before thumbs are generated again. This
might confuse the user, and they may revert back to the broken
version thinking their fix didn't work.

Originally reported by Fae on wiki.

Change-Id: I024702391e5f7ccf10a406a29485601f64069405
2014-06-29 21:24:18 -03:00
Gergő Tisza
3ee07d8bb4 Use separate PoolCounter config for expensive thumbnails
Depends on Ic62984e0f4a761642b2bdd1bfa362301ed94c284
and If40e223c328ddd15310d13f2a49000bf6e08200e

Bug: 65691
Change-Id: Ic737673b5a31974d866b9bf5afa4b4036baa03bb
2014-06-27 19:39:47 +00:00
Faidon Liambotis
5ca94d2d26 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
2014-05-11 16:58:14 +02:00
Aaron Schulz
5d286fad03 Added missing File::RENDER_NOW flag to thumb.php
Change-Id: I5f05b09272ebcad5cf8409af7ad61d9e9004a2f0
2014-05-02 16:33:14 -07:00
Aaron Schulz
a530be17cf Made wfThumbIsStandard() aware of the width/height handler scaling choice
* Generally, either the height or width is used for each description page
  link when using $wgImageLimits. This depends on the $wgImageLimits values
  and the file dimensions. Description page links should better pass the
  wfThumbIsStandard() method now, and thus have weaker rate-limiting.

Change-Id: Id1c3b0fc57f8ed3c14929a1a1661842a069b805d
2014-05-01 00:08:29 +00:00
jenkins-bot
5c2f1dc5c0 Merge "Fixed "getCachedWork" callback in thumb.php to avoid 404s in the stream method" 2014-04-30 17:44:17 +00:00
Aaron Schulz
41730cbfb9 Fixed "getCachedWork" callback in thumb.php to avoid 404s in the stream method
Change-Id: Id3781b87023291b9f7b2c7b3d8ae429a4065c227
2014-04-30 10:38:25 -07:00
Aaron Schulz
40e5324ece Moved isDeleted() check down to avoid information leakage in thumb.php
Change-Id: Idcbf79ef7c82f5bcf3c0ab1002fde2201d81313f
2014-04-30 00:51:35 -07:00
Aaron Schulz
b0de7c7c60 Tweaked wfThumbIsStandard() to recognize handler-specific default parameters
* Now thumbnails with default lossy/lossless values will still count as "standard",
  for example. This makes use of the file media handler.

Change-Id: Ia69301dfbf85bb26a17f8eee0939d690021343ec
2014-04-29 14:39:05 -07:00
Aaron Schulz
5c57d22894 Randomize thumbnail failure key TTL a bit to avoid stampedes
Change-Id: Ibf268b646a9eb2acfaa649d634c5278133091158
2014-04-25 11:33:10 -07:00
Aaron Schulz
89d85a4be4 Added pool counter support for all thumb.php requests
* This can limit how many workers work on a given file at once,
  regardless of which specific thumbnail parameters are requested.
* Also added a BagOStuff::incrWithInit() method per DRY.
* Tweaked the register_shutdown_function() callback to avoid
  File/MediaTransformOutput references, since they may involve
  TempFSFile objects.

Change-Id: Ic01461cb974ab23b179ac3b60cf6de12e36360f6
2014-04-23 20:57:17 +00:00
Aaron Schulz
c993ec0095 Avoid uncommitted transaction notices in thumb.php and img_auth.php
bug: 56269
Change-Id: I8cf5c070899d281c7efbac853f04c2fea9374e4d
2014-04-22 15:40:42 +00:00
Aaron Schulz
c81e91d4fe Lowered limit for wfThumbIsAttemptThrottled() to 4
Change-Id: I2d91647abdaff820eb87b0bd45505ffa1fbc25fe
2014-04-21 11:19:52 -07:00
jenkins-bot
41f9342538 Merge "thumb.php and img_auth.php cleanups" 2014-04-21 17:50:32 +00:00
jenkins-bot
b26e232708 Merge "Call wfThumbIncrAttemptFailures() in thumb.php on fatals" 2014-04-21 16:34:29 +00:00
Aaron Schulz
3e7cdbf63a Call wfThumbIncrAttemptFailures() in thumb.php on fatals
Change-Id: I3dbe07d12abdc265d377cd05bb87c837df156995
2014-04-21 09:27:04 -07:00
Aaron Schulz
0f9d78eb07 thumb.php and img_auth.php cleanups
* Specifically check isDeleted() instead of relying on the file
  being moved to the deleted zone alone.
* Made img_auth.php skip some unnecessary checks for public wikis.
  Also made it set the private cache control headers only if needed.

Change-Id: If82589acd53c02943d5f3bbafd29381fd63f8f68
2014-04-20 17:11:33 -07:00
Aaron Schulz
4f2324fc81 Support tighter rate limiting for "non-standard" thumbnails
* Also avoid passing some junk params to File::thumbName()

Change-Id: I7e89f72ade47be7fcc7bf33f0afb970183aac936
2014-04-17 10:39:09 -07:00
umherirrender
9c614ac02d Fixed some @params documentation
Swapped some "$var type" to "type $var" or added missing types
before the $var. Changed some other types to match the more common
spelling. Makes beginning of some text in captial.

Change-Id: I8c9f30128b46086064326708a4878228ba459447
2014-04-14 19:52:18 +00:00
Gilles Dubuc
4d9e07056e Have ?download parameter trigger Content-Disposition: attachment
This parameter triggers Content-Disposition: Attachment which
makes the browser download the image instead of displaying it.

This is needed by Media Viewer to allow users to click a button in
order to download an image at a given resolution or the original.

Change-Id: I470a24a09139ac65588312104995e34d97a89b0f
2014-03-25 11:04:50 +01:00
Aaron Schulz
dc496c02d9 Limit attempts to render the same thumbnail after failures
bug: 49118
Change-Id: I9379ec445bf2e77bd3b085c00182c5e406ed300d
2014-02-12 16:55:57 -07:00
umherirrender
5dbfd5bf80 Fixed spacing
- Removed trailing spaces in comments
- Removed multiple empty lines
- Removed space after object operator

Change-Id: I9fd3256ab490c7cd2034de3fd94e6be6e6d6d8f2
2013-11-21 18:52:25 +00:00
Tim Starling
0dd1a446c8 thumb.php: map b/c params prior to attempting redirection
This should fix most of the "No width specified" exceptions. I guess
most of this code will be rewritten to fix bug 56926, superseding this
patch, but I thought this might be a useful stopgap.

Bug: 56924
Change-Id: I5bcaaafc81e1e2a8a33819fa64790d5509dc6aa6
2013-11-12 14:57:22 +11:00