Commit graph

233 commits

Author SHA1 Message Date
James D. Forrester
f9f8dff40f Rename CDN config variables to be generic, deprecating the old names
Hook, methods, classes still to rename where appropriate.

Bug: T104148
Depends-On: Id34339dff88bc6d1863378ac94b96b2d590b891d
Depends-On: I4e2938395bcbf7956b83fff00978f09c61dcfa36
Change-Id: I7a725dae551c867a4fa7c213838d52c7fb862756
2019-05-24 21:09:22 +00:00
Zoranzoki21
1f2e9c1b54 Fix common typos in code
Bug: T201491
Change-Id: Id962b79f2590c51380cb977e727b7548abc11d33
2018-09-02 09:03:07 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Bartosz Dziewoński
485f66f174 Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
Find: /isset\(\s*([^()]+?)\s*\)\s*\?\s*\1\s*:\s*/
Replace with: '\1 ?? '

(Everywhere except includes/PHPVersionCheck.php)
(Then, manually fix some line length and indentation issues)

Then manually reviewed the replacements for cases where confusing
operator precedence would result in incorrect results
(fixing those in I478db046a1cc162c6767003ce45c9b56270f3372).

Change-Id: I33b421c8cb11cdd4ce896488c9ff5313f03a38cf
2018-05-30 18:06:13 -07:00
Kunal Mehta
06ca92eb8c Re-enable MediaWiki.Usage.SuperGlobalsUsage.SuperGlobals sniff
Disable it in specific files and places where there are legitimate uses
to access $_GET and $_POST directly.

For EditPage, which wants to output $_POST for debugging information,
introduce WebRequest::getPostValues() as a wrapper, matching the
existing ::getQueryValues().

Change-Id: I2cb0a7012fb7ed29dcd720056b42f56508ddc5fa
2018-05-19 15:07:25 -07:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Gilles Dubuc
a9213ccb4c Add ability to proxy thumbnail requests to a service
Bug: T169144
Change-Id: I4af09a8b75e7158d6ff15f97e8f067b66ac33d5c
2018-02-01 10:07:32 +01:00
Fomafix
84bb8c4240 thumb.php: Set ENT_NOQUOTES for htmlspecialchars
There is no need to escape double quotes in content of HTML and in HTML
comments.

ENT_NOQUOTES escapes '<', '>', '&' but not "'" and '"'.
https://secure.php.net/manual/en/function.htmlspecialchars.php

