Commit graph

70 commits

Author SHA1 Message Date
stibba
3ee7eee360 Use new ScopedCallback::newScopedIgnoreUserAbort helper function
Introduced in Ib6e307d76f93.

This patch updates FileBackend, LoadBalancer and LBFactory to use a public
function newScopedIgnoreUserAbort in ScopedCallback instead of all using
the exact same function but duplicated.

Bug: T184044
Change-Id: I27d7dc16abfe4b9447d7f3d8bd89f0de3ddeb662
2018-11-01 17:18:01 -07:00
Timo Tijhof
8df0342eef filebackend: Add normalization for stat errors
Bug: T205567
Change-Id: I75f1eb6dc2cbff0ea0dc0706cca0ad79c54fc612
2018-10-04 23:00:48 +00:00
Timo Tijhof
63de0fc604 filebackend: Use $tmpDirectory instead of wfTempDir()
Follows-up f7e3ac3f95.

Change-Id: I9583e126e596641956ca3f6646fe4e52eeaca9a2
2018-08-23 01:14:52 +01:00
Umherirrender
d5c659cb95 Replace @remarks by @note
@remarks is uncommon and blacklist in phpcs

Change-Id: Ia21f340ad75f0f007fea8b1b79e16ab889a74d0c
2018-08-07 12:12:13 +02:00
Aaron Schulz
ec7dfb4a34 filebackend: switch callers from ProcessCacheLRU to MapCacheLRU
Change-Id: I6efe7122ff30053a85461d31be7b5ddad0a5d2af
2018-07-14 11:27:09 +00:00
jenkins-bot
ef97002179 Merge "Simplify PHP by using ?? and ?:" 2018-07-11 09:09:18 +00:00
Fomafix
6866cfec37 Simplify PHP by using ?? and ?:
Also remove not necessary surrounding parentheses.

Change-Id: I0eb5c9c1bdfb09a800258379cdcefb5fd4d3d21c
2018-07-10 20:03:17 +00:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
Max Semenik
1e680456b4 Get rid of call_user_func(_array)(), part 3
Also cleaned up nearby code in a couple places.

Change-Id: Ibf44ee7c0ceb739d7e79406e4ff39303c316e285
2018-06-10 02:21:24 +00:00
Max Semenik
6e956d55aa Replace call_user_func_array(), part 2
Uses new PHP 5.6 syntax like ...parameter unpacking and
calling anything looking like a callback to make the code more readable.
There are much more occurrences but this commit is intentionally limited
to an easily reviewable size.

In one occurrence, a simple conditional instead of trickery was much more readable.

This patch finishes all the easy stuf in the core, the remainder is either unobvious
or would result in smaller readability gains. It will be carefully dealt with in
further commits.

Change-Id: I79a16c48bfb98b75e5b99f2f6f4fa07b3ae02c5b
2018-06-07 20:19:26 -07: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
Bartosz Dziewoński
4fd27f006f Use PHP 5.6 '**' operator instead of 'pow()' function
Change-Id: Ieb22e1dbfcffaa4e7b3dcfabbcc999e5dd59a4bf
2018-05-30 18:05:19 -07:00
Fomafix
d65ac78277 Replace HTTP by HTTPS
* https://www.unicode.org/ instead of http://www.unicode.org/ or
  http://unicode.org/
* https://secure.php.net/ instead of http://www.php.net/ or
  http://php.net/
* https://hhvm.com/ instead of http://hhvm.com/
* https://www.iis.net/ instead of http://www.iis.net/

Change-Id: I84d818a7e0ced5ffb9485ec89a75efb28a77c1e0
2018-05-22 12:14:14 +02:00
Timo Tijhof
a89095bd52 filebackend: Fix undefined 'req_params' context in FileOperation log
Follows-up 9d49075b38. Noticed various log messages on Beta Cluster
from this code path that used "{params}" even in the real messages
(not normalised). Turned out, it isn't being defined due to a typo.

Change-Id: Ib9cf644fdf413035504d9d7486696cffa7737d4a
2018-05-20 01:39:36 +02:00
Aaron Schulz
b6853e0009 Remove bogus @throws from HTTPFileStreamer
Change-Id: I28928a6f01b107b2aed8ab6fbeb013410a8f9718
2018-04-26 19:17:19 -07:00
Gilles Dubuc
cd233f1165 Separate additional swift users for public and private
For better security seggregation it can be desirable
to set different additional swift users when dealing
with private containers.

Bug: T187822
Change-Id: I66d26ec81b3a3577d274c0d28cf86db7b505e082
2018-02-26 10:25:59 +01:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
Chad Horohoe
5c93fabafd Drop XCache support
It was never super popular anyway, APC was always the best option.
The project has no plans to move to PHP7, so it's quickly reaching
its end of life. Oh, and Fedora dropped it from their repos 2 years
ago.

Change-Id: Ia3257e86a6323d8943f04a5c05c72c0bd4c4b0a9
2018-02-07 13:45:40 -08:00
Umherirrender
3124a990a2 Use ::class to resolve class names in includes files
This helps to find renamed or misspelled classes earlier.
Phan will check the class names

