Commit graph

1579 commits

Author SHA1 Message Date
James D. Forrester
0958a0bce4 Coding style: Auto-fix MediaWiki.Usage.IsNull.IsNull
Change-Id: I90cfe8366c0245c9c67e598d17800684897a4e27
2020-01-10 14:17:13 -08:00
DannyS712
24b11bc7d3 Remove wfGlobalCacheKey global function, deprecated and unused
Bug: T241350
Change-Id: Icdb2512f3ec10bc4b26a6faa08f14d7603176c82
2020-01-08 01:08:55 +00:00
Fomafix
6a3f192d11 Forbid wfDeprecated with $version = true
$version = true is not supported.

Change-Id: Id08ada32cd0273564c638d242354351333a9f163
2019-12-31 13:53:36 +01:00
Umherirrender
4854212539 Allow all kind of arrays on wfAppendQuery
wfArrayToCgi accept also arrays of array, so the string[] is to strict
on wfAppendQuery

Change-Id: I719fec91cb765a1673299974ec0eea59c37ce72f
2019-12-29 12:22:08 +01:00
Umherirrender
615f53d8bd Update @param of wfMessage
Use the same as for MessageLocalizer::msg

mixed is needed, because it can also accept int or arrays from
Message:numParam and friends

Change-Id: I56df8c61c933dfa0e3458739a8d26b00be061c80
2019-12-21 10:44:06 +01:00
Daimona Eaytoy
25ba3b3794 Document more scalar types for BagOStuff::makeKey and Language::formatNum
These were spotted by phan's stricter type checks. All make*Key methods
can also take integers, and that's pretty common across core and
extensions.
Language::formatNum can also take numbers (and tests cover this case);
in this case, move the cast to the top of the method, so that we're
passing a string to strtr, too.

The methods touched in this patch are the main source of false positives
in both core and extensions.

Change-Id: I6d538ce3ca7fd2d495c2bafbab7cc279da69db1c
2019-12-15 00:02:04 +00:00
Daimona Eaytoy
598c4d7fcb build: Upgrade phan to 0.9.0
Scalar casts are still allowed (for now), because there's a huge amount
of false positives. Ditto for invalid array offsets.

Thoughts about the rest: luckily, many false positives with array offsets
have gone. Moreover, since *Internal issues are suppressed in the base
config, we can remove inline suppressions.

Unfortunately, there are a couple of new issues about array additions
with only false positives, because apparently they don't take
branches into account.

Change-Id: I5a3913c6e762f77bfdae55051a395fae95d1f841
2019-12-07 20:16:19 +00:00
Umherirrender
337ecb0514 Add missing @param and @return to documentation
Change-Id: Ibc5849cc8ea7e7c4eb30ded9c1cfa5f52187c377
2019-11-10 22:12:58 +00:00
jenkins-bot
73bd3d8b1c Merge "Hard deprecate wfGetRusage(), no known callers" 2019-11-01 03:18:18 +00:00
jenkins-bot
17b931caf6 Merge "Remove Language::factory and getParentLanguage use" 2019-10-29 09:25:29 +00:00
Brian Wolff
67ea4f5747 Mild refactoring of ContentSecurityPolicy
This is to make it behave in a more object orientied way. The
goal is to make it be easier to allow extensions to mark certain
pages as requiring a different policy (For example, CodeEditor
extension uses a blob: url with a WebWorker. We don't want to
include that on the policy of every page, but allow the extension
to mark it as required whenever needed).

This commit does not change code behaviour in any way.

Change-Id: I4bf53dabb6e6c5446cea99a64db68b300cef2fd4
2019-10-28 09:02:14 -07:00
Aryeh Gregor
0de9c47b50 Remove Language::factory and getParentLanguage use
Change-Id: I11f8801ef47ec1a1f63d840116e69667e6f3ae3c
2019-10-27 12:34:28 +02:00
jenkins-bot
248c72fb25 Merge "Deprecate wfWikiId() in favor of WikiMap::getCurrentWikiDbDomain()" 2019-10-27 00:30:58 +00:00
jenkins-bot
533346b24f Merge "Deprecate wfGetRusage(), no longer useful" 2019-10-22 14:13:14 +00:00
James D. Forrester
9ed8bb4092 Hard deprecate wfGetRusage(), no known callers
Change-Id: I157386ab0c2991fc8ed55f0e0b77d8cecf86d04c
Depends-On: Ic70d0304e9cd04d4011671e498146e4b5994cbe9
2019-10-22 11:32:23 +01:00
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