Commit graph

1664 commits

Author SHA1 Message Date
James D. Forrester
13bd9a8845 Deprecate wfGetRusage(), no longer useful
Change-Id: Ibab4825b53cd76053f1e4ce8986dfac8054a04f8
2019-10-22 11:18:43 +01:00
Daimona Eaytoy
ae424ce5da build: Upgrade mediawiki-phan-config to 0.8.0
This is to ensure that the CI job is working with the new version.

Note: redundant_condition_detection should have worked as expected by
this version, but unfortunately it still has false positives.

Bug: T235049
Bug: T231636
Change-Id: Idaba6584cb5b2ff19b6455c7bbec6b89619ddbff
2019-10-22 09:16:45 +00:00
Aaron Schulz
f5ac68300e Deprecate wfWikiId() in favor of WikiMap::getCurrentWikiDbDomain()
The later distinguishes meaningful (not "mediawiki") schema names
if postgres is in use and can be used to get DB domain strings or
full wiki IDs as needed.

Change-Id: I7bd3d85e36a992fa7359127328669fe6e16b0fed
2019-10-22 02:47:33 +00:00
Tim Starling
184676c346 Move MediaWikiTestCase::setUp() and tearDown() to annotation hooks
This removes the requirement that setUp() and tearDown() in the derived
class need to call the parent.

Change-Id: I9d4771c28160356ff58884e3a58fa28c8db4e8a5
2019-10-17 20:22:39 -07:00
Daimona Eaytoy
cae0110e5a Fix new phan errors, part 1
First part, mostly doc-only.

Bug: T231636
Change-Id: Id59f585740fa5bfb53c257287121f51a30de38fe
2019-10-11 15:04:04 +00:00
Max Semenik
c8eb0798f1 Hard-deprecate wfIsHHVM()
Deprecated in 1.34, no callers once the mentioned below patch
is merged.

Bug: T192166
Change-Id: I1043002d794a7aecf2dac257a64b8cac2d3969b3
Depends-On: I63da562af5f60e04a81a15cd3073eeae1b222541
2019-10-06 22:45:03 -07:00
James D. Forrester
27fa60be37 HHVM removal: Simplify wfGetRusage()
Change-Id: I4e7e1285951518f59423c55e5c48d995a1941a5b
2019-10-03 11:08:58 -07:00
James D. Forrester
c00e7cd793 HHVM removal: Deprecate and simplify wfIsHHVM()
Change-Id: I81b15d3ae66f070a8a1286627973a339cc08e86b
2019-10-03 11:08:57 -07:00
Aaron Schulz
4f11b61454 Avoid using "enqueue" mode for deferred updates in doPostOutputShutdown
Set appropriate headers and flush the output as needed to avoid blocking
the client on post-send updates for the stock apache2 server scenario.
Several cases have bits of header logic to avoid delay:

a) basic GET/POST requests that succeed (e.g. HTTP 2XX)
b) requests that fail with errors (e.g. HTTP 500)
c) If-Modified-Since requests (e.g. HTTP 304)
d) HEAD requests

This last two still block on deferred updates, so schedulePostSendJobs()
does not trigger on them as a form of mitigation. Slow deferred updates
should only trigger on POST anyway (inline and redirect responses are
OK), so this should not be much of a problem.

Deprecate triggerJobs() and implement post-send job runs as a deferred.
This makes it easy to check for the existence of post-send updates by
calling DeferredUpdates::pendingUpdatesCount() after the pre-send stage.
Also, avoid running jobs on requests that had exceptions. Relatedly,
remove $mode option from restInPeace() and doPostOutputShutdown()
Only one caller was using the non-default options.

Bug: T206283
Change-Id: I2dd2b71f1ced0f4ef8b16ff41ffb23bb5b4c7028
2019-09-30 22:59:59 +00:00
Daimona Eaytoy
e5444ea55a docs: Avoid some scalar juggling
Phan can treat scalar types as non-interchangeable with
`scalar_implicit_cast` set to false. This patch fixes some of those
issues (which are in total >1000), namely the ones with alphabetic order
< includes/actions.

Change-Id: Ib1c6573ab899088bc319b9da9ceaffc850da3dbe
2019-09-19 17:21:24 +00:00
Daimona Eaytoy
b138a9b228 Fix using null for a non-nullable argument
These are reported by phan as PhanTypeMismatchArgumentNullableInternal
when null_casts_as_any_type is disabled.

Change-Id: I85076ee31c1bfc59a19600e84da0d915e425890a
2019-09-19 16:55:03 +00:00
Daimona Eaytoy
dddc912fd6 Update docblocks for methods potentially returning null
These were discovered by setting `null_casts_as_any_type` to true in
phan, and filtering by `PhanTypeMismatchReturnNullable`. Of course there
are others, some of which are false positives, but we cannot suppress
them now (or the UnusedSuppressionPlugin will complain).

Change-Id: Ia8443e575c22f47a6d8c63038f4e7ac36815fc27
2019-09-15 15:22:39 +00:00
Daimona Eaytoy
b5cbb5ab3f Upgrade phan config to 0.7.1
This allows us to remove many suppressions for phan false positives.

Bug: T231636
Depends-On: I82a279e1f7b0fdefd3bb712e46c7d0665429d065
Change-Id: I5c251e9584a1ae9fb1577afcafb5001e0dcd41c7
2019-09-04 08:20:53 +00:00
Daimona Eaytoy
327e8ea416 Unsuppress phan issues part 6
Bug: T231636
Depends-On: I50377746f01749b058c39fd8229f9d566224cc43
Change-Id: I2cd24e73726394e3200a570c45d5e86b6849bfa9
2019-09-01 09:48:45 +00:00
Daimona Eaytoy
e70b5b3309 Unsuppress other phan issues (part 4)
Bug: T231636
Depends-On: I58e67c2b38389df874438deada4239510d21654f
Change-Id: I6e5fba7bd273219b1206559420b5bdb78734aa84
2019-08-31 17:13:39 +00:00
Daimona Eaytoy
5eac6d131c Unsuppress more phan issues (part 3)
Bug: T231636
Depends-On: I78354bf5f0c831108c8f606e50c87cf6bc00d8bd
Change-Id: I58e67c2b38389df874438deada4239510d21654f
2019-08-31 16:38:55 +00:00
Aryeh Gregor
5e2199c5b0 BadFileLookup to replace wfIsBadImage
I think this probably shouldn't be directly in the MediaWiki namespace,
but I don't know where is a better place to put it.

In order to avoid gratuitous use of TitleFormatter, I changed the cache
format -- the old implementation used getPrefixedDBkey() and I switched
to an ns/dbkey pair. I also changed the cache keys to use SHA1 instead
of MD5, by Daniel's request.

The previous implementation cached the parsed blacklist for one minute
without invalidation, so it could return slightly stale results, but it
didn't retrieve the bad image list message on a cache hit. The new
implementation unconditionally retrieves the bad image list message, but
uses a hash of it in the cache key and caches for one day. The new
behavior happens to be more cleanly implementable in a service.

