Commit graph

7031 commits

Author SHA1 Message Date
Thiemo Kreuz
e1dd371e11 Make use of PHPUnit's assertCount feature where possible
… and avoid assertEmpty() on arrays, in favor of a much more strict
assertSame( [] ).

Change-Id: I20266b0b1fc38a3a87666ba1b0793cb2b37d94a9
2020-03-02 15:58:41 +00:00
jenkins-bot
76b79714ef Merge "include blob: as a default script-src" 2020-02-29 20:17:03 +00:00
DannyS712
0f9fc7b76f Hard deprecate Revision::countByPageId
Part of the soft deprecated revision class, no known callers outside of a test, which hide the deprecation

Bug: T246284
Change-Id: I7b80c7e51e26845d2703d1dc5434baf9d0744d11
2020-02-29 03:23:55 +00:00
DannyS712
2efa4b69a9 Hard deprecate Revision::loadFromTitle
Part of the soft deprecated revision class, no known callers outside
of EditPage, which is updated, and tests, which hide the deprecation

Bug: T246284
Change-Id: I099cb93a12f3a1d9a720e18e3236374321ce7b0c
2020-02-28 19:10:17 -08:00
Thiemo Kreuz
8d57c5e32c Replace weird stdClass mock with class actually expected
Change-Id: I7abc014b6c82f5f5a62b807a43a623ef7d1fe721
2020-02-28 21:07:43 +00:00
jenkins-bot
8cbceea5c2 Merge "tests: Replace a very long string with str_repeat" 2020-02-28 18:30:39 +00:00
jenkins-bot
53c4d327d0 Merge "debug: Remove $wgDebugTimestamps feature" 2020-02-28 04:46:40 +00:00
jenkins-bot
05b1712cbe Merge "resourceloader: Add more granular phan type information in various classes" 2020-02-27 21:21:26 +00:00
Brian Wolff
c29ad0f20a include blob: as a default script-src
blob: is basically a fancy version of eval(), commonly used with
web workers. We currently allow eval() ('unsafe-eval'), so we
might as well include blob. If we try and lock-down eval() at
some later point, we can re-evaluate this decision.

AFAIK, blob: urls are currently used with web workers in
NavigationTiming and CodeEditor extensions.

Bug: T245981
Change-Id: I3c44286e140ddfe2d3abd31428e0770ff5531e37
2020-02-27 19:02:55 +00:00
Petr Pchelko
0f87f5885c Convert JobRunner into a service and use DI
Bug: T246156
Change-Id: If4f67a6fa0e26ade3fc0420e62fa836c2a3e4b2e
2020-02-27 08:04:48 -08:00
Daimona Eaytoy
183edf76fd tests: Replace a very long string with str_repeat
Strings like this can make it problematic to scroll the page.

Change-Id: Ic2a5905fc64ea2d3bc1cb76746170953a671d107
2020-02-27 09:41:25 +00:00
DannyS712
7186b63f82 Hard deprecate Title::getUserPermissionsErrors
Remove final uses as well

Bug: T244929
Change-Id: I65e937c7b9904b1e93f649508b14148849589f82
2020-02-26 05:09:55 +00:00
jenkins-bot
ab7028b9b5 Merge "Replace calls to Title::getUserPermissionsErrors (part 5)" 2020-02-26 03:28:16 +00:00
DannyS712
909f0bef6e Replace calls to Title::getUserPermissionsErrors (part 5)
This does //not// fix all calls in core.

Bug: T244929
Change-Id: I02ffcca31fa0bdc6bffddf21e82f4ff5e9ab5374
2020-02-26 03:00:33 +00:00
jenkins-bot
fb808a5758 Merge "Inject language services into ApiQueryLanguageinfo" 2020-02-25 16:12:41 +00:00
jenkins-bot
5949b43699 Merge "Update all use of $wgVersion to MW_VERSION" 2020-02-25 16:04:01 +00:00
jenkins-bot
e8e35a64ff Merge "Provide MW_VERSION and deprecate fake global $wgVersion" 2020-02-25 16:03:54 +00:00
jenkins-bot
9b1445e1c5 Merge "Escape % sign if form valid percent-encoding in fragment identifiers" 2020-02-25 11:33:38 +00:00
Timo Tijhof
f575721a06 Update all use of $wgVersion to MW_VERSION
Follows-up I04628de4152dd5.

Bug: T212738
Change-Id: I718474ec0d9fd29ac2c05477f0f2493615d8aff5
2020-02-25 02:16:12 +00:00
Timo Tijhof
a5d5ea82ca Provide MW_VERSION and deprecate fake global $wgVersion
$wgVersion is not a configuration variable, it should never be
changed at run-time.

While we've gone in the route of class constants for most constants,
this one will not benefit from class-autoloading since it needs to
be present from the very beginning.

MW_VERSION is named similarly as PHP_VERSION, and $wgVersion is
now soft-deprecated.

