Commit graph

1794 commits

Author SHA1 Message Date
Bartosz Dziewoński
911abbf573 Deprecate wfArrayDiff2()
No longer used anywhere.

Change-Id: I7c35e92e2926489f140b86bca13efaf4144f4057
(cherry picked from commit f1de465a23d6e0c45c974e7a338d649c58dd2a4c)
2024-11-04 19:34:41 +00:00
Umherirrender
e662614f95 Use explicit nullable type on parameter arguments
Implicitly marking parameter $... as nullable is deprecated in php8.4,
the explicit nullable type must be used instead

Created with autofix from Ide15839e98a6229c22584d1c1c88c690982e1d7a

Break one long line in SpecialPage.php

Bug: T376276
Change-Id: I807257b2ba1ab2744ab74d9572c9c3d3ac2a968e
2024-10-16 20:58:33 +02:00
James D. Forrester
9203493606 Add namespace to remaining parts of Wikimedia\FileBackend
Bug: T353458
Change-Id: I49c843c9d8f6459c0fbf774afeea7a82fa564b59
2024-10-03 16:21:22 +00:00
jenkins-bot
286925fcef Merge "Hard deprecation of wfExpandIRI" 2024-09-07 13:07:24 +00:00
jenkins-bot
8a4138d7a5 Merge "Remove wfUnpack, deprecated since 1.42" 2024-09-07 13:01:10 +00:00
Ebrahim Byagowi
ba2190a467 Hard deprecation of wfExpandIRI
Deprecated since 1.39, now let's emit warning.

Depends-On: Ib08a0cc47a7b0d8ec7375d4505b447c4b770d4ef
Change-Id: I6bd166b998b2283ef0fb2de56a517b74d004f991
2024-09-07 08:03:40 +03:30
Ebrahim Byagowi
136a799336 Remove wfUnpack, deprecated since 1.42
Change-Id: I7e5df58fe809d3adb61bdb64444c4ca98641c6c6
2024-09-07 06:48:35 +03:30
Ebrahim Byagowi
5ea2d04efa Remove wfGetLangObj, deprecated since 1.41
Change-Id: I8d75eb513f9fc7bfcd89ebfa064435bdc92e72cf
2024-09-07 05:54:56 +03:30
jenkins-bot
1243bdf8ec Merge "Remove wfRemoveDotSegments, deprecated since 1.39" 2024-09-06 19:12:40 +00:00
Ebrahim Byagowi
ea43a44a2e Remove wfRemoveDotSegments, deprecated since 1.39
It didn't have any use outside the core so went for the removal
instead of raising warning and hard deprecation.

Change-Id: I08dab348a89f1fe1adccfad4f003d9fb8b233f0d
2024-09-06 22:00:09 +03:30
Ebrahim Byagowi
ab136421a8 Hard deprecating wfGetServerUrl
wfGetServerUrl is deprecated since 1.39, let's remove the
only use and turn it into a hard deprecation.

Change-Id: I82be851fe411cd002c9c5847fe3924a6c0a4ba50
2024-09-06 16:54:31 +03:30
Ebrahim Byagowi
68aee7d37b Hard deprecating wfUrlProtocols
wfUrlProtocols is deprecated since 1.39, let's remove the uses and turn it
into a hard deprecation.

Change-Id: Ic5f827f6e4563bab1b28f090da8f8613b124fcc5
2024-09-05 19:16:19 +03:30
Umherirrender
be39a18332 build: Use inline ignore for Generic.CodeAnalysis.AssignmentInCondition
Avoid that new code contains this pattern.

Depends-On: I7a9b5c89129fe4b555d03861f2c3ce3e9e2b2446
Depends-On: Ic2bcc7eeb16d3333dcd019bd209bd7fde843dab9
Depends-On: If20eddd8376ae2e8e29c4e56cd51f7b8eb6642b0
Depends-On: I3414f7e17f4bcb801857bc986bae8eb97aa2bfb8
Depends-On: I38b2729418e8389c681c6cd84858f5e5ed25bd3e
Change-Id: I7cfd2e027edd327cf8be6471e348c137fefacda0
2024-09-01 00:15:10 +02:00
Ebrahim Byagowi
697e19e461 Add MediaWiki\Registration namespace to registration classes
Bug: T353458
Change-Id: Ifa3b6a6e0353bb4ce21a3f4456f1fc696c8d377c
2024-08-10 10:08:22 +00:00
Bartosz Dziewoński
c9f73efd5a Namespace MessageSpecifier under Wikimedia\Message\
In change I625a48a6ecd3fad5c2ed76b23343a0fef91e1b83 I am planning to
make Wikimedia\Message\MessageValue use it, and we try to pretend that
it is a library separate from MediaWiki, so it makes sense to move
MessageSpecifier to the same namespace under Wikimedia\.