Bug: T200882
Bug: T139216
Change-Id: I69fed1b1f3cfc1aa149e0739780e67f6de01609d
2019-08-21 20:45:37 +03:00
Krinkle
74068ce880 Make wfGetDB() return a MaintainableDBConnRef instance (take 2)
This enforces the DB_* role checks of DBConnRef in more places.

This is a re-submission of 335066505a, which was reverted due to T228928.

Change-Id: I556627dc6486e6f6539d1d2dd5aa6f009eff341e
2019-07-25 15:28:27 +00:00
Krinkle
02b14d3142 Revert "Make wfGetDB() return a MaintainableDBConnRef instance"
This reverts commit 335066505a.

The standalone parser test runner, as used by Parsoid Jenkins builds,
is (indirectly) using wfGetDB in a way that isn't supported (changing
the selected database). This needs to be fixed, but we can give it
a few days.

Change-Id: I07ff422dd56d5700e570100747aa49b7764ec80f
2019-07-24 18:07:18 +00:00
Aaron Schulz
335066505a Make wfGetDB() return a MaintainableDBConnRef instance
This enforces the DB_* role checks of DBConnRef in more places

Depends-on: I9328e709fe5d81099338a31deef24d34db22d784
Change-Id: I0d7dacee3ec4ef67dc0b0f6551ad046c74dc47dc
2019-07-24 16:41:59 +00:00
Derick Alangi
99cf057e0f GlobalFunctions: Hard deprecate wfGlobalCacheKey() function
The only extension that used this was ConfirmEdit and it has been
cleaned up with Ia7b276ee65fdf58c, so is it time we hard deprecate
it?

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbwfGlobalCacheKey%5Cb&i=nope&files=&repos=

Depends-On: Ia7b276ee65fdf58c4fc0859563930528d44a03ca
Change-Id: I3fda797c64ec62df4454625ad1a3bf89f6a88246
2019-07-18 09:41:23 +01:00
Timo Tijhof
82fe641c42 Setup: Make wfMemoryLimit() internal and simplify
Bug: T189966
Change-Id: I4fa3d66dbf2e2d05a0d1868329a16dfb1959498f
2019-07-13 01:22:43 +00:00
Derick Alangi
49bbfc7f1f GlobalFunctions: Tighten version number type for wfDeprecated()
To avoid cases like: facddc4 and Ifaf6ab0d36bc02bd170, make sure the
value of the mediawiki version  must be a string (e.g. '1.33') or a
boolean (e.g. `false`).

For some reason, typos can slip through for this value to be a float.
Let's safe guard for future cases like this.

Change-Id: I52bdf94c957bda67548a937d51649e925195f926
2019-07-01 21:07:10 +00:00
James D. Forrester
7bb16a14ce Drop wfGetLBFactory, deprecated in 1.27
Change-Id: I53b5611edc9443f6a684192e5a03bb0100cb448d
2019-06-24 21:12:59 +00:00
James D. Forrester
348a29f3e4 Drop wfResetSessionID, deprecated in 1.27
Change-Id: I14a9c91a43504ee02aac809f5e1124e1cb958e19
2019-06-24 14:12:33 -07:00
jenkins-bot
20e65a1915 Merge "parser: inject the time for {{REVISIONTIMESTAMP}} on pre-save parse" 2019-06-23 22:13:48 +00:00
Derick Alangi
0022a545c8 GlobalFunctions: Remove deprecated wfCountDown() function from core
The global function `wfCountDown()` was deprecated in 1.31 and a replacement
made available (\Maintenance::countdown()) in 1.31 as well. Currently, the few
usage in BSF have been cleaned up, hence can be removed.

Usage
=====

https://codesearch.wmflabs.org/search/?q=wfCountDown&i=nope&files=&repos=

Depends-On: Iae61d36899036ecdc0341feb3f1bcaa6b38dbf44
Depends-On: Id202148c6a6ceaadcefcf7a4ab8360edd9fe3b0b
Bug: T220656
Change-Id: Ic7460f1d35cb6f2eb8bf60694cdd4c55b2e001c0
2019-06-20 22:54:14 +01:00
C. Scott Ananian
1cb3851f0a Remove global function wfBCP47, deprecated in 1.31
Change-Id: I8b9956bec18cc7bbc9aafeec124e6c1fef262dc6
2019-06-20 20:43:40 +00:00
Derick Alangi
21e2d71560 Replace some uses of deprecated wfFindFile() and wfLocalFile()
These global functions were deprecated in 1.34 and services made
available to replace them. See services below;

* wfFindFile() - MediaWikiServices::getInstance()->getRepoGroup()->findFile()
* wfLocalFind() - MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo()->newFile()

NOTES:

* wfFindFile() and wfLocalFind() usages in tests have been ignored
  in this change per @Timo's comments about state of objects.

* includes/upload/UploadBase.php also maintained for now as it causes
  some failures I don't fully understand, will investigate and handle
  it in a follow up patch.

* Also, includes/MovePage.php

Change-Id: I9437494de003f40fbe591321da7b42d16bb732d6
2019-06-11 13:26:37 +00:00
Aaron Schulz
e85fe191c9 parser: inject the time for {{REVISIONTIMESTAMP}} on pre-save parse
DerivedPageDataUpdater::prepareContent already locks in the revision
timestamp before insertion, so inject that into the parser options
used for any pre-save parse (e.g for edit filters).

This means that a reparse is no longer needed within in the same save
request to get the post-save canonical output. A parse will still be
required if the edit filter output used an edit stash output, since
the revision timestamp is not set at stash time.

Instead of using vary-revision, add a vary-revision-timestamp flag
for the revision timestamp words. The month/day/hour variants retain
their prior optimizations for allowing edit stash output reuse for
the post-save canonical output.

Change-Id: Ic2c13db4d21197c79a89de0de56745ca32918eb6
2019-06-09 13:12:57 +01:00
Reedy
0517b9af9b Update wikimedia/at-ease from 1.2.0 to 2.0.0
https://github.com/wikimedia/at-ease/releases/tag/v2.0.0
https://github.com/wikimedia/at-ease/compare/v1.2.0...v2.0.0

Change-Id: Ia49a156e76d0a4e257e91cc6a51050848bcb9a5e
Depends-On: If40364e2590e3c23035838f8ed26c4f69e730602
2019-05-18 14:32:57 +01:00
James D. Forrester
b761bfa311 Drop wf(Suppress|Restore)Warnings, deprecated in 1.26
Change-Id: Idcc9debd90e6ee12adf5ab7c4ec640db12828997
2019-05-18 15:18:28 +02:00
Derick Alangi
3737859a4f GlobalFunctions: Version for hard & soft deprecation must match
Per the deprecation policy, hard and soft deprecation version for
MW must match, so hard must match soft, in that order. The method
wfGetLBFactory() was soft deprecated in 1.27 so hard deprecation
version should be 1.27 and not 1.34

This is a follow up for 91a3f56.