Bug: T212738
Change-Id: I04628de4152dd5c72646813e08ff35e422e265a4
2020-02-25 01:55:21 +00:00
DannyS712
d3aa888904 Hard deprecate Revision::userCanBitfield
Also replace uses. Some callers had a user that could be null;
RevisionRecord::userCanBitfield requires a user, so add $wgUser
fallbacks at the callers with soft deprecations for using them,
and will hard deprecate in a subsequent task.

Bug: T245958
Change-Id: I137e21e3883b149fdd98d1b59d4e498d15b39dd9
2020-02-24 21:18:49 +00:00
Lucas Werkmeister
3201bf5e39 Inject language services into ApiQueryLanguageinfo
Change-Id: I05a03d7a81aad3d9b592e062412eea1c1e9b57d8
2020-02-24 19:37:37 +01:00
Timo Tijhof
f081a71f2c debug: Remove $wgDebugTimestamps feature
MediaWiki provides at least a dozen distinct ways that debug logs
can be generated, augmented and displayed, and even more ways
for profiling information can be collected. This makes it difficult
to reason about overall and isn't helping with on-boarding.

Reduce investments to only a few methods and make them great,
starting by removing possibly the least useful profiler we have
today (relative to the others we've developed since then),
which is the "relative timestamps and memory use" prepended
to wfDebug messages, which would presumably be used in conjuction
with $wgDebugComments, $wgDebugToolbar or $wgDebugLogFile of
which the latter two already includes timestamps and/or offsets.
If this is truly useful, I suggest we (unconditionally) make use
of offsets in (one of) those instead.

Originally introduced in r61582 (b1e2b87b95).

Change-Id: I09d1cb0d3f5b0b3165ed4d299b71c051b78a1918
2020-02-24 13:08:33 +00:00
DannyS712
2bcbc5912b Hard deprecate all methods of old SpecialPageFactory
Bug: T245686
Change-Id: I5ff279f08888bef8cd0bc0f35c9808bc16c4966c
2020-02-23 22:07:09 +00:00
DannyS712
1948049498 Hard deprecate Title::userCan and ::quickUserCan
Bug: T244923
Bug: T244927
Change-Id: I1a064aeb3fc87573af50ae5b14793e750696371d
2020-02-22 01:53:03 +00:00
Timo Tijhof
a3ce1f9da7 resourceloader: Add more granular phan type information in various classes
* Where possible and easy to figure out, change `array` to something like
  `array<K,V>` or `V[]` for improved static analysis to catch/prevent
  regressions in CI.

* Minor doc improvements:
  - consistently use the imperative mood for method briefs,
  - consistently use @internal instead of @private,
  - explain in @throws why they happen to inform when they should be caught
    (and remove if they are not meant to be caught/handled by any caller).

* Simplify addSources() implementation as a simple loop instead recursing
  (not worth the complexity, only called once or twice at runtime).

* Use more granular exceptions to distinguish between errors that indicate
  a mistake on the caller (logic/invalid arguments error), and runtime
  errors (which are more circumstantial).

* Update register() unit test for bad 'moduleInfo' type to use
  a nested value, given that the second-parameter level type is
  now verified by the signature already.

Change-Id: Id98ba1f28cb7f1c72f0a3e82f4151bcbd0f3db77
2020-02-21 23:54:33 +00:00
jenkins-bot
1cb25b580a Merge "Fix the namespace of SpecialPageFactory" 2020-02-21 15:41:18 +00:00
jenkins-bot
4e18398c30 Merge "Remove Title move functions, deprecated in favor of MovePage class" 2020-02-21 04:50:39 +00:00
Tim Starling
44d51cb04e Fix the namespace of SpecialPageFactory
Follows-up d4045035b0.

This class was added to the MediaWiki\Special namespace, contrary to the
plan in T166010 which reserves that namespace for core special pages.
Instead, use MediaWiki\SpecialPage, following the directory in which it
is located.

Also, fix two bugs which prevented the introduction of a namespaced
class alias.

Bug: T166010
Change-Id: I6e31340aaae32a89beb7e45b79d76a7fea9808d2
2020-02-21 13:46:19 +11:00
jenkins-bot
4fcb08e8da Merge "UserDef: Don't return incomplete UserIdentityValues" 2020-02-20 17:46:21 +00:00
Thiemo Kreuz
05fd10ffa9 user: Use more native PHPUnit assertions in UserTest
* Make use of assertGreaterThan() where possible.
* Use the more trivial assertSame() for arrays with only 0 or 1
  elements.
* Flip a few assertions where the expected and actual value have been
  flipped.
* Remove some unused function arguments.

Change-Id: I1d3b5dd55736931fa484065a4aa8d7e336980682
2020-02-20 08:24:00 +01:00
DannyS712
fdd814d3ee Remove Title move functions, deprecated in favor of MovePage class
Removes Title::isValidMoveOperation(), ::moveTo(), and
::isValidMoveTarget()

Bug: T241341
Change-Id: I56993a7f29923c467940318ee77f58dd64abcc30
2020-02-19 20:44:55 -08:00
jenkins-bot
b99719a1ca Merge "Remove CommentStore::newKey, deprecated and unused" 2020-02-20 02:31:35 +00:00
jenkins-bot
4027bf95e2 Merge "Deprecate falling back to $wgUser in some functions" 2020-02-20 02:04:07 +00:00
jenkins-bot
67f499b6bd Merge "Tests: Pass a user to FileDeleteForm::doDelete" 2020-02-20 02:01:10 +00:00
DannyS712
cb5bcac4ff Remove CommentStore::newKey, deprecated and unused
Bug: T241957
Change-Id: If074df75e4c739a633e9d7f6578c34130264e89d
2020-02-20 02:00:15 +00:00
jenkins-bot
bd9bef8add Merge "Use existing $this->user property in UserTest where possible" 2020-02-20 01:35:12 +00:00
DannyS712
c013ac2ccc Tests: Pass a user to FileDeleteForm::doDelete
Bug: T245682
Change-Id: Iab5b07877c836d6b67de47bb56c56b91a1bcf688
2020-02-19 22:32:31 +00:00
DannyS712
328f093458 Deprecate falling back to $wgUser in some functions
Not passing a user to the following functions is deprecated:
* Title::getNotificationTimestamp
* Revision::newNullRevision
* WikiPage::insertProtectNullRevision
* PatrolLog::record
* LogEventsList::userCan
* LogEventsList::userCanBitfield
* LogEventsList::userCanViewLogType
* LogPage::addEntry

Bug: T242935
Bug: T243652
Change-Id: I8990bc16ac72680fb65f8ca37eb7908749a9e5cc
2020-02-19 21:43:46 +00:00
Bartosz Dziewoński
68e495d8b0 ApiMain: Add support for assert=anon
In VisualEditor, when the user is saving their edit, we want to ensure
that they understand how their edit will be attributed. Therefore, if
the user gets logged out or logs in in another tab, we want to display
a message about it before saving.

We've been detecting this situation by manually managing tokens and
handling the 'badtoken' error, but our code would be much simpler and
it would be possible to share it with other extensions if we could
instead rely on automatic retrying in mw.Api#postWithToken and use
'assertuser' and 'assert' parameters. 'assert=anon' is the only
feature we're missing.

Bug: T245327
Change-Id: I485f99e1f5f493262b0c9af22370da01adf1e09c
2020-02-19 22:37:31 +01:00
jenkins-bot
23c920b3bf Merge "Follow-up 0437877: SanitizerTest: Fix whitespace, test false state too" 2020-02-19 21:26:18 +00:00
Brad Jorsch
4d877c12a9 UserDef: Don't return incomplete UserIdentityValues
IPs and external names could still have an actor ID. Don't return a
UserIdentityValue with the actor ID set to zero for these.

For now, that means we'll always return a User object since those have
the logic to fill in missing fields.

Bug: T245652
Change-Id: I7df3629d2c892b61f61f763db099be9974ec7f07
2020-02-19 15:28:40 -05:00
Gergő Tisza
8a08f2a806
Use dependency injection for AuthManager and allow it for providers
Change-Id: Icf3345bec993f8cb103f065e76b04fe1f3521639
2020-02-19 01:18:16 -08:00
jenkins-bot
a44570b973 Merge "Add object-src 'none' to MW CSP directive (configurable)" 2020-02-19 01:01:59 +00:00
Brian Wolff
97c992eb5d Add object-src 'none' to MW CSP directive (configurable)
<object> and <embed> are from a mostly bygone era. They often can
be used to evade CSP rules, and are often a soft spot for browser
security.

The default value of 'none', disables <object>, <embed>. In some
browsers this will also disable loading some file formats like
pdf directly in an iframe.

The only use I am aware of is in TimedMediaHandler. However, it seems
like the mw.EmbedPlayerGeneric, mw.EmbedPlayerKplayer, and
mw.EmbedPlayerVlc.js are no longer used.

Bug: T239051
Change-Id: Iae7ab1f5b7c422803782848c787bc1a4c6339913
2020-02-18 16:20:56 -08:00
jenkins-bot
191840b16a Merge "Fix some PHPStorm warnings by replacing array functions with loops" 2020-02-18 23:07:25 +00:00
Tim Starling
f2abcbb4ec Fix some PHPStorm warnings by replacing array functions with loops
I find most uses of array_filter(), array_reduce(), etc. to be
excessively clever, i.e. they are used to prove how smart the
developer is, at the expense of readability and performance. So I am
pleased to have a defensible reason to remove these instances, which
broke PHPStorm's type propagation.

Change-Id: I03dcd6c3c80f19f90e7b39448b5508713da63806
2020-02-19 09:28:44 +11:00
jenkins-bot
dd1fec96ad Merge "Add more tests for the user class" 2020-02-18 20:34:59 +00:00
jenkins-bot
71ba5005cf Merge "Hard deprecate ApiTestCase::doLogin" 2020-02-18 19:28:42 +00:00
jenkins-bot
c664b4f1b9 Merge "Don't tell user when email is required but not supplied" 2020-02-18 17:32:51 +00:00