Commit graph

168 commits

Author SHA1 Message Date
Gergő Tisza
c230675585 Log errors in thumb.php
Add new streamFileWithStatus() methods to FileRepo and
MediaTransformOutput that can be used to get more detailed error
information on failure. The historic streamFile() methods become sinple
wrappers to the new methods. Thumb.php is changed to use the
streamFileWithStatus() methods so that failure reasons can be logged.

Change-Id: I3088cde2044a7ff00841e53ca252d0b222c8b518
2015-11-06 19:08:24 +00:00
Brian Wolff
b47a86316d Fix name of PoolCounter callback in thumb.php
The callback is named doCachedWork, not getCachedWork. The typo
made it so that if multiple people try to render a file at once,
MediaWiki would not check if the last person to go already did the
needed work.

This might not make as much difference as it would sound, as the
pool counter lock is for the entire file, not a specific size,
and I'm unsure if swift has an equivalent of "slave lag", where the
check to see if a cached version is available might happen before
the write is totally visible.

Also merge the fallback handler into the error handler, so we get
actually error messages reported.

Change-Id: I12d228961de39cffc3d492554d93e30bd741adc9
2015-11-05 00:16:56 -07:00
Aaron Schulz
d101295ac6 Convert wfGenerateThumbnail() away from $wgMemc
Change-Id: I06c2d90cb3e75142f781afa80f917d4155513a22
2015-10-27 21:40:01 -07:00
Timo Tijhof
e8275758fe objectcache: Introduce IExpiringStore for convenient TTL constants
Also consistently use self:: instead of BagOStuff:: for constants
referenced within the BagOStuff class.

Change-Id: I20fde9fa5cddcc9e92fa6a02b05dc7effa846742
2015-10-28 04:07:25 +00:00
Vivek Ghaisas
c54766586a Fix issues identified by SpaceBeforeSingleLineComment sniff
Change-Id: I048ccb1fa260e4b7152ca5f09b053defdd72d8f9
2015-09-26 23:06:52 +00:00
Amir E. Aharoni
6408d2be80 Make lines shorter to pass phpcs in thumb.php
Bug: T102614
Change-Id: I01158675db267832a03385945d3dcdf422ddc467
2015-09-26 22:21:10 +03:00
jenkins-bot
2f3fddb0d9 Merge "Fixed and suppressed some thumb.php IDEA errors" 2015-09-01 00:45:12 +00:00
Aaron Schulz
b49e7242f7 Fixed and suppressed some thumb.php IDEA errors
Change-Id: If5ec6fd1d6d272633296b74d2d8e146feb924229
2015-08-31 10:55:37 -07:00
Gergő Tisza
8d52a21598 Return HTTP 429 when thumbnailing is throttled due to too many errors
Bug: T110109
Change-Id: I8af527661a041964690faae7566fb97e305e2b0f
2015-08-26 14:18:54 -07:00
Aaron Schulz
0bd62fe71b Reduced some instances of HTTP 500 in thumb.php
* This add noise to logs and graphs that can look like outages
  due to a single crawler.

Bug: T110109
Change-Id: Ie2a1edd0330b0f858729fcc56c828c11d9c7476c
2015-08-26 19:56:26 +00:00
Timo Tijhof
a2d6ecc453 thumb.php: Escape $rel404 in error message
Bug: T97391
Change-Id: I363686732fe9e5636c85c267c0728fc872c3e39d
2015-08-11 07:17:09 -07:00
Gilles Dubuc
f9e1ea8a04 Remove thumbnailaccess logging
Bug: T107437
Change-Id: I3c2fe7b894fc571f4f92323637340dda23099a3a
2015-08-05 10:40:58 +02:00
Giuseppe Lavagetto
304e95a333 Add Content-Length header to thumb.php redirects
Without the Content-Length header, the response is sent with
Transfer-Encoding: Chunked, which is somehow mangled by
mod_fastcgi. Varnish then claims the response is malformed and declines
to process it, sending the client a 503 instead.

This is a followup of 0ee9e717f4

Bug: T84842
Change-Id: Ia610a43789e6ff14cfc0964f285bbec39c890152
2015-07-29 16:57:45 +01:00
Gilles Dubuc
8786130244 Log thumbnail access
Bug: T106323
Change-Id: Iddd4201b13a31f441c6d25bcde6564b643cefdb4
2015-07-20 20:37:31 +02:00
Gilles Dubuc
ec60612b6f Refine thumbnailing metrics
Bug: T105681
Change-Id: Icf576a1718eb2e588af4c48c05362bbef3bb7942
2015-07-17 13:49:20 +02:00
Gilles Dubuc
103eff5bcd Record timing of thumbnail generation and store pull
Bug: T105681
Change-Id: If2edf285dc47736abde957a117ac4b40716072aa
2015-07-14 11:21:21 +02:00
Ori Livneh
0ee9e717f4 Add Content-Length header to thumb.php error responses
Without the Content-Length header, the response is sent with Transfer-Encoding:
Chunked, which is somehow mangled by mod_fastcgi. Varnish then claims the
response is malformed and declines to process it, sending the client a 503
instead.

Change-Id: I977387bf3e039926df58e3e5a14d0d0bd55201c4
2015-07-06 20:52:43 +00:00
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