Change-Id: I2b4b4c97dca3bc8ecadf7a53d68ea183b4a0de9c
2019-05-09 15:56:40 +01:00
Aryeh Gregor
e6691999f4 Make RepoGroup a service instead of singleton
Change-Id: Id1661bf992ee7b7a1822f52fdfefe8e045b9f280
2019-05-06 13:57:40 +03:00
Derick Alangi
fee2fa2d8e GlobalFunctions: Remove deprecated wfMakeUrlIndexes() function
This function was hard deprecated in 1.33 and per code search, usage
is no longer there, probably completely replaced?

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5CbwfMakeUrlIndexes%5Cb&i=nope&files=&repos=

Bug: T42485
Change-Id: I01642a8207f582762428f5a7ac33830066268b2e
2019-04-28 09:21:27 +01:00
Derick Alangi
3d2750b89f GlobalFunctions: Remove usage of wfArrayFilter & wfArrayFilterByKey
These functions were hard deprecated in 1.32 and usage no longer exist
and seems to have been completely removed from all repos. See below;

Usage
=====

https://codesearch.wmflabs.org/search/?q=%5B%5E%3E%5D(wfArrayFilterByKey%5C(%7CwfArrayFilter%5C()&i=nope&files=&repos=

Bug: T42485
Change-Id: I28092eeb8dec058c5dba2fb63f3602249c137b31
2019-04-27 07:48:07 +01:00
Derick Alangi
91a3f56eae GlobalFunctions: Hard deprecate wfGetLBFactory() function
Usage of this function has almost disappeard from both core and
all mediawiki extensions. Kill this function in MW 1.35.

Depends-On: Id415d70aa0090c01ea04c3156aecd76caa8e83f8
Change-Id: I95f42b1631caf5ae026b9b7a3ced277bf9fa0608
2019-04-23 16:42:33 +01:00
Aryeh Gregor
b6e1e99bec Use LinkTarget in Linker instead of Title
Bug: T214318
Change-Id: I60b6208fa5b45a568e81f908a19cd0f244ef79be
2019-04-15 17:15:05 +03:00
Fomafix
9cbb8f104d Use https://www.php.net/ instead of https://secure.php.net/
Change-Id: I0acca592c6909e91b28b904da49dcbd6a43cd2a5
2019-04-12 06:44:48 +02:00
Derick Alangi
84292b7728 Replace deprecated function wfEscapeShellArg with Shell::escape()
Change-Id: I4046d593d1450cfffc489ca2abadba1084a540e4
2019-04-07 20:17:39 +01:00
Reedy
c13fee87d4 Collapse some nested if statements
Change-Id: I9a97325d738d09370d29d35d5254bc0dadc57ff4
2019-04-04 19:02:22 +00:00
Aaron Schulz
d3e65ed02e Remove deprecated wfSplitWikiID() function
Change-Id: I87c5532effde9d433aef537228aa804f6d751f9b
2019-03-28 12:19:49 -07:00
Fomafix
6dbd989314 GlobalFunctions: Document the usage of wfUrlencode( null )
This was introduced for testing in 53b0052df.

Change-Id: I318d6d6c04334ea75fbc9ac1771fab9a9db8cb83
2019-03-25 18:24:53 +01:00
Fomafix
4b46994799 Fix usage of MediaWikiServices in comments and documentation
MediaWikiServices::getFoo()

is wrong. Right is:

MediaWikiServices::getInstance()->getFoo()

Change-Id: Ib6d844ddfe5bd6ccd72b887a63d9ad476c8d196f
2019-03-03 14:09:33 +00:00
Matěj Suchánek
2c8db66fa4 Prevent PHP notice on SpecialDeletedContributions
Bug: T208544
Change-Id: Ie8d5c3d7257134857713853eec8e0eb42890366a
2019-02-15 18:45:09 +00:00
Kunal Mehta
cc5d9a92a2 build: Updating mediawiki/mediawiki-codesniffer to 24.0.0
Change-Id: I66b1775b7c1d36076d9ca78cbeb42787a743f2aa
2019-02-07 18:39:42 +00:00
Max Semenik
30e1e9ba2c Hard-deprecate wfArrayFilter() and wfArrayFilterByKey()
Deprecated in 1.32, no callers.

Change-Id: Id6147cff1336cc39863c985023933ce9c6afca31
2019-01-21 23:04:01 -08:00
Reedy
2bb276f07d Improve documentation of wfDeprecated
Change-Id: I20b7724f0cf2b0221ae27412844e4019ae451b61
2018-12-28 11:10:41 +00:00
Fomafix
3ee1560232 No yoda conditions
Replace
  if ( 42 === $foo )
by
  if ( $foo === 42 )

Change-Id: Ice320ef1ae64a59ed035c20134326b35d454f943
2018-11-21 17:54:39 +01:00
Niedzielski
9e90793dfa Merge "Doc: result domain for GlobalFunctions::wfRandom()" 2018-11-16 20:19:19 +00:00
Brad Jorsch
d65e96b763 Use new externallinks.el_index_60 field
This adds a method to LinkFilter to build the query conditions necessary
to properly use it, and adjusts code to use it.

This also takes the opportunity to clean up the calculation of el_index:
IPs are handled more sensibly and IDNs are canonicalized.

Also weird edge cases for invalid hosts like "http://.example.com" and
corresponding searches like "http://*..example.com" are now handled more
regularly instead of being treated as if the extra dot were omitted,
while explicit specification of the DNS root like "http://example.com./"
is canonicalized to the usual implicit specification.

Note that this patch will break link searches for links where the host
is an IP or IDN until refreshExternallinksIndex.php is run.

Bug: T59176
Bug: T130482
Change-Id: I84d224ef23de22dfe179009ec3a11fd0e4b5f56d
2018-11-12 22:33:18 +00:00
Stephen Niedzielski
2b2f76287a Doc: result domain for GlobalFunctions::wfRandom()
Domain is an important property to document for callers. For example,
random numbers are often used in calculations that are input into array
index calculations and the knowledge that a function can or cannot ever
return the integer 1 helps avoid rare off-by-one errors that may occur.
`int( wfRandom() * count( $array ) )` will always yield an in-bounds
index if wfRandom() returns [0, 1) but can make no such guarantee for
[0, 1].

It's not immediately obvious from the implementation whether the
endpoints of the domain of wfRandom() are inclusive or exclusive. This
patch calculates the minimum and maximum results and documents it.

For its minimal value, given `mt_getrandmax()` returns 1 and `mt_rand()`
returns 0:

  $max = mt_getrandmax() + 1;
  $max = 2;
	$rand = ( mt_rand() * $max + mt_rand() ) / $max / $max;
  $rand = ( 0 * 2 + 0 ) / 2 / 2;
  $rand = 0;

