Commit graph

1720 commits

Author SHA1 Message Date
Amir Sarabadani
7690ab4e33 Reorg: Move HeaderCallback to Request directory
Cleaning root of includes/

Bug: T321882
Change-Id: I1844da95d4fd79824646fdf4b6063cb771ca3000
2022-11-08 10:53:27 +01:00
jenkins-bot
89920e0b23 Merge "Revert "Reorg: Move some of request related classes to MediaWiki/Request"" 2022-10-27 14:23:29 +00:00
Zabe
f6b9381d7f Revert "Reorg: Move some of request related classes to MediaWiki/Request"
This reverts commit 2bdc0b2b72.

Reason for revert: T166010#8349431

Bug: T166010
Change-Id: Idcd3025647aec99532f5d69b9c1718c531761283
2022-10-27 13:14:16 +00:00
jenkins-bot
0a2d909437 Merge "Reorg: Move some of request related classes to MediaWiki/Request" 2022-10-27 12:22:34 +00:00
Amir Sarabadani
2bdc0b2b72 Reorg: Move some of request related classes to MediaWiki/Request
Moving:
 - DerivativeRequest
 - FauxRequest
 - FauxRequestUpload
 - PathRouter
 - WebRequest
 - WebRequestUpload

Bug: T166010
Change-Id: I5ea70120d745f2876ae31d039f3f8a51e49e9ad8
2022-10-26 16:49:10 +02:00
Timo Tijhof
3270283abf ResourceLoader: Add structure test for foreign-resources.yaml
Enable the equivalent of running `manageForeignResources.php verify`
as a structure test via PHPUnit.

Related cleanups for this to work well:

* Improve cache key readability before enabling in CI.
* Document how we do caching in CI.
* Change some exceptions to errors so that we don't
  stop on the first error, thus improving the usefulness of the CI
  result by telling the developer all mismatches instead of only
  the first.
* Fix incorrect typehint for nullable $integrity.

Bug: T203694
Change-Id: I8aeffc1f2e81ffcf037977528f94c00995791999
2022-10-26 10:24:15 -04:00
Amir Sarabadani
0fff5089ba Reorg: Move StubObject classes in includes to its own directory
Bug: T166010
Change-Id: Idcf0e9dc6e0841e4f132207bce0f96774dad898c
2022-10-25 16:04:48 -04:00
Tim Starling
0077c5da15 Use short array destructuring instead of list()
Introduced in PHP 7.1. Because it's shorter and looks nice.

I used regex replacement.

Change-Id: I0555e199d126cd44501f859cb4589f8bd49694da
2022-10-21 15:33:37 +11:00
jenkins-bot
f221b44a08 Merge "Remove deprecated global function wfLogProfilingData" 2022-10-12 19:15:37 +00:00
Daimona Eaytoy
947ff7c0f5 build: Update mediawiki/mediawiki-phan-config to 0.12.0
This patch only adds and removes suppressions, which must be done in the
same patch as the version bump.

Bug: T298571
Change-Id: I4044d4d9ce82b3dae7ba0af85bf04f22cb1dd347
2022-10-08 15:45:42 +02:00
Umherirrender
b7f52e2fb9 Remove deprecated global function wfLogProfilingData
Deprecated in 296b485
Fix comment about this function and wrong mention of pre-send,
but it is post-send, documented in c49a45f

Change-Id: I29448377ca785843d7cd16f8c458d31b77b8bbe6
2022-09-30 21:24:48 +02:00
Umherirrender
c34db14fbe Remove deprecated global function wfQueriesMustScale
Last usage was in FlaggedRevs, removed in Ie3d8ab35c978458ee.
Deprecated in core since 1.39 with Ic2971c31f29babb48fb.

Change-Id: Ieaccaab3e8805ecb387480990f945bca6f989c2d
2022-09-30 18:48:11 +00:00
Umherirrender
04bd85cd5e Remove hard-deprecated wfReadOnly/wfReadOnlyReason
Bug: T283978
Change-Id: I2ef829bb9f5b89d4b9c77718ca2e090b0cbd3264
2022-09-23 22:44:44 +02:00
Gergő Tisza
94b43c8ce2
Fix documentation of wfTimestamp()
Change-Id: I12a5ad918aa16fb329a95615b6a470953ce68154
2022-08-24 18:25:38 -07:00
Máté Szabó
36dd10f9de Migrate use of ${var}-style string interpolation
The "${var}" and "${expr}" style string interpolations are deprecated in
PHP 8.2. Migrate usages in core to "{$var}" as appropriate.