Bug: T353458
Change-Id: I9ff4ff7beb098b60c92f564591937c7d789c6684
2024-07-28 14:21:32 +02:00
Bartosz Dziewoński
9b8b99911e Deprecate wfMergeErrorArrays()
No longer used anywhere.

Change-Id: Id764fa47ab57875e99fee7d8b87d009cde73ea52
2024-07-18 13:33:56 +00:00
Umherirrender
9879723ef3 Use namespaced classes (1)
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: Ic4d4dd61de5ab896fb6173eb579c81f164a1e4a3
2024-06-16 20:18:23 +02:00
Ebrahim Byagowi
d21cc67450 Add namespace and deprecation alias to FileBackend
This patch introduces a namespace declaration for the
Wikimedia\FileBackend to FileBackend and establishes a class
alias marked as deprecated since version 1.43.

Bug: T353458
Change-Id: Id897687b1d679fd7d179e3a32e617aae10ebff33
2024-05-19 22:35:58 +03:30
jenkins-bot
820562496b Merge "Document the format used by wfGetCaller()" 2024-05-04 13:30:24 +00:00
jenkins-bot
e5699d2e21 Merge "Formally deprecate code marked with @deprecated" 2024-05-04 12:47:59 +00:00
Gergő Tisza
959371a456
Document the format used by wfGetCaller()
Change-Id: I7934aa45cc25a90acb72d0d45db0b9d0544a6be8
2024-05-04 14:28:46 +02:00
Amir Sarabadani
214674d6b1 namespace MWDebug
Bug: T353458
Change-Id: I99d728bd111ff882220cd175ff09d4da20b81eae
2024-05-03 22:59:47 +02:00
James D. Forrester
3ed6668745 Formally deprecate code marked with @deprecated
Some of these have been marked in-code as deprecated for a long while,
but haven't ever been announced in the RELEASE-NOTES (and later,
HISTORY) file, so let's mark them up now so we can get the ball rolling
at least.

Per Gergo, the AuthManager one was 'born deprecated' and should only
have been used by humans also reading the deprecation notice given in
the code, and indeed no uses are known to code search, so also emit
deprecation warnings there immediately; others will have to wait until
uses have been migrated.

Change-Id: I0c1c71d8f4293623039302da35d58d2a24367e97
2024-05-03 18:25:03 +03:00
James D. Forrester
30795cda4f Hard-deprecate wfGetDB(), deprecated in 1.39
Given this is a big deal, stealing the top-spot in the
release notes.

Pointing users primary to ICP rather than DBL as the
simpler, better route to take (ahead of us deprecating
the latter).

Bug: T273239
Change-Id: Idfe1e9dde7cdaf9c5241ff89f908a032d383304e
2024-03-25 16:28:23 +00:00
James D. Forrester
fe1fbb3a5c build: Upgrade mediawiki/mediawiki-codesniffer to v43.0.0
Depends-On: I5349d3378b5acd04f0d7c60072a9b1e3dd8f2052
Change-Id: I3b7fd4c460418e72ed0c36febef75f41bad0afb1
2024-03-01 15:58:13 -05:00
C. Scott Ananian
0cf68ad872 wfEscapeWikiText: add missing \r! case for symmetry
In I6c9dcfdbbb2c6eff9414e24d3f2693ebe576505a it was pointed out that
we were missing a case here.

Followup-To:  I34f2fa8c329e6f6771453b2f94dc4afbec31dac8
Change-Id: I6ae142883c8af8c2fd3766d99a2d417cf353928a
2024-02-14 22:29:20 -05:00
Bartosz Dziewoński
941280477c Clean up wfEscapeWikiText() input types
wfEscapeWikiText() has accidentally supported `null` and `false` as
input before, and now we should stay compatible with that.

Bug: T357032
Change-Id: I966e4c091dcd3234936f3a232ae0a629852051e4
2024-02-15 00:12:19 +01:00
jenkins-bot
831cab7875 Merge "wfEscapeWikiText: Don't choke if the replaced wikitext is empty" 2024-02-12 15:58:15 +00:00
James D. Forrester
102a4f8a35 build: Upgrade mediawiki/mediawiki-phan-config from 0.13.0 to 0.14.0 manually
* Switch out raw Exceptions, mostly for InvalidArgumentExceptions.
  * Fake exceptions triggered to give Monolog a backtrace are for
    some reason "traditionally" RuntimeExceptions, instead, so we
    continue to use that pattern in remaining locations.
* Just entirely give up on PostgresResultWrapper's resource vs. object mess.
* Drop now-unneeded false positive hits.