For its maximal value, given `mt_getrandmax()` returns 2^31 - 1 and
`mt_rand()` also returns 2^31 - 1.

  $max = mt_getrandmax() + 1;
  $max = 2^31 - 1 + 1;
  $max = 2^31;
  $rand = ( mt_rand() * $max + mt_rand() ) / $max / $max;
  $rand = ( (2^31 - 1) * 2^31 + 2^31 - 1 ) / 2^31 / 2^31;
  $rand = ( 2^62 - 2^31 + 2^31 - 1 ) / 2^31 / 2^31;
  $rand = 2^62 / 2^62 - 1 / 2^62;
  $rand = 1 - 2^-62; // Less than 1.

Change-Id: Ib179d70902e231eaeeafe6449f505464eb25204d
2018-11-12 02:07:30 +00:00
Aaron Schulz
a5352157c7 Deprecate hacky wfSplitWikiID() method
Change-Id: I59095ee7cc39f634d124fa711ec01a5a5d188d23
2018-10-27 04:49:09 +00:00
Aaron Schulz
ebbccf1845 Migrate some wfWikiId() callers to getLocalDomainID()
Change-Id: I33fe222b7ca66babd61610febaebcf52d3806a7d
2018-10-15 23:58:49 -07:00
James D. Forrester
17e5334fc9 Drop wfRunHooks, deprecated since 1.25
Change-Id: I0350fba3f1a4a4ff500af746609bc9c6b46f0bdf
2018-10-10 15:30:00 -07:00
James D. Forrester
e52347fc40 Drop wfUsePHP, deprecated in 1.30 and unused
Change-Id: Ic247af4e9b2b2e687ee74e990e69401426be7c31
2018-10-10 15:30:00 -07:00
jenkins-bot
628fccb967 Merge "Use varargs in global functions" 2018-10-02 01:04:11 +00:00
James D. Forrester
05316b849a Drop wfErrorLog, deprecated in 1.25
Change-Id: I29131f3c677ab5747ac0ae5121669af63a1d5bd8
2018-09-28 18:34:38 -07:00
Max Semenik
f4d62d09e3 Use varargs in global functions
Change-Id: I1b5509f20ff4903e5063280c4fce4e380055e038
2018-09-27 21:44:48 +00:00
James D. Forrester
7e0bb365bb Drop wfUseMW, deprecated in 1.26
Change-Id: I291d6eace1913a651c5e7136f3f2e0216d89fac5
2018-09-13 18:24:51 -07:00
jenkins-bot
2f86f8dbb9 Merge "Don't throw an exception when waiting for replication times out" 2018-09-04 02:20:12 +00:00
Tim Starling
e8df0fbab1 Don't throw an exception when waiting for replication times out
For maintenance scripts it is usually harmful to throw an exception.
For jobs the exception was already caught and handled appropriately,
so this can continue as before. For DeferredUpdates it was extremely
harmful to throw an exception. So in the web case, reduce the timeout to
1s and continue as normal if the 1s timeout is reached. This allows the
DeferredUpdate to be throttled without being killed.

In the updater, increase the replication wait timeout to 5 minutes.
ALTER TABLE could indeed cause replication lag, but exiting the update
script with an exception will probably ruin your day. Update actions are
not necessarily efficiently restartable.

Do not call JobQueue::waitForBackups() when jobs are popped. Maybe it
makes sense to call a queue-specific replication wait function for
bulk inserts, like copyJobQueue.php, but doing it when jobs are popped
just makes no sense. Surely the worst that could happen is that the
queue would become locally empty? Removing this waitForBackups() call
avoids waiting for replication twice when JobQueueDB is used.

Bug: T201482
Change-Id: Ia820196caccf9c95007aea12175faf809800f084
2018-09-03 12:29:35 +10:00
Kunal Mehta
75c3755666 Remove wfMakeStaticArrayFile()
Replaced by the StaticArrayWriter class.

Bug: T200626
Change-Id: I7c02cf3a7dda2804d2eb8d51716254bd78b7544c
2018-08-17 23:07:17 -07:00
Kunal Mehta
3b1e8a5cef Move wfMakeStaticArrayFile() into a class
And include tests :)

This code is independent of MediaWiki, but not really large enough to be
worth librarizing right now.

Bug: T200626
Change-Id: I022c074e8a708fb5219bc4ff4b53e7e31f60dc4b
2018-08-17 22:48:19 -07:00
Kunal Mehta
49efdca8f5 Deprecate wfGetCache() and wfGetMainCache()
The former is already a wrapper around ObjectCache::getInstance().

The latter was identical to ObjectCache::getLocalClusterInstance().

Bug: T115890
Change-Id: Ib4e43bc8d3f4ac9f7a453e36dcce9b3d962666ba
2018-08-17 17:56:21 +00:00
Aryeh Gregor
90d4f56fe4 Mass conversion of $wgContLang to service
Brought to you by vim macros.

Bug: T200246
Change-Id: I79e919f4553e3bd3eb714073fed7a43051b4fb2a
2018-08-11 22:44:29 -06:00
James D. Forrester
827e143c9e GlobalFunctions: Hard-deprecate wfUseMW, unused
Change-Id: Ifa532f2fb7d482238e4b922f622a79b9ab6540e8
2018-07-28 16:59:08 -07:00
jenkins-bot
4533986087 Merge "Avoid a redirect loop when the request URL is not normalized" 2018-07-24 16:13:39 +00:00
jenkins-bot
1655c86faf Merge "$wgHttpsPort should only be used in very special cases" 2018-07-24 01:13:32 +00:00
Max Semenik
b8dee03d9e GlobalFunctions: use a closure instead of polluting global namespace
Change-Id: Ia587008de75a8bde90ad45d4932284f0b6401845
2018-07-19 23:54:49 -07:00
Max Semenik
9b0c621d7f Deprecate wfArrayFilter() and wfArrayFilterByKey()
Now that all our supported PHP versions have array_filter()
with a third parameter, these functions aren't needed anymore.

Depends-On: I3b097a1a048baabcaca15dc214a3a1bb06e746cc
Depends-On: I0187e27ac47cbab099249572201d1a649226a734
Change-Id: I7cabd0252691a083cb749cf9d3a7a23f1d076c39
2018-07-19 08:40:46 +02:00
Tim Starling
f6d582a91e Avoid a redirect loop when the request URL is not normalized
If the request URL was not normalized, for example having a double slash
in it, this could cause it to fail to match in the PathRouter. But the
canonicalizing redirect was using the normalized URL, causing a redirect
loop exception.

So:

* If the PathRouter fails to match with the original URL, try matching
  against the normalized URL. This allows it to still work for
  normalized URLs with a double slash in the title part of the path.
* Have WebRequest::getFullRequestURL() always return the URL without
  removing dot segments or interpreting double slashes. Just append
  the path to the server.
* Make MediaWikiTest.php use WebRequest instead of FauxRequest, allowing
  it to reproduce the exception in question. Add relevant test.
* Add tests for the new PathRouter behaviour.

Bug: T100782
Change-Id: Ic0f3a0060904abc364f75dae920480b81175d52f
2018-07-16 15:55:59 +10:00
Brian Wolff
89b21847e1 Start working on phan-taint-check warnings. Fix minor escaping issues.
This fixes 26 of the phan-taint-check warnings on MW core. Some
are outright fixed, others are false positives that were suppressed.