Bug: T314096
Change-Id: I269bad3d4a68c2b251b3e71a066289d4ad9fd496
2022-07-29 02:45:09 +02:00
Mark A. Hershberger
f6039593ef Handle null passed to wfShorthandToInteger() and Html::element()
null is tested as a parameter in GlobalTest::provideShorthand() and
HtmlTest::testElementBasics(), so handling null must be important.

Bug: T289926
Change-Id: I7421fb618fbce221c638bc6faf208db5e9935545
2022-07-12 13:21:18 +00:00
jenkins-bot
f5ba3b2e8e Merge "Remove deprecated wfGetScriptUrl" 2022-07-08 15:27:10 +00:00
jenkins-bot
54583e98b3 Merge "Remove deprecated wfLocalFile and wfFindFile" 2022-07-08 15:26:29 +00:00
Umherirrender
51f9040be4 Remove deprecated wfLocalFile and wfFindFile
Bug: T249020
Change-Id: I9988e0abcec39ec0c6e92a92d40363a45483f016
2022-07-07 18:49:31 +00:00
Umherirrender
0c77580f7e Deprecate unused wfQueriesMustScale
Change-Id: Ic2971c31f29babb48fb211b600a79876351ababb
2022-07-07 18:42:12 +00:00
Umherirrender
ba9f124cd3 Remove deprecated wfGetScriptUrl
Change-Id: I856f390b5329e06e9d7047ee980cc49813b11e00
2022-07-07 20:35:01 +02:00
Umherirrender
b90cb191a1 Hard deprecate wfReadOnly/wfReadOnlyReason
Bug: T283978
Change-Id: I99177bedc32e219dc2e6ae6e114787d0602bfb22
2022-06-28 21:21:51 +02:00
Matěj Suchánek
fe1c0672dd Remove wfCanIPUseHTTPS
It has been deprecated since 1.37 and it is unused.

Change-Id: Ie4a85c608c7a78fad61d3effae35b0b81da05451
2022-06-25 19:41:56 +02:00
Tim Starling
3e2653f83b ResourceLoader namespace (attempt 2)
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader itself.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Revert of a241d83e0a.

Bug: T308718
Change-Id: Id08a220e1d6085e2b33f3f6c9d0e3935a4204659
2022-05-24 15:41:46 +00:00
Matěj Suchánek
b2c8e5d9d8 Improve replacement hint for wfGetDB
getConnectionRef has been deprecated since 1.39 (a294e71).

Follow-Up: I5dcaf438cd8724c8df709f606f69ae92ec85b059
Change-Id: I360ebc2b2f0df14fa845373cfb5cb6620c7009d2
2022-05-23 16:04:44 +00:00
jenkins-bot
ac5a110b83 Merge "Soft deprecate the global function wfGetDB()" 2022-05-21 14:31:22 +00:00
Lucas Werkmeister (WMDE)
a241d83e0a Revert "ResourceLoader namespace"
This reverts commit e08ea8ccb9.

Reason for revert: Breaks Phan in extensions, and as far as I’m aware,
this change isn’t urgently needed for anything, so the simplest fix is
to revert it again for now. After PHP 7.4 it should be safer to try this
again (we hopefully won’t need the two “hack” classes by then).

Bug: T308443
Change-Id: Iff3318cbf97a67f821f78e60da62a583f63e389e
2022-05-16 14:43:33 +00:00
Tim Starling
e08ea8ccb9 ResourceLoader namespace
Move ResourceLoader classes to their own namespace. Strip the
"ResourceLoader" prefix from all except ResourceLoader and
ResourceLoaderContext.

Move the tests by analogy.

I used a namespace alias "RL" in some callers since RL\Module is less
ambiguous at the call site than just "Module".

I did not address DependencyStore which continues to have a non-standard
location and namespace.