Change-Id: I07a925c2a9404b0865e8a8703864ded9d14aa769
2018-01-27 20:34:29 +01:00
Max Semenik
55497cdc1a Phan: resolve and reenable PhanAccessMethodProtected
Change-Id: I2bd7c787012f4f54600f3289d9d0d725f87788bc
2018-01-23 09:31:13 -08:00
Aaron Schulz
795412ccaf Clean up formatting of SwiftFileBackend::sanitizeHdrsStrict()
Change-Id: I5e411f4bf50836d22db01220853776494a9e69d5
2017-11-28 09:07:37 -08:00
Cormac Parle
d36d987c4e Do not strip Content-Type header for POST requests to swift
libcurl adds 'Content-Type: application/x-www-form-urlencoded'
to a POST request if the 'Content-Type' header is not set
manually. Because data in swift is updated via POST, the
Content-Type header must be set explicitly to stop a run of
refreshFileHeaders.php from changing the Content-Type of all
files in swift to application/x-www-form-urlencoded

Bug: T178849
Change-Id: I43c21bc1b73e37104cf07cd5f1c1557f472b9898
2017-11-28 14:24:27 +00:00
Aaron Schulz
205f4606af SwiftFileBackend::resolveContainerPath() check the proper length
The length sanity check should use this instead of urlencode()
see it is rawurlencode() that is actually used.

Change-Id: I5632e30c14c8ab27c8324c3e31311ca8bff7c162
2017-11-17 23:37:04 +00:00
Chad Horohoe
9d49075b38 Fix grouping for remaining logger calls in SwiftFileBackend
Change-Id: I80ad8424de3e2a6a0c4b5e69537012a8f775cd68
2017-11-03 22:22:33 +00:00
Chad Horohoe
4f2d55babb Group Swift metadata errors by making $path a parameter
Change-Id: I3beb3743e1d13b06a9110c44f84fdc8d1b193137
2017-10-26 10:33:42 -07:00
Brion Vibber
1b04c8a106 Support uploads with UTF-8 names on Windows
On PHP 7.1 and later, filesystem functions on Windows
use the Unicode system functions, which makes our file
handling work for non-ASCII file names.

Previously this was blacklisted for Windows on all PHP
versions. Versions before 7.1 will still reject Unicode
filenames with non-ASCII chars.

Bug: T3780
Change-Id: I94377faa5185f133be2dfb7b9b6aeacbd582834f
2017-10-03 23:13:33 +00:00
Gilles Dubuc
75a3043b71 Give thumbor swift user r/w access to containers
readUsers and writeUsers are new optional values
of the swift backend configuration. They allow
giving read and/or write rights to additional
users than the default swift user.

Bug: T144479
Change-Id: I0f81a013ec994eee3f156a89f29f4fcfc37c42b7
2017-09-25 21:45:39 +00:00
Umherirrender
86463f3df6 build: Updating mediawiki/mediawiki-codesniffer to 0.12.0
Change-Id: Iefaae5043fa77d5d556c31079549dab8f61bd3ef
2017-09-10 21:11:37 +02:00
Kunal Mehta
0cb2a09b6d Always put type information before variable name for @var tags
Like other tags, @var should have the type information before the
variable name.

<https://docs.phpdoc.org/references/phpdoc/tags/var.html>

Change-Id: I9eca6957b1990fa8cc687103dc02ee38af5f9086
2017-09-04 11:06:51 -07:00
Umherirrender
3f1a52805e Use short type bool/int in param documentation
Enable the phpcs sniffs for this and used phpcbf

Change-Id: Iaa36687154ddd2bf663b9dd519f5c99409d37925
2017-08-20 13:20:59 +02:00
Umherirrender
718e63694d Add missing @param and @return documentation
Change-Id: I1d1098eec3933df6561cceef646576013ddc08c8
2017-08-11 22:17:01 +02:00
Umherirrender
ace44e2064 Use correct variable name in @param documentation
For some varargs a variable name is added with suffix ,... as seen for
many other varargs

Some @param are swapped, because there are in the wrong order

Enable Sniff MediaWiki.Commenting.FunctionComment.ParamNameNoMatch

Change-Id: I60fec6025bce824d5c67563ab7b65ad6cd628ad8
2017-08-11 19:27:19 +02:00
Umherirrender
a9007e8baf Add missing & to @param documentation to match functon call
Change-Id: I81e68310abcbc59964b22e0e74842d509f6b1fb9
2017-08-11 18:47:46 +02:00
Timo Tijhof
7f000f8681 Re-introduce use of mime_content_type()
Follows-up eac059c722. See also https://stackoverflow.com/a/39676272/319266.

This function was never deprecated. For a short time, the www.php.net
manual page for `mime_content_type` wrongly documented it as having been
deprecated in PHP 5.3, but this wasn't true, and it has been present in
every PHP version since PHP 4.3, including PHP 7 and HHVM 2.3+.

Between PHP 4.3.0-4.3.2 and PHP 5.0-5.3, the function would be absent
if the Mimemagic extension was not enabled at compile-time. However, while
mime_content_type was first introduced by the Mimemagic PHP ext, it is
backend by the Finfo extension since PHP 5.3.0.