This really only covers some of the easy ones. There are still
314 warnings to go.

Change-Id: I30463bc3a09fd4324d190de8533f51784764dd3a
2018-07-12 03:26:59 +00:00
Tim Starling
8962915449 $wgHttpsPort should only be used in very special cases
When expanding a URL, don't overwrite an explicitly specified port or
add a port to a foreign URL. $wgHttpsPort is only useful for a very
specific case: when $wgServer is protocol-relative and HTTPS is
requested.

Documented correct use of $wgHttpsPort in DefaultSettings.php. Fixed
invalid "@see", in Doxygen it can only point to "classes, functions,
methods, variables, files or URL".

Added test cases which previously failed.

Change-Id: Id65c58300d22712212b6605711ff916916e8768b
2018-07-11 12:31:48 +10:00
Umherirrender
130ec2523d Fix PhanTypeMismatchDeclaredParam
Auto fix MediaWiki.Commenting.FunctionComment.DefaultNullTypeParam sniff

Change-Id: I865323fd0295aabd06f3e3c75e0e5043fb31069e
2018-07-07 00:34:30 +00:00
jenkins-bot
2ff855cd49 Merge "Add missing use statements" 2018-07-04 00:44:28 +00:00
C. Scott Ananian
6f60ee3b27 Hard deprecate wfBCP47, which was soft deprecated in 1.31
Change-Id: I8632f08a8cb22641b5d16d955f3164dc45843520
2018-07-03 14:04:45 +00:00
Umherirrender
ae2f5d6232 Add missing use statements
Swap some ResultWrapper/Database to interface IResultWrapper/IDatabase

Change-Id: I312cb3cca5742f72efdb0965ba35362f2eb1129d
2018-06-27 20:49:23 +02:00
Fomafix
3714131b5d Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient
This is a followup to 485f66f1.

Change-Id: I7a2a44b7e933103178929b3cdc015859612c8b35
2018-06-11 19:23:15 +02:00
Kunal Mehta
b7116e4f7d Fix phpdoc for wfMessage $params for phan
phan and phpDoc expect that the type of variadic params is the type of
each individual item.

Change-Id: I8229d52b3e4b70a9de6c5bb813bab776c5547e5d
2018-06-08 10:59:22 -07:00
Max Semenik
f16caa5b06 Fix wfMessage() annotation
$params is a variadic parameter now, so it must be treated as an
array. Same thing for wfMessageFallback().

Change-Id: I606deb7ea0fb9be25ac79aadfbab0cc44bdc36a0
2018-06-07 23:07:57 -07:00
Max Semenik
8085c58a4b Replace call_user_func_array(), part 1
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.

Change-Id: Idcec077ef3fdf029b632cceafd0150851ad723e3
2018-06-04 23:39:04 -07:00
Max Semenik
817049ec6b Begin introducing PHP 5.6 variadic parameters where appropriate
Change-Id: I5670b8482e8d3bcb0b3a2b4d2ce9834cfc37e171
2018-06-04 11:53:55 -07:00
jenkins-bot
5a6c78c441 Merge "Use PHP 7 '??' operator instead of '?:' with 'isset()' where convenient" 2018-05-31 19:01:07 +00:00
jenkins-bot
a2882874bb Merge "Use PHP 7 '<=>' operator in 'sort()' callbacks" 2018-05-31 18:48:34 +00:00
Timo Tijhof
a930bf7d7b Remove deprecated global $parserMemc and wfGetParserCacheStorage
Deprecated since 1.30, no longer used in core, bundled components,
and WMF-deployed extensions.

Change-Id: I09715f94750f083712719ef599a2ea4260297681
2018-05-31 14:28:42 +01: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
b191e5e860 Use PHP 7 '<=>' operator in 'sort()' callbacks
`$a <=> $b` returns `-1` if `$a` is lesser, `1` if `$b` is lesser,
and `0` if they are equal, which are exactly the values 'sort()'
callbacks are supposed to return.

It also enables the neat idiom `$a[x] <=> $b[x] ?: $a[y] <=> $b[y]`
to sort arrays of objects first by 'x', and by 'y' if they are equal.

* Replace a common pattern like `return $a < $b ? -1 : 1` with the
  new operator (and similar patterns with the variables, the numbers
  or the comparison inverted). Some of the uses were previously not
  correctly handling the variables being equal; this is now
  automatically fixed.
* Also replace `return $a - $b`, which is equivalent to `return
  $a <=> $b` if both variables are integers but less intuitive.
* (Do not replace `return strcmp( $a, $b )`. It is also equivalent
  when both variables are strings, but if any of the variables is not,
  'strcmp()' converts it to a string before comparison, which could
  give different results than '<=>', so changing this would require
  careful review and isn't worth it.)
* Also replace `return $a > $b`, which presumably sort of works most
  of the time (returns `1` if `$b` is lesser, and `0` if they are
  equal or `$a` is lesser) but is erroneous.

Change-Id: I19a3d2fc8fcdb208c10330bd7a42c4e05d7f5cf3
2018-05-30 18:05:20 -07:00
jenkins-bot
d8a144d38e Merge "languages: Use static array files for normalizer data" 2018-05-25 23:03:18 +00:00
jenkins-bot
2542abb6f6 Merge "Enable merging of WrappedStringList between 'bottomscripts' and 'reportime'" 2018-05-25 19:52:13 +00:00
James D. Forrester
9d875febd5 Bump PHP version requirement to 7.0.0+
Bug: T172165
Change-Id: I740f32ac859d9bb3787fdf8414f82ae6f410492f
2018-05-24 16:15:56 +01:00
Timo Tijhof
03db2f5b3c Enable merging of WrappedStringList between 'bottomscripts' and 'reportime'
* Fix ResourceLoaderClientHtml to return what it was documented to
  return, a WrappedStringList. It accidentally used the wrong join()
  method, causing it to create a plain string too early.

* Update method documentations from ClientHtml::getBodyHtml to
  BaseTemplate::getTrail for 'bottomscripts', and from
  ResourceLoader::makeInlineScript for 'reporttime'.

* Update BaseTemplate::getTrail to join by new line instead of native string
  concatenation.

This by itself would suffice for the most common case, but in order
to also account for the possibility of extensions using hooks for
'SkinAfterBottomScripts' that concatenate, update bottomScripts()
to pass a plain string to the hook and merge it later.

Change-Id: If0d227cb9db67229a27d489c082db790ea8e3840
2018-05-24 14:23:17 +01:00
Timo Tijhof
4f22361759 languages: Use static array files for normalizer data
This reduces the number of '.ser' files to 1 (we still have
first-letters-root.ser).

Change-Id: Ib0ee0d826da34b1825fd5bb74563c6bbadeec75c
2018-05-22 21:38:43 +00: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
Kunal Mehta
230958d97c Autofix MediaWiki.Commenting.FunctionComment.SpacingDoc* errors
Change-Id: I63761ebce04c03b9b13237919c27cc10180f198f
2018-05-19 14:07:03 -07:00
Brian Wolff
70941efd35 Initial support for Content Security Policy, disabled by default
The primary goal here is a defense in depth measure to
stop an attacker who found a bug in the parser allowing
them to insert malicious attributes.

This wouldn't stop someone who could insert a full
script tag (since at current it can't distinguish between
malicious and legit user js). It also would not prevent
DOM-based or reflected XSS for anons, as the nonce value
is guessable for anons when receiving a response cached
by varnish. However, the limited protection of just stopping
stored XSS where the attacker only has control of attributes,
is still a big win in my opinion. (But it wouldn't prevent
someone who has that type of xss from abusing things like
data-ooui attribute).

This will likely break many gadgets. Its expected that any
sort of rollout on Wikimedia will be done very slowly, with
lots of testing and the report-only option to begin with.

This is behind feature flags that are off by default, so
merging this patch should not cause any change in default
behaviour.

This may break some extensions (The most obvious one
is charinsert (See fe648d41005), but will probably need
some testing in report-only mode to see if anything else breaks)

This uses the unsafe-eval option of CSP, in order to
support RL's local storage thingy. For better security,
we may want to remove some of the sillier uses of eval
(e.g. jquery.ui.datepicker.js).

For more info, see spec: https://www.w3.org/TR/CSP2/
Additionally see:
https://www.mediawiki.org/wiki/Requests_for_comment/Content-Security-Policy

Bug: T135963
Change-Id: I80f6f469ba4c0b608385483457df96ccb7429ae5
2018-05-13 21:01:11 -07:00
Reedy
1e7aea9089 Add since tag to wfRemoveDotSegments
Looked it up for another commit, so might aswell make it easier to find for others :)