Change-Id: Id183ab60994cd9c6dc80401d4ce4de0ddf2b3da0
2024-02-10 02:22:41 +00:00
James D. Forrester
a3f4f7bbbb wfEscapeWikiText: Don't choke if the replaced wikitext is empty
Bug: T357032
Change-Id: Idcb12edc60c342a7f8e748320caaa836fe2ef482
2024-02-08 12:57:38 -05:00
thiemowmde
ab1e3a66e7 Make use of the [ ... ] operator instead of array_merge
The array spread operator is documented to behave identical to
array_merge. The syntax is just much shorter and easier to read in
situations like this, in my opinion.

Change-Id: I3b016e896e552af53d87d5e72436dc4e29070ce1
2024-01-31 15:47:44 +01:00
C. Scott Ananian
3fc635dcb2 wfEscapeWikiText: protect string against wikitext tokens formed at edges
The result of wfEscapeWikiText() did not consider inclusion of a string
within table context, and so `!!` and `!` at start of line were not
previously escaped.

Additionally, if you are inserting the result of wfEscapeWikiText()
into a wikitext string, the result can inadventently form new tokens
at the left and right edges.  For example:

   {|
   |<escaped string>

When the escaped string starts with a `-` or `+` it forms the `|-` or `|+`
token and changes the parse.

On the right side:

  <escaped string>_FORCETOC__

is not a magic word unless the escaped string ends with a `_`.

Token-gluing can also occur with the double newline token denoting
a paragraph separator.

This patch adds additional cases to wfEscapeWikiText to armor
its output against all contexts in which the output may be
inserted.

Depends-On: I56147520620d56a4b98c2f22d1f469b49aed761f
Change-Id: I34f2fa8c329e6f6771453b2f94dc4afbec31dac8
2024-01-26 17:48:46 -05:00
jenkins-bot
1a66246e19 Merge "Use native str_contains/str_starts_with in a few more places" 2024-01-25 16:27:36 +00:00
thiemowmde
4e7c3ca094 Use native str_contains/str_starts_with in a few more places
This makes the code quit a bit more readable, I believe.

strpos is especially confusing because it can return false when a
string doesn't contain the needle, as well as 0 when the string
starts with the needle. This is sometimes used as a feature (i.e. to
check if a string contains the needle, but doesn't start with it),
but that's not the case here.

A slightly more complicated change is made in TitleTest. But this is
only in a test and should verify itself when the test still succeeds.

Change-Id: I355ad1dc8e1725ae7a1eb652ec047ce7ff589cdf
2024-01-25 12:17:27 +01:00
jenkins-bot
50c3671537 Merge "Avoid indirect method calls in wfUrlProtocols" 2024-01-21 01:22:16 +00:00
thiemowmde
1dc83bd17c Avoid indirect method calls in wfUrlProtocols
This code exists since I706ef8a from 2022. It's hard to follow for
humans as well as tools like IDEs when the method name is hidden in
a string. There is no need to do this here.

Change-Id: Ib8438e6b7cc714f3657051ba546372735e925326
2024-01-20 20:33:54 +01:00
Daimona Eaytoy
175c0c4abf Replace more instances of deprecated MWException
Bug: T328220
Change-Id: Iba90f7f9b5766bccc05380d040138d74d5e9558a
2024-01-19 23:11:59 +00:00
Daimona Eaytoy
4be770a196 Deprecate and replace the wfUnpack global function
Move it to the StringUtils class, and make it throw a dedicated
exception. Update code in media/ to use the new method. Those seemed to
be the only usages across all known MW code [1], so hard-deprecate the
method as well.

[1] - https://codesearch.wmcloud.org/search/?q=wfUnpack&files=&excludeFiles=&repos=

Change-Id: I82ce96b6373443cf57a48b98595ca05290f37349
2024-01-17 21:17:24 +00:00
Bartosz Dziewoński
f61827d9e0 Replace $wgCommandLineMode checks with MW_ENTRY_POINT in developer code
This code should only be executed in development environments, never
in production, so it should be safe to mess with it.

Bug: T313841
Change-Id: I8cab7704b244db1432f4266b2e06e03452ffc98f
2023-12-14 15:24:48 +01:00
Fomafix
c440f063b3 Remove deprecated wfReportTime() and 'reporttime'
Change-Id: I0e19edf709e84ed2e360e64038f76428f1382341
2023-11-28 12:43:28 -05:00
Timo Tijhof
173954c1b8 GlobalFunctions: Minor clean up of wfMkdirParents()
* Remove docs for unchecked exception (T321683).

* Remove use of MWException, prefer more specific type (T86704).

* Remove use of AtEase (T253461).

* Merge `is_dir||mkdir||is_dir` into one check to more clearly express
  that our success criteria is explicitly one or the other, with
  a repeat for race conditions. This makes them not seem like unrelated
  checks or early returns, rather than the main code.

  This also fixes the seemingly unintentional difference where one
  check was before normalized $dir and one after.

* Use native trigger_error() directly as does not add value to use
  MWDebug::warning() with merely the default parameters. The last
  edge case was $wgDebugToolbar which got fixed with I62d864823ec8a.

Change-Id: Ic44798299a64f902decbc4cf2dbf2206a96c3837
2023-10-19 19:30:42 -07:00
Daimona Eaytoy
f78fd3710d Add $wgRequest to phan's globals_type_map
The base phan config uses a file_exists check to determine whether to
use the namespaced class name, but it doesn't work when running against
core because MW_INSTALL_PATH isn't set. So specify the type in the local
config, and remove @phan-var annotations added in I6bbdbbe6.

Also use `::class` instead of string literals for classes.

Change-Id: I994a0ed32ea948253ed07ee3cc8868a0eaa6d8b9
2023-09-11 23:22:12 +02:00
Amir Sarabadani
5bd33d46ef Reorg: Move WebRequest to includes\Request
This has been approved as part of RFC T166010

Bug: T321882
Change-Id: I6bbdbbe6ea48cc1f50bc568bb8780fc7c5361a6f
2023-09-11 21:44:34 +01:00
Amir Sarabadani
15a278189f Reorg: Move MWTimestamp to MediaWiki\Utils
Bug: T321882
Change-Id: I48c10343295c4eb3d9ef8037343b0070e928f040
2023-08-19 05:53:40 +02:00
Fomafix
1bdf03312b Deprecate 'reporttime' and hard-deprecate wfReportTime
wfReportTime is deprecated sice 11e0fba3b0 included in MedaWiki 1.40.

The last usage of 'reporttime' is in the hard-deprecated function
BaseTemplate::getTrail.

Change-Id: I47c7a70f5ead7d9639f2646dcd129864b05f61e6
2023-08-16 14:29:17 +00:00
Amir Sarabadani
7e135acdc0 Drop wfClearOutputBuffers
Bug: T264981
Change-Id: I9174f6bf74e303f6daaf834c2c578eab4c95aa01
2023-08-16 11:01:38 +08:00
jenkins-bot
b38e97cc8d Merge "UrlUtils: Make assemble() and removeDotSegments() stateless" 2023-08-10 23:37:28 +00:00
Timo Tijhof
b862174dc0 UrlUtils: Make assemble() and removeDotSegments() stateless
Follows-up 472a914c63 (I706ef8a50aafb51), which moved various
functions here en-mass, but these two don't require any state.

The warnings about parse_url() in UrlUtils.php have been obsolete
since about PHP 5.4, when it started to support protocol-relative
URLs, non-slash protocols like "mailto", and deal with spaces/newlines
correctly (https://3v4l.org/YWUkl).

Rather than complicate many components that would otherwise remain
stateless and unit-testable, fix these to once again be the static
functions they were.

For impact, see upto PS17 of change I5117eab95f57297eb02bed.

Bug: T227900
Change-Id: Ifb3f720fc429b107348644c98eb9cd8e1113a42a
2023-08-10 03:39:42 +01:00
Timo Tijhof
b28faecb2b ResourceLoader: Remove support for CSP nonce
The "nonce" CSP feature has been never been properly tested and is not
on track to be enabled at WMF or in MW by default. The use of
nonce-protected eval is not particularly meaningful. It is trivially
bypassed by mw.loader.implement, mw.loader.store, or importScript();
all of which allow any code to be executed directly, or to be stored
and loaded from a first-party origin.

The "nonce" feature is not required for the T208188 roadmap, and with
change I51b8535b2b21a3 there is now also a (small) performance reason
to keep this disabled long-term.

Until and unless there is a plan for enabling this particular aspect
of CSP, we might as well remove it so that we don't waste time our
time building abstraction layers and satisfying dependency injection
through many years for something that might never be used.

Note that this does not remove CSP support from ResourceLoader, and
does not take away from the future of enabling CSP in MediaWiki to
e.g. strictly block third-party scripts, or to require domains to
opt-in by site config or user pref (T208188).

Change-Id: I5a176c41a06a484a11e64bdacdc42b40811fe72e
2023-08-09 02:30:39 +01:00
Timo Tijhof
a1605cf5c8 GlobalFunctions: Update outdated wfScript() docs
We haven't supported custom file extenisons in a long time (e.g.
".php5" or ".phtml"). Use the same terminolgy we use elsewhere
these days, regarding calling it an entry point.

Change-Id: I57873680d779bcced049cb92b060b3e80aedf783
2023-07-24 19:35:13 +01:00