Confirmed via https://3v4l.org/IQC1Q.

* CSSMin: Revert conditional use of finfo back to unconditional use
  of mime_content_type.

* MimeAnalyzer: Replace conditional use of finfo with unconditional use
  use of mime_content_type. Also remove the now-redundant 'else' branch.
  The 'else' branch existed because this code was written at a time where
  MediaWiki still supported PHP 4, of which some minor versions could
  sometimes be compiled without this function.

Change-Id: Iee4a0b6f616a469bb779c40e386045f9c3200446
2017-07-27 02:18:43 +00:00
Aaron Schulz
82e2c924e4 Remove "@author Aaron Schulz" annotations
Bug: T139301
Change-Id: Ib5248e8e27d60611c7373bce4b29dd5e85aa3489
2017-06-27 15:24:14 -07:00
Umherirrender
be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00
Gilles Dubuc
c2ea52a545 Remove X-Content-Dimensions header
Reverts 84e4d75088, and parts of cdfe08439c and 4511f6fa9f.

Bug: T150741
Bug: T167034
Change-Id: I39cfcf2cb231b6dfef569968fba6f473da258916
2017-06-12 18:07:28 +00:00
jenkins-bot
a4943f548b Merge "Handle proxy-based TLS when placed in front of Swift" 2017-05-11 12:10:35 +00:00
Aaron Schulz
8eb82c0f64 Handle proxy-based TLS when placed in front of Swift
Force the URL for storage operations to use https if the authentication
URL is already forced to use https. This avoids following an http URL
based on the response of a Swift proxy unaware that a terminator placed
in front of it was used for the authentication.

Bug: T160616
Change-Id: Ia6c8c99ebb38d5828773b2f7aa8cf14ced6bdfde
2017-05-10 17:01:13 +00:00
Gilles Dubuc
cdfe08439c Store original media dimensions as additional header
For storage repos that support headers (such as Swift), this will store the original
media dimensions as an extra custom header, X-Content-Dimensions.
The header is formatted to minimize its length when dealing with multipage
documents, by expressing the information as page ranges keyed by dimensions.

Example for a multipage documents with some pages of different sizes:
X-Content-Dimensions: 1903x899:1-9,11/1903x873:10

Example for a single page document:
X-Content-Dimensions: 800x600:1

Bug: T150741
Change-Id: Ic4c6a86557b3705cf75d074753e9ce2ee070a6df
2017-05-09 15:49:28 -07:00
Aaron Schulz
8d4b97f364 Use executeOpHandlesInternal() in SwiftFileBackend
Instead calling doExecuteOpHandlesInternal() directly, use the
wrapper parent class method instead so that closeResources() is
called on all of the handles.

Change-Id: Iab0d4f7c08d155639a44f48147b78283059a6d24
2017-03-20 18:04:40 +00:00
Aaron Schulz
17c686a802 Make sure Swift store operations close the source file handle
Bug: T159607
Change-Id: I9a8907a20ba83f33cc5fc96bc15a1728770f656a
2017-03-14 20:08:46 +00:00
Timo Tijhof
50a035cd6b Clean up get_class($this) -> static::class in /includes/cache and /includes/libs
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I22c62851bcc88405f4bdd77258d6e28ec1a14924
2017-03-07 21:06:06 +00:00
Kunal Mehta
a57b64436c Use wikimedia/timestamp
Bug: T100924
Depends-On: I0a067367cda6885fa45631ed7c18799d653dc9bf
Change-Id: I69ba64e364df8af089c1c918cdf32f99454e693a
2017-02-28 21:15:38 -08:00
James D. Forrester
b715f432f4 includes/libs: 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.

Skipping jsminplus.php as those bug numbers aren't Wikimedia's, nor obviously
someone else's.

Change-Id: I9a2210e17852ee56f11282b980ac66d8c7a95671
2017-02-21 18:13:08 +00:00
Erik Bernhardson
d67197fa11 Cleanup some incorrect return annotations
Most of these are simply changing annotations to reflect
reality. If a function can return false to indicate failure
the @return should indicate it.

Some are fixing preg_match calls, preg match returns 1, 0 or false,
but the functions all claim to return booleans.

This is far from all the incorrect return types in mediawiki, there
are around 250 detected by phan, but have to start somewhere.

Change-Id: I1bbdfee6190747bde460f8a7084212ccafe169ef
2016-12-12 10:15:05 -08:00
jenkins-bot
69ae945e8d Merge "Update weblinks in comments from HTTP to HTTPS" 2016-11-08 21:32:00 +00:00
Fomafix
202f695f67 Update weblinks in comments from HTTP to HTTPS
Use HTTPS instead of HTTP where the HTTP link is a redirect to the HTTPS link.

Also update some defect links.

Change-Id: Ic3a5eac910d098ed5c2a21e9f47c9b6ee06b2643
2016-11-07 15:24:46 +01:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Aaron Schulz
177e151174 Fix FileBackendStore IDEA warnings due to var reuse
Change-Id: I1b667fb7e891053c7898a0c247745b4376061590
2016-10-18 23:10:58 -07:00