Change-Id: I432b13b35481cbca9ed6e7328b3b9115fdd203ea
2018-04-28 12:06:10 +00:00
Max Semenik
c751f05d21 Hard-deprecate wfUsePHP()
Deprecated in 1.30, no callers anywhere.

Change-Id: I5168234f4e8cfffbccc9dd43026255ee2dcd878d
2018-04-18 18:45:47 -07:00
Max Semenik
686de25786 Hard-deprecate wfCountDown()
Deprecated in 1.31, the only callers left are in BlueSpice.

Change-Id: I3d59b0967c161eff0190a6f577e571230a7e7a2f
2018-04-18 18:43:02 -07:00
Max Semenik
f4668d6c12 Remove deprecated function wfShellExecDisabled()
Deprecated in 1.30, never had many callers.

Change-Id: Ie77c3df696313f691a68f21b15804539ffcc7f88
2018-04-18 18:41:00 -07:00
Max Semenik
0f50320502 Remove deprecated function wfInitShellLocale()
Deprecated in 1.30, never had more than 2-3 callers.

Change-Id: Ia023ede41affaf8e1b5fd1fed77cdbcefc9dc243
2018-04-18 18:35:41 -07:00
Max Semenik
efa586fddd Restrict shell commands by default
Before it's too late, let's boil the oceans
and just do it. This patch assumes that old code
calling wfShellExec() doesn't know about restrictions
so it doesn't restrict anything. New code, however,
needs to specify its restrictions or deal with defaults.

Change-Id: I58963901087202d4a405bcdb6bd12758bb6b0ff7
2018-04-16 11:50:13 -07:00
Max Semenik
5cf4575ea3 Deprecate wfShellWikiCmd()
Bug: T184339

Change-Id: Ic86a451e0e9d609e06865a4969560d151efa844c
2018-04-16 16:38:05 +00:00
Aaron Schulz
7f24eb5d78 Normalize and lower the default DB lag wait timeout
Bug: T190960
Change-Id: I49aca118583b20314e6bf82f196f3413571f5bd9
2018-03-28 13:49:25 -07:00
Timo Tijhof
665e9b7bf2 Convert OutputHandler functions to a class
* Convert OutputHandler.php from global functions to a class.

  - wfOutputHandler → OutputHandler::handle
    (no alias, no usage outside core)
  - wfGzipHandler → OutputHandler::handleGzip
    (private, no usage outside class)
  - wfRequestExtension → OutputHandler::findUriExtension
    (private, no usage outside class)
  - wfMangleFlashPolicy → OutputHandler::mangleFlashPolicy
    (private, no usage outside class)
  - wfDoContentLength → OutputHandler::emitContentLength
    (private, no usage outside class)
  - wfHtmlValidationHandler → OutputHandler::validateAllHtml
    (private, no usage outside class)

* Add the class to autoload.php for exposure outside WebStart.
  Specifically, for use in ApiFormatPhpTest. This also removes the
  need to manually load the class because this code runs after
  Setup.php loads AutoLoader.php.

Bug: T189966
Change-Id: I27a41ec0ae0ee30aeb313a616323b967605c4055
2018-03-20 21:11:32 -07:00
Kevin Israel
06ba5ca383 Remove internal use of deprecated $wgRequestTime
* Use $_SERVER['REQUEST_TIME_FLOAT'] unconditionally in WebRequest.php
  and libs/Timing.php. WebStart.php was doing this already without issue.
  The key existst since PHP 5.4, for both Web and CLI (we require 5.5).

* In wfDebug() and wfReportTime(), use $_SERVER['REQUEST_TIME_FLOAT'] instead.

* In ApiFormatBase and MWDebug, use WebRequest::getElapsedTime() instead.

* In Maintenance.php, remove setting of $wgRequestTime.

* In rebuildFileCache.php, update mocking to $_SERVER['REQUEST_TIME_FLOAT']
  so that we avoid re-introducing bug T24852.

Change-Id: I1b647da2862f815029caa533b592ec8a05b33806
2018-03-18 04:41:12 +00:00
Jayprakash12345
c48f489ba6 Remove deprecated function wfBaseConvert()
Bug: T189300
Change-Id: I5f05beb105dca8e8079e770df562c004a689c2ed
2018-03-09 16:41:54 +00:00
Umherirrender
554f9c857c Replace wfGetLBFactory
@deprecated since 1.27

Change-Id: I11a7253cebe525948a55cebee183e6de128fdc39
2018-02-27 20:02:48 +00:00
Umherirrender
b5dd5c769a Remove wfProfileIn/wfProfileOut
@deprecated since 1.25

Change-Id: Ie13c31816280fa577ef6bfb5fef172163f83c408
2018-02-24 10:45:31 +01:00
jenkins-bot
89843b44ce Merge "Update suppressWarning()/restoreWarning() calls" 2018-02-11 22:06:29 +00:00
Reedy
fbc0347466 Update MediaWiki\quietCall() -> Wikimedia\quietCall()
Bug: T182273
Change-Id: Id7d8e176fcd93040e30e46cb64fc6a3d36bc8230
2018-02-10 10:49:33 +00:00
Reedy
39f0f919c5 Update suppressWarning()/restoreWarning() calls
Bug: T182273
Change-Id: I9e1b628fe5949ca54258424c2e45b2fb6d491d0f
2018-02-10 08:50:12 +00:00
WMDE-Fisch
d9066cb5f9 Use MediaWiki\restoreWarnings in deprecated wfRestoreWarnings
This will give devs a better hint on how to replace this.

