Commit graph

233 commits

Author SHA1 Message Date
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
Aaron Schulz
3338587604 [FileRepo] Allow different file URLs for media based on file extension.
Change-Id: Ib647377312c93c8ed046f7b9510d0e656788cdc3
2012-11-08 06:19:39 +00:00
Jan Gerber
02624d0016 Allow ExtractThumbParameters before local regexp
ExtractThumbParameters might be able to extract more params but still
match the local regexp. To be able to extract all params, check
ExtractThumbParameters first and only fallback to regexp.

Change-Id: I26efdec1af5fb2bd5e3cc503f36692d12668b2e2
2012-11-02 08:47:32 +00:00
Aaron Schulz
42c0f35133 Avoid thumb.php fatal for bad titles on private wikis.
Change-Id: Id2c19d888989fdbaad6412aa9eb62bb22a75f241
2012-10-10 11:16:28 -07:00
Aaron
56266b2ac4 Merge "Worked around hash path inconsistency to unbreak stash file thumbs." 2012-09-20 16:59:09 +00:00
Aaron Schulz
94158d6387 Don't send empty Vary headers.
Change-Id: I0b6bd7ab24323782302c28cf1438dce62f5b8c5a
2012-09-19 21:18:19 -07:00
Aaron
3bbb73468a Worked around hash path inconsistency to unbreak stash file thumbs.
Change-Id: I567467b75a600841440b36352d5675866d3fca2b
2012-09-19 17:45:39 -07:00
Aaron Schulz
e456ef4a0e (bug 39975) Fixed thumb_handler.php handling of /temp thumb urls.
This basically makes the 'rel404' param for temp thumbanils not
start with "/temp" anymore so that they don't count as bogus.

Change-Id: I88c2c50b5372c7b95108d26ba16ddcd91fdb1154
2012-09-18 11:47:27 -07:00
Tim Starling
f1d13a6653 Add Vary: X-Forwarded-Proto to the thumb.php redirect
Also added missing return. Untested.

Change-Id: I975b82d18ba98d1d9b1f2124150af9e5c41f418e
2012-09-12 21:17:37 +00:00
Aaron
97832b6b1d thumb.php now handles short and long thumbnail name formats when possible.
Change-Id: I33932ac0e0294dc13332dce9d4ab00a75d9cdcba
2012-09-12 21:17:09 +00:00
Aaron Schulz
5fbef994cf Revert "thumb.php now handles short and long thumbnail name formats when possible."
Doesn't quite work, since $img->transform() still saved the thumb under the normal name.

This reverts commit 5b33e66b74
2012-09-06 17:52:33 +00:00
Aaron
5b33e66b74 thumb.php now handles short and long thumbnail name formats when possible.
Change-Id: I8e53ce711e23127854185661c5ce8bddbb226623
2012-09-04 14:59:26 -07:00
Aaron Schulz
d22c890890 Fixed and normalized content-disposition for thumbs.
* Previously, thumbnails could have a hex tmp file name as the disposition.

Change-Id: I495860dc54c02d2b3e053e998a41674cd6d07f2f
2012-08-31 22:32:47 -07:00
Tim Starling
ad03f2f753 Revert Uri class due to bug 39710
Revert 94f623363b. Apparently all
ReverseChronologicalPager subclasses were broken by the unexplained
interface change in wfArrayToCgi(): changing the interpretation of
null array values from "omit this key" to "include this key with no
value". The function has always been called with the former
interpretation, that's why the special case was in there.

Also reverted dependent changes 4b517fa and part of 3d97704.

Change-Id: I41dadbde5d0e0e4c54cc76bfc13c263c15c73828
2012-08-28 10:53:09 +10:00
jeroendedauw
38c7f444e1 Use __DIR__ instead of dirname( __FILE__ )
We can now do this since we finally switched to PHP 5.3 for MW 1.20 and get rid of the silly dirname(__FILE__) stuff :)

