Commit graph

1705 commits

Author SHA1 Message Date
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
Umherirrender
76f9412dcd Remove deprecated global function wfIncrStats
Bug: T250316
Change-Id: Ibe8294fb9b55f5061a7b3522ddcbc8ea6d3b75fa
2022-01-02 21:59:37 +01:00
Reedy
7bf779524a Remove or replace usages of "sanity"
Bug: T254646
Change-Id: I2b120f0b9c9e1dc1a6c216bfefa3f2463efe1001
2021-11-19 23:19:42 +00:00
Alexander Vorwerk
296b485d9a Add deprecation warnings to wfLogProfilingData()
The logic has been moved to the MediaWiki class in If78c37046cf86.

Bug: T292269
Bug: T292253
Change-Id: I563c6529fc045c2ce3c2d67ba17ae31a388901dd
2021-11-17 21:58:45 +00:00
jenkins-bot
6080c9df86 Merge "Revert "wfParseUrl: rely on parse_url for proto-relative urls"" 2021-10-28 19:26:21 +00:00
Urbanecm
a568fdedc3 Revert "wfParseUrl: rely on parse_url for proto-relative urls"
This reverts commit 66e58d1ea7.

Reason for revert: let's revert and hope this will fix T294559

Bug: T294559
Change-Id: I2e4ae268e288f87b6c80fac08d275118f5b5cbd7
2021-10-28 19:04:46 +00:00
Bartosz Dziewoński
2254eba8aa Fix PHP warning with some inputs to wfCgiToArray()
Also add some more tests for it.

Bug: T294017
Change-Id: I8a4faa42c2219ce415fbb82a248b07a28b59157d
2021-10-21 20:49:34 +02:00
Petr Pchelko
66e58d1ea7 wfParseUrl: rely on parse_url for proto-relative urls
On July 12 2011 in df2306b97 Roan added this workaround
for parse_url lacking support for protocol-relative URLs.

In 2012 PHP 5.4.7 came out, that added support for
protocol-relative URLs to parse_url, see [1].

It's 2021, and after a decade of honorably serving our
community, this workaround can be now be retired.

It's not a simple deletion since we have custom 'delimiter'
bit that wfParseUrl returns, and we need to keep supporting
that.

[1] https://bugs.php.net/bug.php?id=62844
Change-Id: If9b3bb2a51afa7af1ba8e674eadaa8db4f6f33f9
2021-10-18 20:30:29 -07:00
Timo Tijhof
df32228920 profiler: Remove dependency on WebRequest from Profiler
I intent to remove Profiler::getContext/setContext after a week
without deprecation. I consider these methods as internal (they
predate the stable interface policy, and we forgot to triage this
class, it has neither `@stable` nor `@internal`).

The hard-deprecation in this commit is to detect any use that may
have gone unnoticed in WMF production from Codesearch analysis alone,
where no usage was found.

Bug: T292269
Change-Id: Id40679f21cc7a3f77a1b96a4bbd55daeaea16892
2021-10-09 03:00:45 +00:00
Tim Starling
65b1b6b56a Remove $wgShellLocale, always use C
$wgShellLocale was a flawed solution to the problem of locale
dependence. MediaWiki has its own concept of locale (the Language
hierarchy) and any kind of dependence on the server's libc locale is
incorrect and harmful, leading to bugs. Developers have an expectation
that functions like strtolower() will work in a certain way, and
respecting the locale set in the environment at install time violates
this expectation.

The problems with using C as a locale, which led to $wgShellLocale, are:

* escapeshellarg() will strip non-ASCII characters. This can be worked
  around by not using it. The security vulnerability it was trying to
  fix can be prevented in another way.
* Shell commands like rsvg will fail to correctly interpret UTF-8
  arguments. This is the reason for the putenv(). On Linux, this can
  be fixed by using C.UTF-8, which we didn't know at the time. On
  Windows, the problem is not relevant (there are unrelated issues
  with UTF-8 arguments).

Bug: T291234
Change-Id: Ib5ac0e7bc720dcc094303a358ee1c7bbdcfc6447
2021-09-24 17:25:01 -07:00
jenkins-bot
0220465fb6 Merge "Soft deprecate wfReadOnly() and wfReadOnlyReason()" 2021-09-20 06:04:40 +00:00
Alexander Vorwerk
1a22c1c1d7 Remove global function mimeTypeMatch()
This is done without a deprecation process since the function is
@internal and completely unused outside of core.

Bug: T291341
Change-Id: I4b074f83f9be67b5b5bc2d33b2a6a55bb109a2b3
2021-09-19 19:03:46 +00:00
Alexander Vorwerk
5097461939 Soft deprecate wfReadOnly() and wfReadOnlyReason()
Bug: T283978
Change-Id: I4362ba6a6f0cf016d5d63404335d8fa35073f991
2021-09-19 10:49:28 +00:00
Umherirrender
07b499fbcf build: Update mediawiki/mediawiki-phan-config to 0.11.0
Addition and remove of suppression needs to be done with the version
update.

Change-Id: I3288b3cefa744b507eadebb67b8ab08c86517c1c
2021-09-07 17:19:05 +02:00
Umherirrender
032b03dc7a Remove unneeded variable assignment
The variable already has the value

Change-Id: I75f25cc944e30d91a65e1d2bb0abce7d671b19b8
2021-09-03 22:51:22 +00:00
Timo Tijhof
837923941d debug: Return early in wfDeprecated(), and improve docs
Change-Id: I1e0832190a440b4c0cd0f725ed72bb883cd7cd9f
2021-09-02 02:57:47 +00:00