Change-Id: I2332b6173b7816aef11841725752745e174fa69f
2018-01-22 18:53:11 +01:00
Stanislav Malyshev
7efe60da09 Fix phpdoc since $proto can be int
In fact, some of the PROTO_* constants are ints,
some strings and one is null (PROTO_CURRENT).

Change-Id: I69c45ab87360ed1ab54b53b7e9e959ea566b4cba
2018-01-18 13:17:12 -08:00
jenkins-bot
a18476eab3 Merge "Remove @param comments that literally repeat what the code says" 2018-01-11 23:48:03 +00:00
Thiemo Mättig
ef470ebf7f Remove @param comments that literally repeat what the code says
These comments do not add anything. I argue they are worse than having
no comments, because I have to read them first to understand they
actually don't explain anything. Removing them makes room for actual
improvements in the future (if needed).

Change-Id: Iee70aad681b3385e9af282d5581c10addbb91ac4
2018-01-10 14:14:26 +01:00
jenkins-bot
bdf062a8e9 Merge "Treat phpdbg as run from the command line when checking PHP_SAPI" 2018-01-08 23:03:41 +00:00
Kunal Mehta
251a0b97e5 Treat phpdbg as run from the command line when checking PHP_SAPI
phpdbg is a gdb-style debugger for PHP that is run from the command
line. However, it has a different PHP_SAPI value, so it was impossible
to run maintenance scripts with it (until now).

To avoid having to check both PHP_SAPI values in a bunch of places,
introduce wfIsCLI() to easily check whether running from the
command-line or not.

We're (CI team) interested in generating code coverage with phpdbg
instead of xdebug, hence this patch.

Bug: T184043
Change-Id: Id1f994ca146d7858cd8bb6ab6cdbb7718ff524fb
2018-01-03 23:00:37 -08:00
Gergő Tisza
7ef448e97a
Fix RepoGroup caching bug
'bypassCache' was renamed in I9f79e5942ced4ae13ba4de0b4c62908cc746e777
to 'latest' but the cache bypass code was not updated.

Also fix an unrelated phpdoc error.

Change-Id: I141b97300853c60092363a90af063c3fd4941d27
2018-01-02 18:26:46 -08:00
Aaron Schulz
336454104d Try to opportunistically flush statsd data in maintenance scripts
This helps to avoid OOMs from buffer build-ups in the statsd
factory object. This piggy-backs on to the same checks used
for deferred update runs. In addition, the output() method
checks if the data size is getting large and emits if needed.

Bug: T181385
Change-Id: I598be98a5770f8358975815e51380c4b8f63a79e
2017-12-30 05:01:21 +00:00
WMDE-Fisch
b94a2829d4 Get conflict results from diff3
This patch extends the global wfMerge function to also return the
result of the first merge attempt that detects merge conflicts.

The additional output explicitly names the conflicting lines and
could help when solving edit conflicts.

Bug: T151320
Change-Id: I97acebdc87b31779200c7fde4dd4449cd1ee8ead
2017-12-06 13:25:35 +01:00
Stanislav Malyshev
194acaa0e0 Expose string->bool conversion as function
There is code in several places in extensions which converts
setting or parameter string (such as "true", "yes", "false", "no")
to boolean. Since we already have the code that does in global
functions in wfStringToBool(), it makes sense to expose this code
and reuse it.

Change-Id: I88d98b012ff4bf14fd64a05a9135a6e75cf2d4e7
2017-11-15 06:57:40 +00:00
Timo Tijhof
fbfc69f5da Merge ProfilerFunctions into GlobalFunctions
Even if people use these (deprecated) functions in the earliest hooks or in
LocalSettings.php, it will keep working because GlobalFunctions is loaded
between DefaultSettings.php and LocalSettings.php.

The only places affected would be files in core: AutoLoader.php, Defines.php,
and DefaultSettings.php, which don't use these functions.

Change-Id: If4c0e8cbe1ea918283df22d72f792a3806569216
2017-11-09 16:31:55 -08:00
Max Semenik
ca887b5301 Hard deprecate wfRunHooks()
Deprecated since 1.25, very few callers. Having to grep for 2
ways of calling a hook is harmful not only because it wastes developers'
time, but also because it makes it possible to forget to search for the
old way, resulting in mistakes. Better get rid of this.

Change-Id: Iab28bd5758475b780c2016847881757d64973862
2017-10-17 00:36:17 +00:00
jenkins-bot
2373a59e26 Merge "Hard deprecate wfBaseConvert()" 2017-10-13 18:15:34 +00:00
Max Semenik
ba3ced83a4 Hard deprecate wfBaseConvert()
No callers anywhere.

Change-Id: If804d1153ca8e9e82eda3af4d992e395ab112158
2017-10-12 19:38:26 -07:00
Max Semenik
0392d9bb57 Move wfCountDown() into Maintenance class
Doing this allows to restrict it to maintenance scripts and support
quiet mode.

Change-Id: Iad0858ce1fdd64f746d5f9d4a7d6ed96f21e94df
2017-10-12 17:24:46 -07:00
Max Semenik
009764c0ae Hard deprecate wfShellExecDisabled()
No users anywhere, only ever had 1 caller outside of core.

Change-Id: I1361d3b555b642b75ec58f071a02407a611b44f9
2017-10-11 19:42:18 -07:00
jenkins-bot
a7f7bc7981 Merge "Refactor global function wfBCP47 to static function LanguageCode::bcp47" 2017-10-05 17:55:50 +00:00
Fomafix
ea0bd74a94 Refactor global function wfBCP47 to static function LanguageCode::bcp47
Deprecate global function wfBCP47.

Change-Id: Ie6bb061b5d6ca67289bb18bc468a87421f38fc94
2017-10-05 09:54:45 +02:00
Max Semenik
31475c87b2 Hard deprecate wfInitShellLocale()
Soft deprecated since 1.30, no callers anywhere.

Change-Id: Ifec11eb3c2c25ea9d7e5ecb72c53127536ab6c30
2017-10-04 14:58:38 -07:00
Brad Jorsch
2c34fd6e0e Replace uses of each()
It's deprecated in PHP 7.2, may as well replace it now.

I note that, contrary to claims at
https://wiki.php.net/rfc/deprecations_php_7_2#each, none of our uses
were trivially replaceable with foreach.

* wfArrayDiff2_cmp() is processing two arrays by value in parallel.
* MagicWordArray::parseMatch() is doing something funky with the data
  structure returned by preg_match().
* HashRing was using it like "nextKey()", replaced with calls to key()
  and next().
* FormatMetadata and IndexPager were both using it as a shorter way to
  get both key() and current() for the first element in the array. I
  suppose a foreach(){ break; } would do the same, but that's confusing.