Change-Id: Id9b2c9cd2e678197aa81c78adced5d1d31ff57b1
2012-08-27 21:45:00 +02:00
Siebrand Mazeland
3d97704f91 Replace some deprecated method calls.
Change-Id: Id4beca7b6821139fcc319c5694917e68668835ee
2012-08-19 23:27:43 +02:00
Alex Monk
2fabea7eea Use wfMessage instead of deprecated wfMsg*
Or $this->msg in special pages.

Change-Id: I774a89d646615053c8424050e42ad95601f92543
2012-08-18 14:11:05 +02:00
Aaron
25fe23a403 Various thumb.php fixes.
* Made wfThumbHandle404() handle full REQUEST_URI urls.
* Made wfExtractThumbParams() handle protocal relative zone urls.
* Added FileRepo::getZoneHandlerUrl() and site zone configuration to simplify wmf rewrite rules.
* Renamed some variables to be less misleading.

Change-Id: Ic3e23c2a623c1241ee22a9811aee073fb07aa68c
2012-07-26 13:59:07 -07:00
Alexandre Emsenhuber
f27ff698fb Added missing GPLv2 headers in some places.
Also made file documentation more consistent.

Change-Id: I30e124514396f110a572467b94ca06cefd5f7b46
2012-05-23 13:41:30 +02:00
Aaron Schulz
8667a6354d [FileRepo] Added support for temp file repos (to preserve our thumb.php hack).
* Added FileRepo::getTempRepo() to get a temporary repo similiar to the one used in wmf1.19 thumb.php.
* Merged and cleaned up wmf1.19 code into thumb.php to handle temp files and thumbnails.

Change 1: prevent FileRepo::getTempRepo() from being called on the result of FileRepo::getTempRepo().

Change 2: made FileRepo::getTempRepo() account for cases when the 'directory' param is not the empty string.

Change 3:
* Tweaked TempFileRepo to override getTempRepo() to enforce restriction.
* Added FileRepo::getTempHashPath() and used in thumb.php to get the correct path.