Change-Id: I7146df9582fc1d9742b9e1b0e4f03d7c7d2ed91f
2017-11-09 12:02:18 +01:00
James D. Forrester
6854fc6182 Removed deprecated ExtractThumbParameters hook
Depends-On: I827c61a5a340d4f107478174263e4a5d385398f4
Change-Id: I97e820d78d8041c40fb6e553c4081c676602462c
2017-05-15 13:17:04 +01:00
WMDE-Fisch
7b5f08e703 Replace deprecated Context::getStats() with MWServices::getStatsdDataFactory()
Change-Id: I1756f69ca2ebd301a5049bf758d1a87c37771fe6
2017-03-17 12:07:03 +01:00
James D. Forrester
e08e923935 /*.php: Replace implicit Bugzilla bug numbers with Phab ones
It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345"
except where it doesn't, so let's just standardise on the real numbers.

Change-Id: If82c31fc877249d6fa3727b79c3bb8369ad9382b
2017-02-21 02:14:48 +00:00
Gilles Dubuc
80c1e8343e Serve 400 instead of 500 when invalid thumbnail parameters are requested
This was requested because of 0px thumbnail requests, but there are
other cases where parameters are detected as invalid and 400 is
semantically more correct than 500 in that situation.

Bug: T147784
Change-Id: I4d24a93e655f04d8119e77798d5df5a45caaafcf
2016-11-29 09:50:42 +01:00
umherirrender
932c37e3cb Use english messages for background use of Status::getWikiText
Status::getWikiText is used for internal logging, api error messages and
maintenance scripts. All this places are usually in english, so pass an
english language to getWikiText.

Change-Id: I3010fca8eb5740a3a851c55a8b12e171714c78f7
2016-04-12 20:01:44 +02:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
umherirrender
54c1e18eec Remove various double empty newlines
The double empty newline is not needed between functions, variable or at
end of file

Change-Id: Ib866a95084c4601ac150a2b402cfa184ebc18afa
2015-12-27 18:55:12 +00:00
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
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
jenkins-bot
1e95602281 Merge "Support rate-limiting thumbnail generation" 2013-10-16 17:31:50 +00:00
Reedy
f7e7a5ef9a Fix "Unsupported operand types at thumb.php on line 429"
Return type of $handler->parseParamString() wasn't evaluated,
instead $handler value was compared again

Bug: 55437
Change-Id: Iedb940d9f1ad4d137b9732e7e624e55d05bc2c96
2013-10-07 19:46:02 +01:00
Aaron Schulz
43d3304ed6 Support rate-limiting thumbnail generation
* Added some rate limit comments

Change-Id: I987bb5d0ed8821d64131baefd4457acd25678818
2013-10-04 15:51:55 -07:00
jenkins-bot
265cb52243 Merge "Make thumb_handler.php use MediaHandler::parseParamString" 2013-09-30 18:11:09 +00:00
Brian Wolff
aa99e1cdfc Add a header on thumb.php saying which thumb server on error.
Only added if $wgShowHostnames is on. Adding the host name as a
header makes it much easier when debugging with command line tools,
since one often throws away the response body. This still keeps
the host name in an html comment in the response body as well,
like it was previously.

Change-Id: I9d15bd5e2abb4e7a8d3fe2a17fc546a1c5f3b70f
2013-09-28 20:41:00 -03:00
Brian Wolff
ccf89be91a Make thumb_handler.php use MediaHandler::parseParamString
Use MediaHandler::parseParamString to parse the parameter string
of a thumbnail. This seems to make much more sense given the
design of the Handler class. Also mark ExtractThumbParameters hook
as deprecated.

This should be reviewed by someone familar with the 404 thumbnailing
infrastructure. I'm unclear if there was a reason for why it wasn't
using MediaHandler::parseParamString in the first place.

Bug: 49629
Change-Id: I43a0e7d6f0e45536e4e24b72140157791f5f027f
2013-09-28 20:32:40 -03:00
Aaron Schulz
7e9f8ec1df Simplified some code and broke lines in thumb.php
Change-Id: I99fc63ab473a3f2fe33e0227e5e283e0c195f01b
2013-09-20 18:10:31 +00:00
Brian Wolff
82a8e07935 Make thumb.php give http redirects if given a file redirect
See bug 22390 for some of the background. Basically there's two
reasons why we want this:
* Hotlinkers to commons. We don't want to break their links when
we move a file (Wikimedia blog is a prominent hotlinker)
* Cached entires. On wikis using commons files, a file move doesn't
trigger HTMLCacheUpdate jobs for the downstream wiki (it only
triggers it on commons). This means that these pages will still
use the old version of the html (with img tags that have the old
url) until the next edit or purge action. But these urls won't
work as soon as the file is moved.

I'm pretty confident that redirects will work at this point
in the thumb stack, as the redirects for long file names work
fine (provided no thumb exists in swift with the wrong name).

Change-Id: I40350121cf902f66fcbd3cf788335a988fa7ee33
2013-08-27 09:22:05 -06:00
Aaron Schulz
555664ac63 Simplified some tedious profiling code
Change-Id: Ia5d56b3a38feb1b151f6821d76abbdd6b2dd9f46
2013-08-22 11:18:19 -07:00
Brian Wolff
377f8ffa07 thumb_handler.php doesn't seem to extract path_info correctly
Set $wgArticlePath so that it works the way that [[Manual:Thumb.php]]
claims it does.

Change-Id: I35b4ab73e1d84dad10503d3a098ee154e8d58d8a
2013-06-16 22:43:13 -03:00
Timo Tijhof
4bd5471ca3 docs: Remove odd colons after @todo
Most were this way already:
https://doc.wikimedia.org/mediawiki-core/master/php/html/todo.html

Ran a find/replace on the odd ones. Also made them all
lower case.

Change-Id: I70c6a69344ddebc603e9a1c1d87e3cc4f4f4c560
2013-05-15 06:23:40 +00:00
Timo Tijhof
50e7985d4d phpcs: Fix WhiteSpace.LanguageConstructSpacing warnings
Squiz.WhiteSpace.LanguageConstructSpacing:
   Language constructs must be followed by a single space;
   expected "require_once expression" but found
   "require_once(expression)"

It is a keyword (e.g. like `new`, `return` and `print`). As
such the parentheses don't make sense.

Per our code conventions, we use a space after keywords like
these. We appeared to have an unwritten exception for `require`
that doesn't make sense. About 60% of require/include usage
was missing the space and/or had superfluous parentheses.

It is as silly as print("foo") or return("foo"), it works
because keywords have no significance for whitespace between
it and the expression that follows, and since experessions can
be wrapped in parentheses for clarity (e.g. when doing string
concatenation or mathematical operations) the parenthesis
before and after basiclaly just ignored.

Change-Id: I2df2f80b8123714bea7e0771bf94b51ad5bb4b87
2013-05-09 05:56:26 +02:00
Tim Starling
1fe9340bb3 Remove hphpc support and deprecate related functions
hphpc has been superseded by hhvm, so support for hphpc is no longer
needed.

* Continue to use Preprocessor_Hash under HipHop since it is still
  faster under hhvm
* Keep $wgCompiledFiles for now, so that wikihiero doesn't give an error
  before Ic9d1e795 is merged
* Migrate the run-server script and associated configuration file to
  hhvm. Enable EnableStaticContentFromDisk since it doesn't seem
  ridiculously inefficient at first glance. Run from $IP rather than
  $IP/.. since hhvm is apparently not picky about sourcing files from
  outside of the current directory.

Change-Id: Ic3e769f1fbad4f7ad26dd819406796fee48c6b45
2013-05-09 08:28:05 +10:00
Siebrand Mazeland
655f5c6b48 Update code formatting
Change-Id: I8741b5b979e55f38a666961a16c387586a92410e
2013-02-14 13:38:19 +00:00
Aaron Schulz
a04d9cb748 Improved some thumb.php error messages.
Change-Id: I5a61e898dd97db67b719a13ca044530c4baecc99
2013-01-23 11:11:44 -08:00
Aaron Schulz
dfe02f371b (bug 42302) Fixed broken thumbnails for files with a "+" in the name.
Change-Id: Ic5764fa17e12d24ddbc77bfc0523e97ed12b0afe
2012-11-24 15:47:22 -08:00
Aaron Schulz
3fca064bfc Fixed uncaught thumbName() exceptions and use $_GET.
* Using $_REQUEST is bad since cookie data is also in there.
* Also made a few tiny code cleanups.

Change-Id: Ib7064b95a2788484d05cf457034fe1d5be298bc4
2012-11-15 17:19:08 -08:00
Aaron Schulz
c43deebfd5 Simplified thumb.php for 404 handling.
* Made thumb_handler.php "just work" in a way similar to img_auth.
  It no longer needs any "handlerUrl" setting to be set.

Change-Id: I557ba1f94db3cef0f21f5c0e2b60d8e381ea3f96
2012-11-08 17:31:05 +11:00