Change-Id: I92998ae6a82e0b935c13e02a183e7c324fa410a3
2022-05-16 14:41:27 +10:00
Matěj Suchánek
e47c441078 Fix many typos in comments
Found using IntelliJ's "Typo" code inspection.

Change-Id: I746220ebe6e1e39f6cb503390ec9053e6518cf16
2022-05-10 12:46:11 +00:00
Alexander Vorwerk
ef80fbb410 Remove deprecated global function wfGetLB()
deprecated since 1.27 and unused in deployed code

Change-Id: I8c098dfd1c09c7de1951273729bbac6464b89d90
2022-04-14 04:28:15 +00:00
Alexander Vorwerk
83a5667683 Soft deprecate the global function wfGetDB()
The global function wfGetDB() should be replaced with LoadBalancer::getConnection()

Bug: T273239
Change-Id: I5dcaf438cd8724c8df709f606f69ae92ec85b059
2022-04-13 23:54:59 +02:00
Aryeh Gregor
472a914c63 Refactor URL-parsing global functions to class
The new class, UrlUtils, is usable standalone or as a service. Using it
as a service will just automatically load a few settings from site
configuration.

In addition to just making our code cleaner, this will enable making
some of Setup.php's dynamic configuration more sane.

Test coverage is all lines except invalid URLs -- I couldn't find any.

Bug: T305093
Change-Id: I706ef8a50aafb518e13222719575d274c3583b90
2022-04-12 15:14:35 +03:00
jenkins-bot
d5dbca4b11 Merge "Remove deprecated global function wfWikiID()" 2022-03-31 19:49:58 +00:00
Umherirrender
6caf78c2c8 phan: Remove PhanPossiblyUndeclaredVariable suppression
Make phan stricter about conditional variable declaration
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T259172
Change-Id: I1f200ac37df7448453688bf464a8250c97313e5d
2022-03-30 19:47:15 +00:00
James D. Forrester
24e67e03b1 phan: Upgrade mediawiki-phan-config to 0.11.1 and set minimum_target_php_version
MediaWiki still supports PHP 7.2+, but we want to mainly test in newer versions
of PHP. Setting minimum_target_php_version to 7.2 this lets us run phan without
phan trying to get us to make PHP 7.2-incompatible changes to 'appease' PHP 8.0
or whatever later changes.

Some switches of generic 'resource' type-hinting to 'resource|object' to inform
phan to ignore this (triggering PHPCS at the time, ah well), rather than trying
to hint the specific novel PHP encapsulation classes to that have replaced them
from PHP 8.0 onwards but don't yet exist, and fixes from where we were checking
the results of implode and explode.

Bug: T293924
Change-Id: I629e3fb3adfad73beb3d424a07e643c2e079d9bb
2022-03-29 16:54:36 +00:00
Alexander Vorwerk
0bbc238919 Remove deprecated global function wfWikiID()
deprecated since 1.35 and unused

Bug: T298059
Change-Id: I0c601b67beaf8218b7fd7ca46a8caeb1452f4d76
2022-03-29 18:11:05 +02:00
Alexander Vorwerk
32f68bb947 Remove wfGetCache() and wfGetMainCache(), deprecated since 1.32
Bug: T293928
Change-Id: If6d51b5c825d3f34eec91275dae05abb95a9c46e
2022-03-27 16:37:36 -04:00
Umherirrender
1f71eccf63 phan: Disable null_casts_as_any_type setting
Make phan stricter about null types by setting null_casts_as_any_type to
false (the default in mediawiki-phan-config)
Remaining false positive issues are suppressed.
The suppression and the setting change can only be done together

Bug: T242536
Bug: T301991
Change-Id: I0f295382b96fb3be8037a01c10487d9d591e7e01
2022-03-21 18:25:07 +00:00
Umherirrender
6dd8a2bb32 phan: Disable scalar_implicit_cast setting
Make phan stricter about scalar types by setting scalar_implicit_cast to
false (the default in mediawiki-phan-config)