Change-Id: I2937b5ffb3ec9a7e2741b42bc28dc76833053fcd
2012-04-06 15:55:44 -07:00
Platonides
9951f9f9ae trunk/phase3 is now mediawiki/core
Change-Id: Ief2721ee6573a5e54a276c91de636d9e1a678b8b
2012-03-23 17:19:22 +01:00
Sam Reed
356799f95a Drag in a change noticed in wmf branches 2012-02-11 15:14:15 +00:00
Aaron Schulz
224dfaeb33 * Removed thumb.php comment about ProofreadPage, page numbers are more general.
* Added ExtractThumbParameters hook handlers for ogg and tiff handler extensions.
2012-02-10 20:52:57 +00:00
Aaron Schulz
30ed85146a r111076: url decode the 'rel404' path...*ahem*. Archived files and files with special chars are otherwise broken. 2012-02-10 01:35:13 +00:00
Aaron Schulz
5e91795785 (bug 34231) - 'Make thumb.php error or redirect for urls with bogus paths but valid file & thumb names.' 2012-02-09 19:45:12 +00:00
Aaron Schulz
8f0814e64c Similar to r108937: fixed breakage where the zone urls were defined as relative paths. 2012-01-20 20:52:09 +00:00
Aaron Schulz
cae80e3738 r105512: Handle REDIRECT_URL discrepancies and always work with URI paths for thumb 404 handling 2012-01-14 19:17:17 +00:00
Aaron Schulz
5a6559d8b1 Reverted r108743 per CR comment. This should at least be discussed first. 2012-01-12 19:41:18 +00:00
Sam Reed
a5c200a25b Kill "* @return void" 2012-01-12 19:12:24 +00:00
Aaron Schulz
c8a0908bdf FU r105512: urldecode() the file and thumb name in wfExtractThumbParams() for 404 handling as needed. 2011-12-22 00:43:11 +00:00
Aaron Schulz
5275f9b097 Merged FileBackend branch. Manually avoiding merging the many prop-only changes SVN likes to sprinkle in (easy to spot from the change list). Did not add SwiftFileBackend.php as it still is in development. 2011-12-20 03:52:06 +00:00
Robin Pepermans
be2de16942 update all core usage of deprecated Title::userCanRead() 2011-12-13 11:05:30 +00:00
Aaron Schulz
056651c3f0 FU r105512: just always use thumb.php style errors 2011-12-08 04:58:26 +00:00
Aaron Schulz
dcbe8e7dd3 FU r101117: removed cURL thumb handler code and made thumb_handler.php a thin wrapper around thumb.php
* Moved original URL fetching code and parameter extraction code to thumb.php
* Made use of local repo URL and hash settings to avoid extra config code
* This makes it easy to add hooks for extensions/config to alter behavoir (ExtractThumbParameters hook added)
* Added FileRepo::getHashLevels()
2011-12-08 03:43:07 +00:00
Aaron Schulz
3a6b5d6005 FU r100535:
* Thumb handler can now also work without cURL
* Combined related config vars into array config vars
* Folded $thgThumb404File into $thgThumbCallbacks
* Avoided some global pollution
2011-10-28 05:12:12 +00:00
Aaron Schulz
12b7bfe233 More whitespace tweaks...and fixed doc typo 2011-10-20 19:05:48 +00:00
Aaron Schulz
ed74ccc6da Minor code style cleanups and tweaks 2011-10-19 00:14:13 +00:00
Sam Reed
d90b987ade Fix whitespace, braces
Fix return items
2011-10-15 22:58:42 +00:00
Chad Horohoe
1a1e917c86 Move wfStreamFile() into a class, update all callers in core (only 3 extensions use it afaict), leave wfStreamFile() as a b/c alias for now.
Yay less global functions, autoloading and less manual require()s.
2011-08-13 19:03:51 +00:00
Tim Starling
ff1dc8a175 HipHop improvements:
* Added the ability to compile extensions. The build process is bootstrapped by running MediaWiki in interpreted mode. Extension setup file inclusions are slightly modified in a way that makes them register themselves for compilation. Then the same LocalSettings.php uses the compiled extension setup file when the compiled binary runs.
* Tested with Cite and ParserFunctions. The code which lets you have an extensions directory in a place other than $IP/../extensions is untested.
* Simplified WebStart.php slightly by using a custom $_SERVER variable to mark compiled mode. It will break if you don't use the supplied server.conf, but that will break a lot of things so don't do that.
* Fixed the core web entry points to include WebStart.php in compiled mode instead of interpreted.
* Made the build directory configurable. This is mostly so that I can grep the source tree without seeing loads of generated C++.
* In server.conf, added a rewrite rule allowing a /wiki/$1 article path.
* Removed server.conf log file location "/dev/stdout", breaks when you switch user
* Disable static content cache, breaks horribly when you set SourceRoot to a directory containing 7GB of files.
* Rewrote the run-server script in PHP, mostly to support the configurable build directory feature.
* Added an option to the run-server script to allow running in interpreted (hphpi) mode.
2011-05-30 13:49:09 +00:00
Russ Nelson
e259adbb50 Fix and add some comments. 2011-05-02 18:48:35 +00:00
Platonides
49074e8a56 Yet more additions of wfProfileOut() 2011-02-10 16:39:53 +00:00
Alexandre Emsenhuber
6af90c193f Removed error suppression operators (per bug 24159) 2010-07-18 13:16:18 +00:00
Tim Starling
2e3023a464 Fix data leakage from thumb.php for wikis where access to images is restricted (e.g. using img_auth.php). For backport to 1.15. 2010-03-08 22:39:14 +00:00
Brion Vibber
6c7b3f0ab6 Provisional revert of r56916 "(bug 20802) Fixed thumb.php redirect handling. Changed wfLocalFile call into RepoGroup::singleton()->getLocalRepo()->findFile"
This appears to make thumb.php more permissive than it's indended and could lead to littering false-positive thumbnails around the server when used to implement 404 handlers as designed.
2009-09-30 19:00:48 +00:00
Bryan Tong Minh
c184ebec19 (bug 20802) Fixed thumb.php redirect handling. Changed wfLocalFile call into RepoGroup::singleton()->getLocalRepo()->findFile 2009-09-25 14:23:09 +00:00
Ilmari Karonen
34fb6297cd Step 2 in NS_IMAGE -> NS_FILE transition (bug 44) (WARNING: huge commit).
This is a global search and replace of NS_IMAGE and NS_IMAGE_TALK with NS_FILE and NS_FILE_TALK respectively in all core files, excluding those already updated in step 1 (r44004).
2008-12-01 17:14:30 +00:00
Aaron Schulz
9f8228e659 revert bogus change 2008-08-13 02:09:10 +00:00
Aaron Schulz
c64c3961cd use $sourcePath here too 2008-08-13 02:05:24 +00:00
Aaron Schulz
e983e01e2c use getArchivePath() 2008-08-13 02:02:36 +00:00
Aaron Schulz
2ba5650095 use makeTitleSafe() 2008-08-13 01:24:03 +00:00
Aaron Schulz
c7b992acd3 we need a $title here 2008-08-13 01:11:45 +00:00
Aaron Schulz
a52e560d2c check 'archived' param 2008-08-13 01:01:58 +00:00
Brion Vibber
95b4aef2dc replace live hack: include debug info in thumb.php (switch it in with $wgShowHostnames) 2008-06-19 23:22:03 +00:00
Alexandre Emsenhuber
087a9f70c5 WARNING: HUGE COMMIT
Doxygen documentation update:
* Changed alls @addtogroup to @ingroup. @addtogroup adds the comment to the group description, but doesn't add the file, class, function, ... to the group like @ingroup does. See for example http://svn.wikimedia.org/doc/group__SpecialPage.html where it's impossible to see related files, classes, ... that should belong to that group.
* Added @file to file description, it seems that it should be explicitely decalred for file descriptions, otherwise doxygen will think that the comment document the first class, variabled, function, ... that is in that file.
* Removed some empty comments
* Removed some ?>

