Commit graph

180 commits

Author SHA1 Message Date
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