Bug: T174354
Change-Id: I36169a04c764fdf1bfd6603395111c6fe0aae5eb
2017-09-20 09:51:28 -04:00
jenkins-bot
af09cc1088 Merge "Port BCP47 formatter from PHP to JavaScript" 2017-09-12 11:43:49 +00:00
Niklas Laxström
990c1f0ad2 Port BCP47 formatter from PHP to JavaScript
It can be accessed via mw.language.bcp47.
To be used in ContentTranslation, see T157212

Change-Id: I37d32ab8a55c7101b903b03869899f00a39afd11
2017-09-12 11:07:31 +00:00
Max Semenik
77ce3b98a0 Replace wfShellExec() with a class
This function has gotten so unwieldy that a helper was
introduced. Instead, here's this class that makes
shelling out easier and more readable.

Example usage:
  $result = Shell::command( 'shell command' )
       ->environment( [ 'ENVIRONMENT_VARIABLE' => 'VALUE' ] )
       ->limits( [ 'time' => 300 ] )
       ->execute();

  $exitCode = $result->getExitCode();
  $output = $result->getStdout();

This is a minimal change, so lots of stuff remains
unrefactored - I'd rather limit the scope of this commit.
A future improvement could be an ability to get stderr
separately from stdout.

Caveat: execution errors (proc_open is disabled/returned error) now
throw errors instead of returning a status code. wfShellExec() still
emulates this behavior though.

Competing commit: I7dccb2b67a4173a8a89b035e444fbda9102e4d0f
<legoktm> MaxSem: so you should continue working on your patch and I'll
          probably refactor on top of it later after its merged :P

Change-Id: I8ac9858b80d7908cf7e7981d7e19d0fc9c2265c0
2017-09-08 21:49:49 -07:00
Max Semenik
104d864425 Remove deprecated function wfFixSessionID()
Deprecated since 1.27, no callers anywhere.

Change-Id: I2d1019fdb21fe4a9d0aa767a71eb18739f841dfb
2017-09-08 18:26:11 -07:00
Max Semenik
5fd5f6dbba Deprecate wfUsePHP()
No callers anywhere.

Change-Id: I47256448d313983e3cebd713f7c149e3c3a9ab47
2017-09-08 18:03:09 -07: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
Eddie Greiner-Petter
351a699180 Hide "hideuser" on Special:Block for non-infinite blocks
Users with the hideuser right have an extra checkmark on Special:Block
to hide user, however this functionality can only be used on registered
users (not IPs) and only if a block is set to never expire. With this js
enhancement, hide the "hideuser" checkbox and label if the block time is
not set to infinite (either as selected from the dropdown or written
into the "other" input box).

Attribution to meta.wikimedia.org/wiki/User:Margott who uploaded a
draft for this patch on the task a while ago.

Bug: T133036
Change-Id: Ia8c3e25d923e1df57d5afd69e9de3d6f2543f628
2017-07-26 19:28:42 +00:00
Kunal Mehta
399adec9ad Turn ParserCache into a service, deprecate $parserMemc
ParserCache is already a singleton, making it a good candidate for a
service. $parserMemc is an odd global (it lacks the "wg" prefix) and is
ripe for deprecation.

The following are now deprecated:
* $parserMemc global
* ParserCache::singleton()
* wfGetParserCacheStorage()

A ParserCache::getCacheStorage() method was added for cases where direct
access to the underlying BagOStuff object is necessary.

Usage of $parserMemc will emit deprecation warnings through the
DeprecatedGlobal class mechanism. All usage in core was migrated.

Also take this opportunity to inject the $wgCacheEpoch global value into
ParserCache. This will require an update to the FlaggedRevs extension.

Change-Id: I2ac7afff0d8522214329248c3d1cdccd0f72bbd4
2017-07-05 19:56:49 -07:00
jenkins-bot
447ba02601 Merge "Improve documentation for wfParseUrl" 2017-06-18 19:18:39 +00:00
Gergő Tisza
dc01555a3f Improve documentation for wfParseUrl
Change-Id: I84ef76d2e3b026ed38e02a82245b559324950ede
2017-06-18 13:33:34 +02:00
Gergő Tisza
016452cd09 ChangesList: Expose basic properties of lines as data attributes
We have several types of change lists (old RC/watchlist/related
changes, enhanced RC/watchlist, history) with slightly different
HTML, each with their own idiosyncracies. JavaScript code trying
to identify lines by log ID / revision ID has to jump through all
kinds of hoops to work with that.

To simplify the lives of frontend / gadget maintainers and provide
something approaching an API for these pages, we now expose the basic
attributes of each change line (revision ID for edits, log type/action
and ID for log events) as data attributes.

The OldChangesListRecentChangesLine, EnhancedChangesListModifyLineData,
EnhancedChangesListModifyBlockLineData, PageHistoryLine,
ContributionsLineEnding and DeletedContributionsLineEnding hooks
are updated accordingly. New hooks (LogEventsListLineEnding and
NewPagesLineEnding) are added for the change list pages which did
not yet have them.

Change-Id: I6dd006d0b1b0fd35c0020f0f9eea9113eca30b35
2017-06-08 23:19:45 +00:00
Brad Jorsch
fb6f4d35e7 Apply $wgShellLocale in Setup.php
While most of MediaWiki ignores the shell's/C library's locale setting,
there are some things other than shell execs that use it (e.g. the
luasandbox PHP extension).

To provide a consistent environment, set the locale in Setup.php instead
of letting it be changed mid-request depending on whether something else
happened to have called certain functions.

Bug: T107128
Change-Id: I02943803d26d5b1b3ac00ef9216f69cdfa149585
2017-06-01 15:11:01 +10:00
jenkins-bot
163381a091 Merge "Refactor Statsd classes to enable null collector to work." 2017-05-30 03:41:14 +00:00
Stanislav Malyshev
7fdc3d09a3 Refactor Statsd classes to enable null collector to work.
The following changes are added:
- Created MediawikiStatsdDataFactory interface
- Added hasData() method to see if there are any data to send
- Added getData() method to fetch data
- Made service infrastructure use MediawikiStatsdDataFactory interface
- Made wfLogProfilingData() use MediawikiStatsdDataFactory interface
- Added capability to enable/disable buffering collector

Bug: T166354
Change-Id: I2874175647e987996a9a399829b3319674471aaa
2017-05-29 15:33:02 -07:00
Kunal Mehta
ee8eb0fc94 wfIsBadImage: Avoid deprecated wfMemcKey()
Change-Id: I92133ed6a94902bdac2e9723f19a653a9962b757
2017-05-25 12:37:35 -07:00
Kunal Mehta
314cda9b0a Fix up deprecation of wfMemcKey()/wfGlobalCacheKey()
* Move @deprecated tags out of the header so the documentation comment
  still has a summary
* makeKey() and co. are part of BagOStuff, not ObjectCache

Follows up 1e5961dbf6.

Change-Id: I168ce97597f288f6345a404354d68371e57522d3
2017-05-23 14:58:54 -07:00
jenkins-bot
4d3b5d8440 Merge "GlobalFunctions: Avoid unnecessary fully-namespaced MediaWikiServices" 2017-05-23 05:28:04 +00:00