Added following groups:
* ExternalStorage
* JobQueue
* MaintenanceLanguage

One more thing: there are still a lot of warnings when generating the doc.
2008-05-20 17:13:28 +00:00
Tim Starling
d249eea8fd In thumb.php:
* Return 404 response code for missing source file and bad title
* Additionally check IMS against the source file timestamp, to allow for more aggressive purging of the server thumbnail directory.
* Refactor
2008-01-30 06:12:35 +00:00
Tim Starling
a910a32f76 Return an error message if the requested size was bigger than the source, or more generally if the "transformed" output file is in fact the source file. 2007-09-03 21:35:27 +00:00
Nick Jenkins
d466cf6e86 A few comment tag tweaks. 2007-07-11 08:09:21 +00:00
Aryeh Gregor
a15c419b3d Remove ?>'s from files. They're pointless, and just asking for people to mess with the files and add trailing whitespace. (Yes, I looked over every one and reverted those that were bogus. Slash-enter a million times in less worked well enough, although it was a bit mind-numbing.) 2007-06-29 01:19:14 +00:00
Tim Starling
ed4303922f Merged filerepo-work branch:
* Added support for configuration of an arbitrary number of commons-style file repositories.
* Split Image.php into filerepo/File.php and filerepo/LocalFile.php
* Renamed Image::getImagePath() to File::getPath()
* Added initial support for timestamp-based file fetching (OldLocalFile), to be expanded upon by aaron.
* Changed the interface for Image/File object creation: use wfFindFile() or wfLocalFile() depending on semantics
* ImageGallery::add() now accepts a title object as the first parameter
* Moved file handling operations on upload from SpecialUpload to File
* Removed path-related functions from ImageFunctions.php. Removed static path accessors from File. 
* Added a Content-Disposition header to thumb.php output
* Improved thumb.php error handling
* Updated the unit test suite to kind of partially work with modern computers. RunTests.php doesn't work just yet. Fixed an actual regression that the test suite detected -- moved some defines to Defines.php where they will be loaded consistently.
2007-05-30 21:02:32 +00:00
Tim Starling
41df695b36 Output what was asked for. Don't dirty up a clean API like thumb.php with arbitrary defaults when invalid parameters are specified. 2007-05-04 15:05:42 +00:00
Tim Starling
0f6da81bcb better error messages 2007-04-25 07:40:22 +00:00
Tim Starling
b15d8cffc4 * Introduced media handler modules for file-type specific operations: thumbnailing, img_metadata, capabilities, etc.
* Deprecated $wgUseImageResize, thumbnailing will be enabled unconditionally.
* Fixed interaction of page parameter to ImagePage with the HTML file cache
* Improved error reporting for image thumbnailing
* Fixed MIME type for SVG files, will be silently changed from image/svg to image/svg+xml after loading from the database.
* Workaround for djvutoxml bug #1704049 (poor performance). Use djvudump instead.
* Fixed odd behaviour in ImagePage on DjVu thumbnailing errors
* Improved error reporting for image thumbnailing
* Added sharpening option for ImageMagick thumbnailing
* Removed Image::selectPage(), added page parameters to getWidth() and getHeight(), deprecated Image::renderThumb() and Image::getThumbnail()
* Changed default contents of img_metadata to empty string instead of a:0:{}
* Moved responsibility for respecting $wgGenerateThumbnailOnParse from the UI to Image.php
2007-04-20 12:31:36 +00:00
Brion Vibber
2d5ac3c276 * Add 'charset' to Content-Type headers on various HTTP error responses
to forestall additional UTF-7-autodetect XSS issues. Probably not an
  issue on Apache 2.0+, but most servers send only 'text/html' by default
  when the script didn't specify more details.
    This fixes an issue with the Ajax interface error message on MSIE when
  $wgUseAjax is enabled (not default configuration); this UTF-7 variant
  on a previously fixed attack vector was discovered by Moshe BA from BugSec:
  http://www.bugsec.com/articles.php?Security=24