Bug: T242536
Bug: T301991
Change-Id: Ia2fe30b17804186571722e728578121c8b75d455
2022-03-18 18:52:24 +00:00
jenkins-bot
d6170c9e20 Merge "In wfArrayInsertAfter(), skip insert on missing key" 2022-03-09 05:42:36 +00:00
Bartosz Dziewoński
0954804d0a Use Message::newFromSpecifier() in wfMessage()
As a result, when an existing Message object is passed in the $key
parameter, the function will return a clone of that object, rather
than a new Message constructed based on the key extracted from the
old message.

This is mostly relevant when the passed object is an instance of
a subclass like RawMessage or ApiMessage, but it could have other
unpredictable consequences. No test failures, though!

Change-Id: I4815e92dfaf5fbcc8c9356106738716c6b9ae0da
2022-03-08 02:49:51 +01:00
Tim Starling
5a49606d8e In wfArrayInsertAfter(), skip insert on missing key
Instead of raising a notice due to $offsetByKey[$after] referring to a
nonexistent array element, if the item referred to by $after is not
present, don't insert the array.

This is DWIM based on code review of the callers. wfArrayInsertAfter()
is mostly used to extend skin data. BetaFeatures, Favorites,
LiquidThreads and WebToolsManager are inserting an element after
preferences/watchlist only if the user is logged in, assuming that
logged in users have preferences. Temporary users are logged in
without preferences, breaking this assumption, but in all cases it is
acceptable to omit the link from the skin for such users.

Bug: T300263
Change-Id: I76473ef668ca4d9200ca42b57d793e1e03799ba6
2022-03-07 14:56:56 +11:00
Umherirrender
9efd9ca45e Add explicit casts between scalar types
* Some functions accept only string, cast ints and floats to string
* After preg_matches or explode() casts numbers to int to do maths
* Cast unix timestamps to int to do maths
* Cast return values from timestamp format function to int
* Cast bitwise operator to bool when needed as bool

* php internal functions like floor/round/ceil documented to return
  float, most cases the result is used as int, added casts

Found by phan strict checks

Change-Id: Icb2de32107f43817acc45fe296fb77acf65c1786
2022-03-01 18:19:33 +01:00
Reedy
86934b2fa8 Replace some more usages of Wikimedia\(suppress|restore)Warnings()
Change-Id: I2eb133a9e32116cd155f59086245bc4d15ecbfcc
2022-02-24 20:27:46 +00:00
daniel
a5277ce87f Avoid references to DefaultSettings.
This replaces references to DefaultSettings with
references to config-schema.yaml where appropriate.

NOTE: this does not yet change Setup.php. DefaultSettings.php
remains intact and is still being used.

NOTE: this does not remove usages in the installer, see I5d8843a1062fbf
for that.

Bug: T300129
Change-Id: Ie6152cf510c3be61bc22167ca6d90dfc28910a45
2022-02-22 19:43:50 +01:00
jenkins-bot
b71e80afcb Merge "Fix documentation of wfMessageFallback/Message::newFallbackSequence" 2022-02-18 19:26:30 +00:00
Ammarpad
4ecf3451e0 Fix documentation of wfMessageFallback/Message::newFallbackSequence
If all keys failed, instance of the last message key is returned, not first

Test: wfMessageFallback( 'x', 'y', 'z' )->text()

Change-Id: I115a626d5838240665d1f5044dbee1bac1dd5a37
2022-02-18 19:16:55 +01:00
Daimona Eaytoy
7b4a6337f7 GlobalFunctions: make the wfArrayDiff2 comparator a local closure
wfArrayDiff2_cmp is not really meant to be used as a stand-alone
function, and in fact it's never used in any repo known to codesearch.

Also add an assertion that elements are either strings or arrays:
the function already made this implicit assumption, so better
make things clear.

Change-Id: I0e08cdd7857d2f7b236bcde4183c8890d9e028c4
2022-02-17 18:22:35 +00:00
Alexander Vorwerk
01b0e099a8 Hard deprecate the global function wfWikiID()
deprecated since 1.35 and unused

Bug: T298059
Change-Id: I14ba3e7c98215cd584d7f99df2b5b4a198e6eab8
2022-01-10 20:50:50 +01:00
Alexander Vorwerk
fba157c773 Hard deprecate wfGetCache() and wfGetMainCache()
Bug: T293928
Change-Id: I7d9220730cb1f09d5b22f271fb172bd4640212ad
2022-01-09 22:25:00 +01:00