* Trackback responses now specify XML content type
2007-02-21 01:02:47 +00:00
Tim Starling
28dc3ec888 * Moved the main ob_start() from the default LocalSettings.php to WebStart.php.
The ob_start() section should preferably be removed from older 
  LocalSettings.php files.
* Give Content-Length header for HTTP/1.0 clients.
* Partial support for Flash cross-domain-policy filtering. Text entry points should be protected, but uploads are not.
2007-02-19 23:03:37 +00:00
Nick Jenkins
baaee13afc Prevent some unnecessary lstat system calls, generated by include or require directives.
This can be done either by:
* Using explicit full paths, using the $IP global for the installation directory full path, and then working down the tree from there.
* Using explicit full paths, using the "dirname(__FILE__)" directive to get a full directory path for the includer file. 
* Occasionally removing the line altogether, and then for some files the inclusion is handled by the autoloader.

For example, if the "extensions/wikihiero/wh_main.php" file does an include or require on "wh_list.php", then PHP does the following:
* tries to open "wiki/wh_list.php", and fails.
* tries to open "wiki/includes/wh_list.php", and fails.
* tries to open "wiki/languages/wh_list.php", and fails.
* tries to open "wiki/extensions/wikihiero/wh_list.php", and succeeds.

So in this example, the first 3 calls can be prevented if PHP is told where the file is.

Testing Method: On a Linux box, run these commands to attach strace to all the apache2 processes, and log their system calls to a temporary file, then generate some activity, and then stop the strace:
-----------------------------------
rm /tmp/strace-log.txt
strace -tt -o /tmp/strace-log.txt -p `pidof apache2 | sed 's/ / -p /g'` &
php maintenance/fuzz-tester.php --keep-passed-tests --include-binary --max-runtime=3 > /tmp/strace-tests.txt
killall -9 strace
grep "No such file or directory"  /tmp/strace-log.txt | sort -u
-----------------------------------

Any failed file stats will be marked with: "-1 ENOENT (No such file or directory)".

Also:
* Strict Standards: Undefined offset:  230 in includes/normal/UtfNormal.php on line 637
* Strict Standards: iconv() [<a href='function.iconv'>function.iconv</a>]: Detected an illegal character in input string in languages/Language.php on line 776
  [Note: Partial only - despite adding "//IGNORE", it still seems to be possible with some
         messed- up binary input to cause PHP 5.1.2's iconv() function to squeal like a stuck pig].
* Update one $fname variable (method belongs to HistoryBlobStub class).
2007-02-09 05:36:56 +00:00
Tim Starling
6684c57e16 Set content type on error messages, and include a trailing newline 2006-11-12 10:44:48 +00:00
Tim Starling
42476174ba Don't cache error pages. 2006-11-08 06:33:54 +00:00
Brion Vibber
c8acd3393b * Cleaner error behavior on thumb.php with invalid page selection 2006-10-02 21:12:28 +00:00
Brion Vibber
330f20698c * (bug 6889) PHP notices in thumb.php with missing params 2006-10-02 19:46:12 +00:00
Brion Vibber
bf63ffaa2c Committed a bunch of live hacks from Wikimedia servers
A few left, but these don't look too evil
2006-10-02 17:04:13 +00:00
Jens Frank
7f7e79022b (bug 6420) Render thumbnails for djvu images, show multipage preview on image page 2006-08-13 17:34:48 +00:00
Tim Starling
3ea576aa25 Consolidated web initialisation code into includes/WebStart.php. Moved profiling setup to a hook file "StartProfiler.php", following Brion's suggestion to merge Wikimedia's early profiling patch into subversion. Renamed Profiling.php and logProfilingData(), removed unnecessary wfProfileClose() calls. 2006-07-14 05:35:31 +00:00
Tim Starling
424a194a6c need ImageFunctions.php 2006-07-02 16:29:06 +00:00
Brion Vibber
7ed5ec7893 Use a constant instead of var for disabling compression on live sites 2006-04-02 04:20:33 +00:00
Tim Starling
b9766fe1e3 More robust directory structure migration, should fix bug #2532, except for Brion's complaint that the directory structure should be completely different, which he is free to fix in his own time. 2006-02-02 07:07:39 +00:00
Brion Vibber
266d41f165 * Added wfDie() wrapper, and some manual die(-1), to force the return code
to the shell to return nonzero when we crap out with an error.
2006-01-14 02:49:43 +00:00
Ævar Arnfjörð Bjarmason
7bbe971aec * s~ +$~~ 2006-01-07 13:09:30 +00:00
Tim Starling
239ba39261 workaround for any current or future exploit of the $GLOBALS overwrite vulnerability 2005-10-31 21:14:07 +00:00
Brion Vibber
e71e92b67e Committing live hacks: additional profiling points 2005-08-17 20:04:39 +00:00
Ævar Arnfjörð Bjarmason
27105c2129 * (bug 898) Mime type autodetection. 2005-05-21 07:46:17 +00:00
Tim Starling
8395a4e8e7 Fixed various bugs with new image code, changed thumbnail paths as per JeLuF's suggestion 2005-04-16 11:05:41 +00:00
Tim Starling
f90c740f91 Fixed some obvious bugs with the new code and implemented If-Modified-Since handling 2005-04-16 05:48:21 +00:00
Tim Starling
9411d91b49 Optional thumbnail generation by client request, using thumb.php. This removes any need for access to image files on page view. Experimental, some aspects still haven't been tested. 2005-04-16 04:33:34 +00:00